Arkansas Reciprocity Map

Written by Daniel Veazey on July 23rd, 2010

Creative Commons is a neat thing. I wanted to make a map of states that have concealed carry reciprocity with Arkansas, but I didn’t want to draw the map myself. So I started looking for a map in .SVG format so I could edit it in Inkscape. I found this map on Wikipedia:

http://en.wikipedia.org/wiki/File:Map_of_USA_with_state_names.svg

Then all I had to do was recolor it to fit my needs. I also added a color key and a title. Here is the end result:

 

Using keyframes in Kdenlive

Written by Daniel Veazey on June 27th, 2010

Kid asked me how to use keyframes in Kdenlive. Keyframes are a good way to move things around on the screen in a video. They can also be used for some other things, but for now we’ll just stick to using them to create movement.

The first thing we want to do is add the Composite transition to whatever clip we want to move around. Your clip could be a piece of video, or a picture, or a .png file with titles that you want to scroll across the screen. Drag the clip from the project tree to the timeline and then right-click on the clip. Click on Add Transition -> Composite.

A new thing should appear that looks kind of like a clip overlapping your clip. Click on it and drag the ends to match up with your clip. They should snap into place. Above the timeline on the left should be three tabs: Project Tree, Effect Stack, and Transition. If you’re not already on it, click on the Transition tab. The red rectangle in the dark area represents where on the screen your video appears. Right now it’s centered and covering the whole screen. Just below that is another timeline of sorts. On the left end of the timeline you should see a red triangle pointing down and a black triangle pointing up. The red triangle marks where a keyframe is. Kdenlive always puts a keyframe at the beginning of the clip for you.

To add another keyframe, drag the black triangle to the point on the timeline where you want to add it, and click the Add Keyframe button. It’s the fourth one from the left, just below the timeline.

So with keyframes, it basically tells Kdenlive where you want the video to be at a certain points. Kdenlive takes that information and moves the video between the two points over the course of the timeline between keyframes. For example, let’s say we wanted the video to move off the bottom right corner of the screen. We’ll just drag the red rectangle down and to the right while the black triangle is lined up with our keyframe. You’ll see in the project monitor on the right that the video has moved the same as the red triangle on the Transition tab. Also, Kdenlive draws a red line representing the path that the video will follow between the two keyframes.

Now we can add another keyframe farther along the timeline and move the video in a different direction. Just move the black arrow to the new point, click Add Keyframe, and drag the video to the new spot on the timeline. The video in the project monitor moves accordingly, and Kdenlive draws another red line showing where the video will move across the screen.

If you make a mistake while editing keyframes, don’t press Ctrl-Z, because Kdenlive will remove all the keyframe edits you have made since adding the composite transition. To get rid of a keyframe, you can move the black triangle to line up with the one you don’t want and click the Delete Keyframe button.

Now if you want to make titles scroll across the screen, all you have to do is create the titles using Inkscape. Make sure they have a transparent background and export them as a .png file in Inkscape. Import that file as a clip in Kdenlive. Right-click on it in the Project Tree and click on Clip Properties. Make sure the transparent background box is checked. Then drag the titles clip to the timeline. It should already have a Composite transition attached to it, but if it doesn’t, just add it with the method shown above. Drag the end of the clip to make it as long as you want it to be. On the transition tab, click the first button on the left below the timeline and resize the clip to its original size. Then position the red rectangle to where the top of the clip is below the screen. You can click on the first button below the timeline and align it to center horizontally. Move the black triangle to the end of the clip and add a new keyframe. Drag the red rectangle so the bottom is above the top of the screen. Align it to center horizontally again, so the titles will scroll straight up and down.

 

World Cup at Smoke & Barrell

Written by Daniel Veazey on June 23rd, 2010

I took my camera to Smoke & Barrel in Fayetteville to take pictures of people watching USA vs. Algeria in the World Cup. Here are some of the pictures I took.

 

The linux-minidisc project

Written by Daniel Veazey on June 14th, 2010

With Sony being the proprietary fools that they are, I have explained how to set up VirtualBox on your Linux OS so you can run Windows, so you can access files on your Sony MiniDisc Walkman. Now I am going to tell you about another, more attractive solution: The linux-minidisc project. From their website:

Welcome to the linux-minidisc Wiki, dedicated to collecting as much information as possible regarding NetMD/HiMD hardware in order to get it to work on Linux, MacOS X and *BSD.

The linux-minidisc project offers an open-source software package called QHiMDTransfer. It has an interface similar to SonicStage, without all the bloating that SonicStage has. Here is a screenshot:

Screenshot of QHiMDTransfer

It is still a work in progress, but it is exciting to see what Adrian Glaubitz and others have accomplished so far. There are several ways to get involved with the project. Just check out their list of tasks.

 

The bike saga continues

Written by Daniel Veazey on June 9th, 2010

I now know that the combination to my bike lock does not contain both a 1 and a 4. I thought it did, but none of the 302 combinations from my previous program worked. But I haven’t given up hope. Another thing that I seemed to remember was that it had double digits in it somewhere, like 1123 or 4425 or something like that. So I wrote another program to list those combinations. But I didn’t want to list anything that I’ve already tried, so I got a little bit fancier with this program. Also, I put annotated comments in this program. It’s always a good idea to annotate your programs, especially if you’re going to show them to someone else. It makes it easier for the person reading it to understand why you’ve added a particular bit of code. And if you later forget why you wrote a program a certain way, your comments will help you remember. Python ignores anything on a line after a # character, so that is the method for writing comments in your programs. Let’s take a look:

master = [] #create a list of combinations i've already tried in a previous program
for a in range (0, 6):
    for b in range (0, 6):
        for c in range (0, 6):
            for d in range (0, 6):
                combo = str(a+1) + str(b+1) + str(c+1) + str(d+1)
                if "1" in combo and "4" in combo:
                    master.append(combo) #add combinations with both a 1 and a 4 to the master list
possible = 0 #to keep track of the total number of possible combinations that meet the previously mentioned criteria
combo_two = "0000" #to set up a way to prevent counting "double doubles" twice
for a in range (0, 6):
    for b in range (0, 6):
        for c in range (0, 6):
	    for d in range (0, 6):
                combo = str(a+1) + str(b+1) + str(c+1) + str(d+1) #make a string from the values of whichever cycle all four loops are on
                if combo in master: #check to see if this combo has already been tried and added to the master list
                    break
                else:
                    for check in range (0, 3): #set up a loop to compare adjacent digits in combo
                        if combo_two != combo: #only performs the check if this combo hasn't already been counted
                            first = combo[check] #find one digit of combo to compare
                            second = combo[check+1] #find the following digit of combo to compare
                            if first == second:
                                print combo
                                combo_two = combo #this combo has been counted, so combo_two stops it from being checked again
                                possible = possible + 1
print "There are", possible, "possible combinations that have adjacent double digits, but do not contain both a 1 and a 4."
How it works

The first part of the program is very similar to our previous program, combos2.py. But instead of printing out those combinations, we’re adding them to a list called “master.” We first create the empty list with master = []. The brackets are what tell Python we want it to be a list. Then we go through our familiar loops for each digit in the combination. But instead of printing the combinations, we use master.append(combo). Append adds whatever is in the parentheses to our master list. Once it goes through all the loops, we move on to part 2 of the program.

Last time, we counted possible combinations with the variable x. This time, we’re going to be a little more descriptive and name the it “possible.” Being descriptive is another way to make your programs easier to read. We also make a string called combo_two, which we’ll use later to keep the program from counting the same combination more than once.

So we go through the loops again. Each time through, we check to see if combo is already in the master list. If it is, we tell Python to break that loop. Break will interrupt the smallest loop that the program is in at that particular moment. But if the combo we’re working on is not on the master list, then we can go on to the next instructions.

We make a for loop called “check.” Here is where combo_two comes into play. If it is not equal to combo (!= means not equal to), then we do the stuff on the next few lines. But if combo_two is equal to combo, i.e., not meeting the condition of the if statement, then Python skips over the next few lines and goes on back to do another cycle through the four loops that give us a new combo.

Strings

You can reference parts of strings by referring to them like this: Say the string called combo has “2452″ assigned to it. We can find the second character of that string by typing combo[1]. Remember, almost everything in Python begins with position 0, so position 1 is actually the second character in the string. So typing combo[1] would return the character “4.” Typing combo[0] would return “2,” combo[2] would return “5″ and combo[3] would return “2.”

Let’s assume we met the condition of the if statement, meaning that combo_two was not equal to combo. The “check” loop goes from 0 to 3. We’re going to use this loop to compare two adjacent characters in combo. We assign one character of combo to the string “first” by saying first = combo[check]. What’s in the brackets is the position of the string that we want to reference. On the first cycle through the check loop, check has a value of 0, so it’s like saying first = combo[0]. Then we assign the next character in combo to the string called “second” with second = combo[check+1]. So now the string “first” has the one character from the string “combo,” and the string “second” has the following character from combo.

The next line compares first to second. If they’re equal, we print out the combo and add one to the value of possible. Then we make combo_two equal to combo, so when Python goes back around to the next cycle of the check loop, it knows to not perform the checks on the same combo and produce duplicate results. But if the first and second string were not equal, then Python doesn’t print the combo, doesn’t assign combo_two the same value as combo, and repeats the check loop on the next two digits in combo.

So cycle 0 of the check loop compares the first and second digits of combo. Cycle 1 compares the second and third digits, and cycle 2 compares the third and fourth digits. Once it reaches cycle 3, the loop stops because the ending value of a loop is excluded.

Finally, once we have found all the combos that have double digits, but do not contain both a 1 and a 4, we tell Python to print a total to satisfy our curiosity.

 

Working on the bike problem with Python

Written by Daniel Veazey on June 8th, 2010

My bike is still chained to the rail on my balcony. If you recall, I said previously that I believed the combination to the lock had a 1 and a 4 in it. The program I wrote gave a list of all the possible combinations, and it turned out there were 1,296 possibilities. That’s a lot of numbers to fiddle around with on a combination lock. So I figured I should write a new program, this time only showing combinations that had both a 1 and a 4 in them. Surely that would cut out a lot of unnecessary combos, right? I got to work, and here is what I came up with:

x = 0
for a in range (0, 6):
    for b in range (0, 6):
        for c in range (0, 6):
            for d in range (0, 6):
                combo = str(a+1) + str(b+1) + str(c+1) + str(d+1)
                if "1" in combo and "4" in combo:
                    print combo
                    x = x + 1
print "There are", x, "combinations that contain both a 1 and a 4."
How it works

We start off by assigning the value 0 to the variable x, which will keep count of the number of combos with both a 1 and a 4 in them. We make four loops, a, b, c and d, to create all the different possible combinations. inside the fourth loop, we make a string called combo and put the string representations of the variables a, b, c and d in it. Then we look to see if the string combo has both “1″ and “4″ in it. If it does, we print combo and add 1 to the value of x. Once the program runs through all its loops, we have the program tell us how many combinations contain both a 1 and a 4. There are 302 of them. That’s a lot less than 1296, and it seems manageable.

Why the loops go from 0 to 6

When setting up a loop in Python, the number you want to start with is inclusive and the number you want to end with is exclusive. So with the first loop, a, it starts by assigning the value 0 to the variable a for that particular cycle of the loop, and then goes on to perform all the other instructions inside that loop. It continues to cycle through the loop until the value of the variable reaches 6. Once the value reaches 6, it does not go through the loop again. So the loop gets cycled through six times: 0, 1, 2, 3, 4 and 5. But the possible digits in the combination are 1 through 6, not 0 through 5, so when we are defining the string combo, we say it is str(a+1), etc., instead of str(a) to get a meaningful answer.

So why not just make the loop go from 1 to 7? We could do that, and it would work perfectly fine. But there is a reason I start with 0. Everything in lists and strings and other things in Python start with the value 0. For example, the string combo has four characters in it. Python refers to the position of each character as 0, 1, 2 and 3, not 1, 2, 3 and 4. So I usually make my loops start with 0 instead of 1, just so I keep myself in the mindset of everything beginning with 0 in Python. If I ever write anything more complicated with lots of variables and lists and strings and references to positions within strings and lists, it will help prevent confusion because I stay consistent with starting everything at 0.

Now, I have a list of 302 combinations I need to try to get my bike unlocked. I need to get busy.

 

Tanyard Creek

Written by Daniel Veazey on June 7th, 2010

Here are some pictures from Tanyard Creek in Bella Vista, Arkansas.

 

Photo Roundup: Elk Edition

Written by Daniel Veazey on May 27th, 2010

I got up at 4:30 this morning and drove out to Boxley, Arkansas, to get some sunrise pictures of elk before they moved off into the woods. I got a new 75-300mm lens, and I thought it had auto-focus, but I can’t seem to get the auto-focus to work with my Nikon D3000. Manual focus is difficult. What looks well-focused in the viewfinder turns out to not be so well-focused on the LCD after taking the shot. I don’t think this is the greatest lens, but it might be me. It’s a Tamron 672D. Maybe I’m doing something wrong with the auto-focus. I’ll have to research it further. For now, enjoy this gallery of elk. Comments are appreciated.

 

Photo roundup

Written by Daniel Veazey on May 26th, 2010

I got a few good pictures today. With the airplane I tried adapting a Photoshop technique in Gimp to give it the look of a polarizing filter. I think it turned out pretty decent. I’ll try to write a tutorial for the method soon. I was impressed with the bee that had all that bright yellow pollen all over it. I might make a print of that. The monarch butterfly wouldn’t sit still for more than a few seconds. That’s the only shot I got of it. I got the picture of the rabbit while I was waiting around for airplanes to fly over. I was standing right next to it for a long time before I realized it was there. On the red flower, I just wanted to see how it would look if I cropped out part of it. The bumble bee came out pretty sharp, so I included it too. I hope you enjoy these. Please leave a comment and let me know what you think.

 

Practical programming

Written by Daniel Veazey on May 22nd, 2010

I have a bicycle. It is currently attached to my balcony railing with a combination lock/cable. It has been there for a while. The weather is nice now and I want to go for a ride, but I have forgotten the combination to the lock. So today I was playing around with the lock, trying to remember the combination. I’m pretty sure it had a 1 and a 4 in it. The combination is four digits long, and the digits can be any number from 1 to 6. So I was thinking I might have to try new combinations one by one until I found the right one. How many combinations could there be? Well, I could do the math, 6*6*6*6 = 1296 possible combinations. But that doesn’t really illustrate to me the reality of fiddling around with that thing. “What a great opportunity to write a program,” I thought. So I wrote a Python program to show me a list of all the possible combinations. It was very simple. Here it is:

combos.py   
x = 0
for a in range (0, 6):
    for b in range (0, 6):
        for c in range (0, 6):
            for d in range (0, 6):
                print a+1, b+1, c+1, d+1
                x = x+1
print "There are",x,"possible combinations."

How it works

First we give a value of 0 to the variable x. Then we set up 4 for loops, a through d, with each successive one inside the next. We let them run from 0 to 6. Inside the fourth loop, we tell Python to print the value that each loop is on in that particular cycle. We add 1 to the value of x to keep track of how many possible combinations there are. After all the loops are executed, we print a sentence telling us what the value of x is. That’s all there is to it! Now, write a comment in the comments section.