Posts Tagged ‘ Writing ’

How to shoot yourself in the foot in any programming language

Searching through the documents on my hard drive this weekend I came across a document containing the joke of how to shoot yourself in the foot in any programming language. Well, not literally, but it does relate how the different languages behave by using the analogy of shooting one’s self in the foot. I forgot where I found this so if someone knows, post the link in the comments!

* * *

How to Shoot Yourself in the Foot in Any Programming Language

The proliferation of modern programming languages (all of which seem to have stolen countless features from one another) sometimes makes it difficult to remember what language you’re currently using. This guide is offered as a public service to help programmers who find themselves in such dilemmas.

You shoot yourself in the foot.

You accidentally create a dozen clones of yourself and shoot them all in the foot. Providing emergency medical assistance is impossible since you can’t tell which are bitwise copies and which are just pointing at others and saying, “That’s me, over there.”

After importing java.awt.right.foot.* and java.awt.gun.right.hand.*, and writing the classes and methods of those classes needed, you’ve forgotten what the hell you’re doing.

Your foot is ready to be shot in roughly five minutes, but you just can’t find anywhere to shoot it.

You shoot yourself in the foot with a gun made with pieces from 300 other guns.

Find a gun, it falls apart. Put it back together, it falls apart again. You try using the .GUN Framework, it falls apart. You stab yourself in the foot instead.

SELECT @ammo:=bullet FROM gun WHERE trigger = ‘PULLED’;
INSERT INTO leg (foot) VALUES (@ammo);

You shoot yourself in the foot, but nobody can understand how you did it. Six months later, neither can you.

You’ve perfected a robust, rich user experience for shooting yourself in the foot. You then find that bullets are disabled on your gun.

You shoot your right foot with one hand, then switch hands to shoot your left foot but you realize that the gun has turned into a banana.

You shoot yourself in each toe, iteratively, until you run out of toes, then you read in the next foot and repeat. If you run out of bullets, you continue anyway because you have no exception-handling ability.

After realizing that you can’t actually accomplish anything in this language, you shoot yourself in the head.

Using a COLT 45 HANDGUN, AIM gun at LEG.FOOT, THEN place ARM.HAND.FINGER. on HANDGUN.TRIGGER and SQUEEZE. THEN return HANDGUN to HOLSTER. CHECK whether shoelace needs to be retied.

You shoot yourself in the appendage which holds the gun with which
you shoot yourself in the appendage which holds the gun with which
you shoot yourself in the appendage which holds the gun with which
you shoot yourself in the appendage which holds the gun with which
you shoot yourself in the appendage which holds ….

Shoot yourself in the foot with a water pistol. On big systems, continue until entire lower body is waterlogged.

Foot in yourself shoot.

You shoot yourself in the foot, then spend all day figuring out how to do it in fewer characters.

The compiler won’t let you shoot yourself in the foot.

If you succeed, shoot yourself in the left foot.
If you fail, shoot yourself in the right foot.

Concurrent Euclid
You shoot yourself in somebody else’s foot.

Put the first bullet of the gun into the foot of the left leg of you.
Answer the result.

You spend days writing a UIL description of your foot, the trajectory, the bullet, and the intricate scrollwork on the ivory handles of the gun. When you finally get around to pulling the trigger, the gun jams.

% ls
foot.c foot.h foot.o toe.c toe.o
% rm * .o
rm: .o: No such file or directory
% ls

Not only can you shoot yourself in the foot, your users can too.

You’ll be able to shoot yourself in the foot just as soon as you figure out what all these bullets are for.

Visual Basic
You’ll shoot yourself in the foot, but you’ll have so much fun doing it that you won’t care.

You tell your program you want to be shot in the foot. The program figures out how to do it, but the syntax doesn’t allow it to explain.

After correctly packaging your foot, you attempt to concurrently load the gun, pull the trigger, scream and shoot yourself in the foot. When you try, however, you discover that your foot is of the wrong type.

You try to shoot yourself in the foot only to discover you must first reinvent the gun, the bullet, and your foot. After that’s done, you pull the trigger, the gun beeps several times, then crashes.

370 JCL
You send your foot down to MIS with a 4000-page document explaining how you want it to be shot. Three years later, your foot comes back deep-fried.

You try to shoot yourself in the foot but you just keep hitting the whitespace between your toes.

Navigational keyboard shortcuts

Here’s another bite-sized post. Let’s discuss some convenient, but not commonly known navigational keyboard shortcuts that works in most GUI text editors and web text boxes:

Home Move cursor to beginning of line
(Some code editors will move to first non-white space and hitting Home again can put it to position zero before the white spaces)
End Move cursor to end of line
(in some editors, it’ll also count whitespace at the end as a character)
CTRL+Home Moves cursor to the first position at the top of page (row 0, column 0)
CTRL+End Moves cursor to after the last character at the bottom of page
CTRL+Left Arrow Moves cursor to before last word (before white space)
CTRL+Right Arrow Moves cursor to after current word (after white space)

In addition to the above keys, if you hold down SHIFT with the above key combos, it’ll highlight from the current cursor position to wherever the key combo specifies. For example, pressing SHIFT+Home will highlight from the current position to the beginning of the line. You can get crazy with the keys like pressing Home and then SHIFT+End to highlight the entire line. Use these shortcuts to impress the ladies with your proficient typing skills. 😉

Writing and Deleting on the SD card, simplified

This should be something easy and intuitive. The internet makes this not so. Here you go, functions for writing and deleting on the SD card. Copy and paste these right into your program. Do you want to clutter up your users SD card with unnecessary files? Do you want to delete all files on your users SD cards? Do so to your hearts content! (Please don’t though, its messed up.)

// Saving a file to the SD card
public void writeFile(String filename, String data){
try {
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
// This stores the file on the SD card
File locDataForMachines = new File(root, filename + ".txt");
FileWriter machineWriter = new FileWriter(locDataForMachines, true);
BufferedWriter machineOut = new BufferedWriter(machineWriter);
} catch (Exception e) {
// Do whatever you gotta do, maybe use some other exceptions too
// Deleting a file from the SD card, probably used in conjunction with the function above
public void deleteSDFile(String filename){
File deleteMatchingFiles = new File("/sdcard");
if (deleteMatchingFiles != null){
File[] filenames = deleteMatchingFiles.listFiles();
for (File tmpf : filenames){
if (tmpf.getName().startsWith(filename)){ // can change starts with to anything you want to compare with
}catch(Exception e){
// Do whatever you gotta do, maybe use some other exceptions too

Also, add this to your manifest. I hate how people never remind you what to add to the manifest. Its like they want you to fail.

<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”>

Post below and let me know how bad you think this implementation is, or let me know how it helped you. Thanks!