Home

Previous 10

May. 29th, 2008

Geek Dad, or using Perl to do math

Yesterday [info]littlemeridian came to me and said she knew the sum of 1+2+3... etc to 100. She had figured out a way to solve the problem without adding all the numbers.
"I can bang out a perl program that can do the math," I said, not convinced she was right (she was right, btw). So we sat at my computer and I wrote this easy program that adds consecutive numbers up to a limit you specify from <STDIN>. It took us a little while to get the math right but we eventually got it.
see the code )

May. 20th, 2008

netiquette websites +1

I ran into a few websites about netiquette today, and thought I'd share. The +1 may be useful for determining if a website is up or down...

netiquette:
five.sentenc.es
thanksno.com
bccplease.com
and +1:
downforeveryoneorjustme.com

May. 13th, 2008

SSH Vulnerability

from http://www.ubuntu.com/usn/usn-612-1

full notice behind the cut )

What does this mean? You should update Open-SSH if you run a Debian-based Linux distro, like Ubuntu, and recreate and redeploy your SSH keys.

May. 7th, 2008

Ubuntu users: Enigmail/Thunderbird invalid password error fix

I use Thunderbird and the Enigmail extension a lot at work. I like to sign all my emails. After installing the latest release of Ubuntu, I had some trouble. Seahorse (the new default key manager) was not recognizing a passphrase caching agent (either gpg-agent or seahorse-agent). Both were running....
when trying to sign an email, I would get an error like
gpg command line and output:
/usr/bin/gpg --charset utf8 --batch --no-tty --status-fd 2 -d --use-agent
gpg: problem with the agent - disabling agent use
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode

Turns out the fix is easy, and numerous bugs have been filed.

All you have to do is delete the file /etc/X11/Xsession.d/90gpg-agent and restart X (CTRL+ALT+Backspace).

Apr. 25th, 2008

question for you perl programmers...

I wrote a script that will post to twitter. It takes a command line argument or reads a random line from a text file, and posts the result. I've got it working, but I think code could be a little cleaner.
Basically, I want to know if there is a way to put each element in an array ( like @ARGV) into a string.
For instance, if I run perl post-to-twitter.pl here is a tweet, I'd like to turn "here is a tweet" into a string so I can put it in a scalar like $post.
I think I could use a reference, but I have a hard time wrapping my head around the concept. I really want to turn the last 4 or 5 lines into one.

Thanks...

here's my code )

Oh yeah, if the command line argument has an apostrophe, the script breaks... Why is that?

Mar. 31st, 2008

new gpg key

I have a new gpg key. You can get it from the link in my profile, or here.
Fingerprint: E4C9 4420 8972 C50B 9CC8 DF0F B926 3A8B C46A F91F

Mar. 22nd, 2008

It Came Yesterday

My computer arrived yesterday... It's awesome!

Mar. 19th, 2008

shipped

Call me excited. My new computer shipped today at 6:15am.
Call me bummed. I still don't have a tracking number...

Mar. 15th, 2008

Me = Stoked!

After some dissapointment last night while trying to order a Dell Outlet Scratch & Dent, I just placed an order for a beast of a computer. With the Dell Outlet you have 15 minutes from the time you put something in your cart until the moment you complete your checkout, or else they empty your cart. This happened to me twice last night as I was researching this thing. When it didn't show up for sale again I was convinced that somene else snagged from me. But when I looked again, maybe 20 minutes ago, there it was!
Anyway, I'm excited (can't you tell?). And since it doesn't have to be built, I'm guessing It will ship within a week! Yes!

Here are the specs... )
There are some extras I wouldn't have gotten, but for the price you can't beat it. Lord of the Rings online anyone?

Mar. 5th, 2008

Perl and regular expressions

I'm doing what my boss calls "professional development," aka learning more Perl and prgramming skills. Today I was doing an exercise that was pretty simple. Calculate an employee's gross pay based on their rate of pay, hours worked and overtime hours worked. The math is easy.

$pay_rate * ( $reg_hours + ( $ot_hours * 1.5 ) )

But then I wanted to validate input, so my program wouldn't break when the user input wasn't non-numeric. I came up with (what I think is) a unique test. I created a regex that matched only digits and an optional decimal point.

/(\d+\.?\d*)/

Problem was it let through input like 7.h. I didn't want that. So I just compared what the regex matched to the string I was putting throught the regex! If they matched, input was valid!

if ( $_[0] =~ m/(\d+\.?\d*)/ and $_[0] eq $1 ) {
$is_valid=1;
}


I'm giving myself a self congratualory high-five.

Previous 10

mangavatar

November 2009

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     

Advertisement

Syndicate

RSS Atom
Powered by LiveJournal.com