debugging in safari..

Posted by sergio_101 on Apr 19th, 2007
2007
Apr 19

one of the biggest reasons i develop in firefox is that there are tons of great debugging features..usually, all kinks can be worked out in firefox..every now and then, there’s a bug in safari that does not show up anywhere else.. it can be DEADLY trying to figure out what is going on..i ran across an incantation i have never seen before that will open up a debug menu on the screen. this has saved my butt in the bug below.so.. here it is!defaults write com.apple.Safari IncludeDebugMenu 1 that will make the secret menu show up, and save you tons of development time.

this is some stuff i edited and added..

google maps and safari

Posted by sergio_101 on Apr 19th, 2007
2007
Apr 19

okay, here’s something to think about..

we just released a new website at:

http://www.theresthisplace.com

it is heavily reliant on google maps.. actually, the whole point of the site is google maps.

i learned a WHOLE bunch of interesting things doing this.. just when i think that the i have found out where all the pitfalls of javascript are, i find a new one..

this one is TOTALLY my fault.. but i would imagine tons of folks will make this error, so i am hoping to save someone a few hours.

when programming application that have heavy reliance on geographic location, it’s VERY tempting to use variables like:

add_marker(lat, long);

BUT!

in case you have forgotten, ‘long’ is a reserved keyword in javascript..

here’s the problem..

firefox, ie, and everything else will not have a problem with this..

safari will choke on this.. and.. safari doesn’t really clue you in on errors.. there is no firebug..

if you find your maps are not showing up in safari, do a quick code search for this error..

let me know if this worked for you..

mac widgets and adsense

Posted by sergio_101 on Apr 19th, 2007
2007
Apr 19

like most people who use adsense, i am kinda anal about it.. i check it ALOT.. i figured that there would be a a widget that would keep me posted on my earnings.. it turns out that there are ALOT of such widgets..

the problem is, i couldn’t get any of them to work.

i opened up the source code, and found that they use curl to download the current csv file. this seems to be the problem, as in order to get into the file, you must log in to google. the problem is, the curl incantation doesn’t let you into google.

the incantation looks like:

curl -o temp.html -s -c cookies -d username=$2 -d password=$3 https://www.google.com/adsense/login.do

where $2 and $3 are passed by the widget.

i tried unraveling the google login, but had to give up after a few minutes, since i have real work to do.

anyway..

once i get that wired, the widgets should work just fine..

has anyone else gotten these to work?

cleaning up email lists with ruby and regex

Posted by on Jan 22nd, 2007
2007
Jan 22

lately, we have been getting a ton of email lists from clients. these usually consist of THOUSANDS of email addresses that have been gathered on their websites. in every case, there was no address validation on the code that gathered the addresses, so we end up with a bunch of gobledeygoop. the list management software that we use (”php list”:http://www.phplist.com/) will poop if there are any invalid addresses in the text file.. so i came up with this..

i am aware that the function that creates the text file from the array is clunky.. i just cut and pasted it from another program i wrote to do something entirely different.. if it turns out that this becomes a bottleneck, i will look at it..

anyway.. hope this helps someone out..



if ARGV.length != 1
  puts "Usage: clean_addresses.rb [lt]input_filename[gt]\n”
  puts “Will output [lt]input_filename[gt]_cleaned.txt”
  exit
end

filename = ARGV[0]

unless FileTest::exists?(filename)
  puts “Input file does not exist..”
  exit
end

successes = Array.new
failures = Array.new

def create_txt_from_array(array,filename)
  text_file = String.new
  array.each do |e|
    text_file [lt][lt] e
  end
  open(filename,’w') {|f| f[lt][lt] text_file }
end

filename_parsed = filename.split(”.”)
output_filename = filename_parsed[0].to_s+’_cleaned.txt’
fails_filename = filename_parsed[0].to_s+’_failed.txt’

output_file = File.new(output_filename,’w+’)
fails_file = File.new(fails_filename,’w+’)

puts “Outputting to: “+ output_filename

IO.foreach(filename) do |line|
  if line.chomp =~ /\A[\w\._%-]+@[\w\.-]+\.[a-zA-Z]{2,4}\z/
    successes [lt][lt] line
  else
    failures [lt][lt] line
  end
end

create_txt_from_array(successes,output_filename)
create_txt_from_array(failures,fails_filename)

puts “There were: “+successes.length.to_s+” successes.\n”
puts “There were: “+failures.length.to_s+” failures.\n”

ruby email address validation regex

Posted by on Jan 15th, 2007
2007
Jan 15

one of the things i end up having to do day in and day out is validating email addresses before shoving them into a database. honestly, i haven’t been doing it as well as i should be. the only real reason i haven’t is that i didn’t have time to sit around with the ruby book and plod through how they do regex. this weekend, i cracked the book and it was simple.

there are a bunch of decent canned javascripts to do just this, but in alot of cases, our email are sent via AJAX, so it would be really handy to do this with ruby and part of a rails controller.

before i got too involved in the whole thing (i did digest the chapter, though) i did a quick google on a regex. i am not at all opposed to borrowing other people’s code.

over at “devx.com”:http://www.devx.com/enterprise/Article/31197/0/page/3 i found this really keen regex:

/\A[\w._%-]+@[\w.-]+.[a-zA-Z]{2,4}\z/

here is my quick and dirty self explanatory test of how it works.

the code:

emails = ["test@example.com","jo@jo.com","rex","f4$m@you.com",
            "test@go,com","test@example.co", "test.example@example.c",
            "testing.example@example.com"]

emails.each do |e|
  if e =~ /\A[\w\._%-]+@[\w\.-]+\.[a-zA-Z]{2,4}\z/
    puts e + ” is a valid email address\n”
  else
    puts e + ” is not a valid address\n”
  end
end

as you would guess, produces output like this:

test@example.com is a valid email address
jo@jo.com is a valid email address
rex is not a valid address
f4$m@you.com is not a valid address
test@go,com is not a valid address
test@example.co is a valid email address
test.example@example.c is not a valid address
testing.example@example.com is a valid email address

let me know if you find anything that makes this regex choke..

a new slant on backups - backup with DAR..

Posted by on Jan 4th, 2007
2007
Jan 4

i have been working for a few months on a way to backup our server so that the files are easy to access when needed, and easy to deal with at the same time.

for a long while, we used tape as a backup means. since we only have a few hundred gigs a day to backup, tape was slow, clunky for retrieval, and expensive..

we switched a few months ago to a pair of hard usb hard drives. each one has a 400g drive in it..

i have previously used ssh -> rsync to do the backups, but the 400g drives can no longer carry the whole thing.. i wrote a cron job in ruby that does all the work, but like i said, the drives are tapped out.

my first thought was to use the ‘compress’ option in rsync, but that does not compress the final destination, but only compresses the files as they are transferred.

i dug around yesterday, and found DAR this seems to do exactly what i need, other than run over ssh (it may well do this just fine, i will have to see..) right now, i just want to get something workable in place..

rsyncing all my files over now, and will try a DAR backup in a bit here.. the cool thing about DAR is that it will compress the archive.

if this sounds interesting, here are some links to some good stuff..

i really should spend some time going over the system to make sure it’s based on common libraries, etc.. but it seems pretty solid.

some concerns that i do have:

*how to script this so it runs a new differential backup each day.. i am not sure if i need to take care of incrementing the filename of the differential backup. i am not really too concerned with how to do it programatically, i just want to make sure i am not doing something that DAR might do internally, and more elegantly..

hacking b2evolution..

Posted by sergio_101 on Jul 28th, 2006
2006
Jul 28

for those of you who keep up with blog engines, you probably know right away that this blog is based on b2evolution. this is a really great engine, and is in use everywhere. that is a good thing and a bad thing. the bad thing is that you really have to keep up with spammers, as they exploit this thing day in and day out. it is a major pain, and something you have to learn to live with.. that’s okay..

i started using my blog though, as a front end to my picture of the day list. this was all fine and dandy until i started email the html pages to my list. this caused some serious problems.

first, the list was being mailed a page that was chock full of ads and crap that i didn’t want to send to my list. it also had some forms and divs that did not translate well..

what i needed was a stripped down page.

here’s what i did:

checking around on the manual, i found that you can add skin=someSkinName to override the skin of the page. this works even if you have skin switching turned off.

i took the basic skin, and edited it to suit my needs (totally stripped down) and then, when it came time to mail to my list, i just tacked &skin=basic to the end of my url..

this is MUCH better than anything i have used yet.. we’ll see what happens..

trackbacks between b2evolution and haloscan

Posted by on Sep 29th, 2005
2005
Sep 29

for some reason, i am having all sorts of trouble with this. i have been trying to leave trackbacks on blogger powered blogs, but have not had any luck with the url showing up on the trackback. i know that blogger.com does not normally support trackbacks, but uses haloscan to power them.

i tried doing a few trackbacks on some blogger/haloscan blogs and i found that the trackback only leads back to the front page of the referring blog.

the problem i have with this is that i very well could have a ton of posts that would obscure the post i am referring to.

say i trackback to someone, then a week later, they track back to me.. if i post more than five post, the referring post would be lost.

i would sure like to hear from anyone who would know how to deal with this. how to make the trackback point back to the original post..

dangit..

Ashland University Student Blogs

Posted by on Sep 28th, 2005
2005
Sep 28

this is so cheesy.. i know i shouldn’t do this..

BUT..

i helped put these blogs together, and i was wondering if i tracked back to one of these postings, if my text link would show up under referrers..

yeah, it’s a cheesy way to test it.. but hey, i wanna check this out in just a few minutes.. and if i get a few hits outta the deal, who is gonna REALLY be hurt, anyway?

overLIB - Homepage

Posted by on Sep 27th, 2005
2005
Sep 27

i have been looking for something like this for some time. what it does is pop up a small little text box over link text on a website.. sorta like a tool popup.. i think i am gonna try to make use of this in some of my upcoming projects…

Next »