Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Friday, June 17, 2011

Tithing

I've mentioned on this blog before that I pay tithing, and that I feel that I receive a lot of blessings as a result.  Here's the most recent:

Every now and then, my previous employer will call me up and ask me to do small jobs for them.  Shortly after we moved into our new house, he called me up and asked if I could do a project.  It was a fairly good-sized project, and I told him my estimate would be $1500-$2000, but I ended up turning it down because I wanted to spend my few free evening hours working on my novel rather than programming.

Well, the next day, we got a visit from the water company.  Apparently our house was using 15,000 gallons of water a day.  We called a plumber who discovered there was actually a couple leaks--one of them underneath the concrete slab that our house was built on.  The estimate?  $1590.

Well, since we had just bought a house, we had no money left.  Without the side-job from my previous employer, we would have been in trouble.  I called up my old boss, told him I'd do it, and spent the next couple weeks of evenings working on it. 

The final bill was $1725, which after I paid tithing, covered all but $40 of the plumbing bill.

Tuesday, July 13, 2010

Stir-fry

Sorry about more geek humor, but this made me laugh.

Today I was on an airplane, browsing through some third-party computer code looking for a particular programming function (a block of code that performs a given task). In the file I was looking in, all the functions manipulated strings of characters functions, so all of them were prefixed with "str," short for "string," and pronounced "stir."

I passed such functions as strcpy (copy a string of characters), strcmp (compare two strings), and strlen (get the length of the string), then I came across another one: strfry.

The description of the function? "Sauté string briskly."

It was so out-of-the-blue in the staid programming code that I started laughing. Even though it obviously wasn't the function I was looking for, I had to do a little more digging to find out what the function did. Apparently it randomizes the order of the letters in the string. Apt.

Tuesday, July 01, 2008

Programming

In today's digital age, knowing how to program is a great ability.

In the past couple months, I've built Google gadgets to show Child and I how much money we have left in our bank account, and how many minutes we have left on our phone plan (see below).


(Most of the content [text/images] is grabbed directly from our account at tmobile.com. The black and white bar across the gauge is a custom addition, however. It marks where we should be for the time in our billing cycle--currently we have minutes to spare.)

I've also built custom RSS feeds for some forums and sites I frequent. This has a downside, however. In the past, whenever I'd get bored, I'd browse my collection of sites. Now, however, any updates to the sites are delivered right to my door, so it takes me 10 minutes to scan all new content, and I'm bored again.

My most recent project has been learning how to build Firefox 3 extensions. As my first example, I built a word-replacement extension. It can run automatically, or you can run it per-page from a right-click menu item. It replaces a list of words with replacement words on all webpages you view. Good for cleaning up forums with a lot of bad language, replacing common misspellings or abbreviations, etc. Something maybe parents might be interested in.



The first comment someone posted after I submitted the extension to the extension-directory was as follows:
First- I find this hysterical... not because it exists, but because I have a list of friends that I could get to transfer from IE to Firefox just for this extension. (I live in Utah- and all my friends are Mormons- turns out the stereotypes are true)
This person doesn't know that I'm also a Mormon living in Utah. :)

I found the comment amusing, but I'm really not sure why people are so (egotistical? self-centered? close-minded?) that they think everyone else in the world shares their exact same moral standards.

I don't laugh at, look down on, or denigrate your use of language on your (website, blog, whatever). You didn't ask me to read it, and I accept you for who you are. So why do I get laughed at or looked down on for holding to my own moral standard?

Monday, June 16, 2008

Underhanded C Programming

A couple days ago, Slashdot posted a link to The Underhanded C Contest. The idea is to write a program that redacts part of an image while making it possible to recover the lost information. The trick: it has to look innocent to another programmer reviewing your code.

My first version has the following output:

BeforeAfter

Here's the pertinent part of the code:

Redact to black (the "right" way):

p.rgb[R] = 0;
p.rgb[G] = 0;
p.rgb[B] = 0;

Redact to random noise (an acceptable way, see image on right):

p.rgb[R] = rand();
p.rgb[G] = rand();
p.rgb[B] = rand();

Nefarious redaction to random noise (see image on right):

p.rgb[R] ^= rand();
p.rgb[G] ^= rand();
p.rgb[B] ^= rand();

The key is using "^=" rather than just "=". The "^" will perform a bitwise XOR, and XOR has an interesting property. If you XOR A with B, and XOR the result by B a second time, you get back A.

So all we have to do to get the proper image back again is use the same sequence of random numbers, and that's easier than it sounds. It's customary to seed the random number generator using the following code:

srand((unsigned int)time(0));

But the file we're spitting out has the timestamp it was created--the exact time we're using as the seed in our RNG!

(If you're worried about the timestamp changing as the file is copied and passed around, then simply embed the time as a comment in the file--not nefarious at all.)

Friday, May 16, 2008

Ethical Dilemma

I have an ethical dilemma. I do occasional freelance projects, including sub-contracting from a friend who in turn contracts directly with clients. A couple weeks ago, we had a three-way call with a client to discuss a project. My friend introduced me as the programmer who would be working on the project, and I gave the client my contact information so we could discuss the project more directly.

Anyway, due to certain circumstances, I didn't end up taking this project from my friend. Time goes by, my friend doesn't get the job done, the client starts getting irritated with the delay, and finally emails me, asking if I'd like to work for him directly, rather than going through this friend.

What's the ethical response?

My immediate response is: No. It would be unethical for me to take this job. My friend lined it up, presumably has the intention of doing it, so I shouldn't interfere. However, do the following facts change the situation?
  1. It's been 4 weeks since my friend lined up the project, and still hasn't completed it. The client obviously needs it done quickly, and doesn't care who does it.
  2. My friend owes my $1,000.
I still don't think that changes the ethicalness of it, not to mention I just wouldn't want to get caught in the middle of anything.

My response was initially going to be that I'd be happy to take on future projects, but I was going to take a hands-off approach to the current project. However, just now while I was typing this blog post, my dilemma was solved.

My friend and I started talking on IM, and I delicately mentioned that his client was getting impatient. My friend promptly asked if I wanted to take over the job. Dilemma solved.

Although that's good, I was actually looking forward to seeing other peoples' takes on the situation. Feel free to comment if you'd like. :)

P.S. Amazon is interested in doing an interview with me. Is an interesting job/good pay/good benefits worth living in Seattle and giving up the freedom that freelancing would give me? If all I had to do was the programming side of freelance work, I'd stay as a freelancer in a heartbeat, but I also have situations like the one I posted about above...

Monday, April 14, 2008

Tutoring

At the beginning of the semester, I volunteered to tutor at school. I was paired with a freshman taking the introductory programming clas. He contacted me once and I helped him out, then I didn't hear from him for the rest of the semester.

On Friday, he contacted me again. "I need some help!" he said, and we arranged a time on Saturday to meet.

I quickly realized that he didn't want tutoring, he wanted someone to do his projects for him. During the course of the semester, they had to do about 10 programming projects. The grade was important, but if nothing else they had to complete them to pass the class. This kid had skipped the three last projects, and had to complete them before Tuesday (tomorrow) to pass the class.

I helped him for a couple hours, but it was apparent he wanted me to look over his shoulder and tell him exactly what to do. I finally took my leave, and when he IM'd me again this morning, I politely pointed out that I was supposed to tutor him, not do his projects for them.

This morning:

Him: "Are you there?"

Me: "Yes. How're the projects coming?"

Him: "OK. I just need to do some of those labs I showed you."

There are three labs. Each lab takes a week to complete. They are due tomorrow.


Me: "I have an hour or two free later this afternoon, but I can't just help you code the projects. If you are stuck on a particular concept or question, I can help you with that."

Him: "Well, the problem really is that I have no idea as to where to begin with these labs. They're pretty complicated, and they're due tomorrow."

Then don't you think that ONE DAY before the semester ends is the wrong time to BEGIN them?


I feel bad for him, but I'm not going to sit down and code them for him. If I worked the next 24 hours, I could probably squeak them out myself. Helping him do them? Not a chance, even if I agreed to do it.