Things I learned the hard way XIVII

jQuery When the DOM isn't reacting to your javascript selectors as expected try a little specificity: instead of this:
  $("#item_id > a")
do this:
  $("#item_id > ul > li > a'")

Posted by jeremy 14/02/2010 at 15h41


Snow Leopard 10.6 Rails/Passenger

Got this error when loading a rails site served under my local apache"
*** Exception RangeError in PhusionPassenger::Railz::ApplicationSpawner (integer 4294967294 too big to convert to `int') (process 1097):
I updated my passenger gem and regenerated the apache passenger module, updated the httpd.conf at it was all good after that.

Posted by jeremy 05/09/2009 at 16h10


Javascript Exceptions - testing for true - When is undefined actually undefined?

Javascript has to know what 'it' is before Javascript can tell if 'it' is what you want 'it' to be. Example:
if (unreferencedVariableName) { alert('Impossible! an unreferenced variable cannot return true. In fact it cannot return at all!'); }
Result: ReferenceError: unreferencedVariableName is not defined
/* is as true as the unescapable pain and suffering of being an alive human being  */
if (typeof(cowBoySuckMonkey) === 'undefined') { console.log('suck it!') }


/*   these are false - no if-fu for you!   */
if (typeof(cowBoySuckMonkeee) != 'undefined') { console.log('suck it again!') }
if (!typeof(cowBoySuckMonkeee)) { console.log('suck it for real!') }

/* 'undefined is something I guess - just not what I wanted to test against */
if (typeof(cowBoySuckMonke)) { console.log('suck it nut gobbler!') }

var cowboySuckMonkay = '';
if (typeof(cowboySuckMonkay) != 'undefined') { console.log('suck it empty string!') }
/* no joy */
if (typeof(cowboySuckMonkay)) { console.log('suck it empty string, part duex!') }

/* well, I guess an empty string is false - CaulkGobblin! */
if (cowboySuckMonkay) { console.log('suck it empty string, you still not true!') }

if (cowboySuckMonkay == '') { console.log('suck it empty string, now you true!') }
so much to remember…

Posted by jeremy 18/08/2009 at 15h06


comparison of Fixnum with String failed

Where the error occured

Rails 2.1.2 / bundle_fu / Javascript file

Why the fu…?

A javascript files that ends with a line commented out. -1 is being compared to an empty string.

Fix

Add a blank line at the end of the Javscript file(s) that end with commented lines.

Posted by jeremy 15/08/2009 at 07h45


designation agitator

My favorite class name when styling a page is ‘padahoe’. If anyone ever asks what it stands for I’ll tell them “pad a horizontally oriented element”. Lies, damn lies, statistics.

When I commit to git I tend to flavor my commit messages with humorous snark, usually related to how something in the application is deviously circumventing my attempts to enforce my authority. My logic is shot through with regression insurgents.

Posted by jeremy 02/04/2009 at 14h14


violating the linksys rvs4000

FTP is way the fuck broke on my past the return product policy expiration date of my gigabit router. I want to hack it but A) I'm just not that skilled in the ways of *nix; b) I'm too lazy to learn mips cross-compiling for linux embedded systems (whatever the fuck that means).

So I google my incompetence as usual. Search for "rvs4000 ftp" and you get a whole lot of what you already know. The shits broke. No ones gonna fix the shit. You're ten kinds of fucked if you want to ftp anything, ever.

So I roll a search on the processor "star 9202" which drops me a few gems of badassery:
Hacking the WRVS4400NX Stock Firmware V1.1.03 for Full Linux Shell Access
http://openwrt.org/logs/openwrt.log.20071102

Not my model - but it appears the only difference betweenRVS4000 and the WRVS4400N is that the WRVS4400N has a wireless chipset - that is a separate processor to run the wireless services with.

So they seem to be the same except one does wireless and one does not. So I go to the diagnostics pages of the administration ui and start pasting in the different commands from the "Hacking the WRV44...." post to see what happens. No dice. The ftp no longer works - probably a good thing - so I start stumbling around the web glossing over many pages of stuff about busybox. I try pasting in all kinds of shell commands into the way not secure 'Traceroute Target:' field when I happen to get a command to try off of the busybox wikipedia page: ';/bin/ls' - I paste-a-bitch and wa-la:

ARARPTable.htm
AccessRes.htm
Administration.htm
AppGaming.htm
Backup.htm
DHCPClientTable.htm
DMZ.htm
Diagnostics.htm
EditList.htm
Factorydefaults.htm
FirmwareUpgrade.htm
Hidden_telnet.htm
IM-P2P.htm
IPS-N.htm
LocalNetwork.htm
Log.htm
Ping.htm
PortRangeTriggering.htm
QoS.htm
Quick_vpn_setup.htm
RVS4000_Admin.pem
RVS4000_Client.pem
Reboot.htm
Report_Pic-n.jpg
Routercfg.cfg
Routing_Table.htm
Security.htm
Setup.htm
Setup_MAC.htm
Setup_lan.htm
Setup_routing.htm
Setup_summary.htm
Setup_time.htm
Setup_wan.htm
SingleForwarding.htm
Status.htm
Summary.htm
UI_02.gif
UI_03.gif
UI_04.gif
UI_05.gif
UI_06.gif
UI_07.gif
UI_10.gif
UI_Cisco.gif
UI_Linksys.gif
VPNPassthrough.htm
acl.htm
cisco.css
down_chart.jpg
err_msg
func.js
fw_version.pat
help
index.htm
info.htm
ip_conntrack.htm
left.gif
linux.js
log_data.htm
log_outin.htm
middle.gif
mm_menu.js
msg.js
new_rule.htm
po1_0.gif
po1_1.gif
po2_0.gif
po2_1.gif
po3_0.gif
po3_1.gif
po4_0.gif
po4_1.gif
ppp_log
qos_service_managment.htm
quickVpnStatus.htm
raw_data.htm
reboot_guage.htm
report.htm
restore_config.cgi
rh_bg.gif
rh_cisco.gif
right.gif
rvs4000
service.htm
set_vpn.js
setup.cgi
switch_8021x.htm
switch_diagnostic.htm
switch_dscp.htm
switch_mirror.htm
switch_param.htm
switch_port.htm
switch_qos.htm
switch_queue.htm
switch_rstp.htm
switch_status.htm
switch_vlan.htm
switch_vlan_mem.htm
switch_vlan_port.htm
table.jpg
table.png
tr069
tracert.htm
trash.gif
up_chart.jpg
upgrade_flash.cgi
upgrade_pem.cgi
upgrade_sig.cgi
upload_lang.cgi
vpn_adv.htm
vpn_main.htm
vpn_summary.htm
vpnsum.htm
wan_0.gif
wan_1.gif


Would you check that the fuck out!?! 'Hidden_telnet.html' I (again) paste-a-bitch and HOT DAMN if I don't get some purty radio buttons. And after i click yes in the little circle and save the settings hot damn if i don't have an insecure as all holy hell no login needed telnet accessible router spread wide open and waiting like a rufied sorority pledge coed at the frat kegger... and a quick test of my dyndns enabled domain confirms that yes, I do have world facing telnet access of my router sans any security. None, nada. Zero. Luckily I can uncheck my telnet access on my hidden telnet access page and then save settings so I longer have hidden telnet access.

speedy:~$ telnet 192.168.0.1
Trying 192.168.0.1...
Connected to 192.168.0.1.
Escape character is '^]'.


BusyBox v1.00 (2007.09.12-05:31+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# help

Built-in commands:
-------------------
        . : break cd chdir continue eval exec exit export false hash
        help local pwd read readonly return set shift times trap true
        type ulimit umask unset wait

# ls
Active_ALG.list          linuxrc                  sbin
bin                      lost+found               tmp
dev                      nat-pt_packet_stats_log  usr
etc                      proc                     var
lib                      root                     www.eng
# ls bin
ash          df           ipaddr       mount        radvd        umount
brctl        dhcp6-serv   iplink       nat-pt       rm           uname
busybox      dmesg        iproute      netstat      sed          vi
cat          echo         iptunnel     ping         sh
chmod        flash_tools  kill         ping2file    sleep
chown        gzip         ln           ping6        sysinfo
cp           hostname     ls           ps           tar
date         ip           mkdir        pwd          touch
# exit
Connection closed by foreign host.


Maybe I can use this knowledge to fix my ftp problem. Or to get my whole home network compromised.

Posted by jeremy 17/06/2008 at 05h05


typo theme: bird flu update

Oh boy do I suck like a black hole. My bird flu typo theme had some major issues in the default.rhtml. So if you've downloaded it grab it again and trash the old one. Now Working: RSS Feeds; ajax comments; ajax admin menus...

Posted by jeremy 12/03/2006 at 10h39


on the process of progress

Essential understanding: In php str_replace and preg_replace do function similarly yet if you want exact matches you have to specify your regexp pattern with serious prejudice lest you match ANY and ALL partial or exact string matches and fubar your sweet logic with redundant nasties. I consider knowing this progress. Next up is understanding the hows and whys of stringing methods in ruby... Feet don't fail me now!

Posted by jeremy 10/03/2006 at 10h11


things i learned the hard way | VI

Error handling in rails is very technical. The TextMate Backtracer Plugin has been invaluable to me in my development in recent days, yet it only gets me to the file(s) when something is amiss in the code.

Building and running tests is one way of confirming the functionality of your application, and I’m learning the power of good testing, be it quite slowly and with a lot of errors.I’ll get there.

Here is a short list of things I had to consider when flopping from code to browser during development and things kept blowing up in my face:

  • Ruby/Rails has RESERVED WORDS. If you have a class/table that isn’t playing nice make sure you aren’t naming it with one of these. This is tantamount to pouring sugar in your gas tank. And then driving in reverse at full speed. While wearing a blindfold. With your hair on fire.
  • Column names in your tables need to change with alterations to any class/model names, as well as any has_many/belongs_to associations along with any model inclusions in your controllers. If you’re not to invested in the code it’d probably be easier to regenerate a fresh app with the correct model/controller name. Running ./script/destroy (the arch nemesis of ./script/generate) can help in crime scene clean up, but you still have all those pesky symbols/variables/methods with the poison name throughout your app patiently waiting to spurt their demonic ire. Exterminate them with aggression.
  • An objects information will carry from request to request in the session but you still have to stuff it into an instance variable inside whatever controller method is being called upon. I have a tingling sensation in my unmentionables that suggests session customization and databases can smooth out this bumpy road, but this strains the withering tethers of my sanity upon contemplation. I can only learn so much each day.
  • Getting compile errors means you’re trying to bake a duck with a hammer on a string in a pail of kittens. It won’t work. Ruby/Rails doesn’t know or particularly care what you are trying to do, but how you are going about doing whatever it is you are trying to do will never, ever work no matter what. Get rid of whatever you added since the last time it worked and try again. Remember when you went to grandmas house and you had to take off your shoes and you weren’t supposed to go out into the field because you’d get muddy? Yeah, Rails has grandma rules that sometimes take all the fun out of life and make your feet cold.

Throwing away code is a part of development, just as throwing away designs is a part of being a designer. Having the willingness to let go of what’s not working makes room for what will. Even if what that is is nowhere to be seen at the moment.

Posted by jeremy 24/02/2006 at 09h29


imagemap rollovers with area shape="poly\

[UPDATE:Now with Prototype]

dilemma: an image map with irregularly shaped link areas that need to have a separate hover state for each link/area. solution: javascript, css classes and advantageous id/class naming. stats: 5 files = 2 gifs; 1 css; 1 js; 1 html Using part sliding doors and part unobtrusive javascript I ground out some simple code to do the business of making an image map with link hover states. *view example* (opens new window) get the code First things first: Let the *DOM* be your guide.

Posted by jeremy 20/12/2005 at 03h12