
Web Site: http://hekimian-williams.com
Posts by Cory Hekimian-Williams:
Image Chopper
April 10th, 2009While writing a vision application I needed to generate a bunch of images of a certain size. I wrote a program that takes a folder of input images, a folder for output images, and the size of images you want to generate. I figured I’d post the source and the binary in case anyone else ever needs to do some image chopping.
The program is written in C#.
You can find the program source code here: imagechoppersource.rar
You can download the program here: imagechopper.exe
LavaLamp With Submenus in WordPress
March 17th, 2009Adding Submenus with the Correct Default Menu Item
I was playing around with LavaLamp while making this website and I found that there was an annoying bug where submenus would make the sliding image scroll all the way to the left. Reading the comments on Ganeshji Marwaha’s blog I found that you could make a small change to the jquery.lavalamp.min.js file to fix it. Another problem I found was that after clicking a link in the submenu the child page would load with the sliding image going to the first menu item instead of the parent of the current page.
I’ll show the quick and easy way to fix this glitch, then later in the post I will go into some more detail about making it work with WordPress.
Getting Rid of the Slide Glitch
To fix the sliding glitch, open the jquery.lavalamp.min.js, then navigate to the line that says:
$li.not(".back").hover(function(){move(this)},noop);
Change it so that it says:
$li.not(".back").mouseover(function(){move(this)},noop);
Save this file and it should prevent the annoying glitch when you hover over sub menus.
Making it work in WordPress
This is all fine and dandy, but if you are in WordPress you have probably noticed that no matter what page you are on, the sliding image always defaults to the first menu entry. This is because the LavaLamp menu is looking for a menu item that has a class attribute of “current”, and none currently do. In WordPress you are most likely making a call to either wp_list_pages() or wp_list_categories() to display the menu items.
Wordpress tags the current page with the class attribute “current_page_item“, and the current category with the class attribute “current-cat“. You also might want to note that the parent of the current category gets the class attribute “current-cat-parent.”
If you want the image to hover behind the current page’s menu item by default, you will need to choose one of those class attributes and make the following change to the jquery.lavalamp.min.js file:
Setting the Default Menu Item
To fix the default menu item, open the jquery.lavalamp.min.js, then navigate to the line that says:
curr=$("li.current", this)[0]||
$($li[0]).addClass("current")[0];
You should replace both instances of current with the correct class attribute you are using. So if our menu was listing our static WordPress pages we would change the line to:
curr=$("li.current_page_item", this)[0]|| $($li[0]).addClass("current_page_item")[0];
If our menu is listing the categories we would change the line to say:
curr=$("li.current-cat", this)[0]|| $($li[0]).addClass("current-cat")[0];
We can even get fancier with this modification. Lets say you have a category menu with a drop down list. We can set this correctly by using the following line:
curr=($("li.current-cat", this)[0]|| $("li.current-cat-parent", this)[0])|| $($li[0]).addClass("current-cat")[0];
And lastly, the way I use it on my website I have actually merged the menu so that both my WordPress pages, and my categories are all listed. I needed to add the following line to make it behave correctly.
curr=(($("li.current-cat-parent",this)[0]||
$("li.current-cat",this)[0])||
$("li.current_page_item",this)[0])||
$($li[0]).addClass("current_page_item")[0];
This last line will set the default menu item to the current categories parent if it exists. If it doesn’t it will look for the current category’s menu item. Lastly if neither of those are found it must be on a static page so it looks for the current page’s menu item.
Feel free to leave a comment with your feedback, suggestions, or requests etc.
Some of my Origami
March 16th, 2009I decided to post a few of my pieces of origami that I have lying around the apartment. I don’t even remember why or when I made half of these.
Oh yea, Earlier today I was eating dinner with some friends and one of them asked me to make something. I didn’t have any paper handy so I asked her for a dollar bill. She had a lot of fun with her money
Sorry for the bad quality images, my phone doesn’t like taking good pictures close up.
My Take on Origami
March 16th, 2009I think I like origami for a few different reasons.
It’s unique.
How many people do you know that know origami? Unless you have found an origami club, its not likely that you know that many people who can fold anything other than a flapping bird. I had a friend that drove me home one day when I was in high school. While we were driving I folded her a little bull dog. I then graduated and didn’t see her for 2 or 3 years.Then I got back in touch with her and ended up hanging out. Guess what? My little origami bull dog was still on her dash board.
It’s cheap.
As a poor college student I know how annoying it is to have expensive hobbies (musical instruments, fancy computers). However, all origami requires is paper, and even my really stingy friend has paper in his room. In fact, I can usually use other people’s paper if I tell them I am going to make something cool out of it!
It’s cool.
I mean, I just turned a boring piece of paper into a threatening T-Rex while waiting for a friend to finish going to the bathroom! You would be amazed at how many people think my little works of origami are awesome.
It’s easy.
This one can be a lie sometimes… There are some pretty tough origami models out there. However, if you are just getting started and are making some of the simpler models it isn’t that bad. I think the hardest part is figuring out how to read the origami diagrams.
Adding A System Call To Linux (Fedora 9)
November 8th, 2008
Getting Started
The procedure to create a system call varies in different versions of Linux. I will provide a simple step by step guide on adding a system call to the Fedora 9 kernel. The version I used to write this document was Fedora 9 kernel 2.6.26 (i686). I originally wrote this while I was a TA for an undergraduate Operating Systems course at FSU.
When you add a system call you will have to recompile the Linux kernel, so you must have the Linux source tree installed on your system. Furthermore, compiling the kernel can take a good amount of time (depending on the system and kernel options to it can take hours), so give yourself time. There is a way to add system calls without recompiling the kernel using modules as a wrapper, but that is beyond the scope of this document.
Notes
When folders are described with source/ at the start of the path, it represents the highest level of the Linux source tree. You should have folders such as arch, configs, include, and init in this folder.
Creating the System Call Source
We will be creating a simple hello world system call. Create a file mysyscall.c and fill it with the following code.
#include <linux/kernel.h>
#include <linux/linkage.h>
asmlinkage long mysyscall(int i){
printk(KERN_DEBUG "Hello World! The number was %dn", i);
return(1);
}
Adding the System Call
1. Firstly, navigate to the root directory of your Linux source. Create a folder source/mysyscall. Next, inside of your newly created folder, add a source file mysyscall.c that contains all of your system call source code.
2. Next, create a make file within this directory. This make file only needs to contain one line that says what to compile.
Create source/mysyscall/Makefile (keep the capital ‘M’)
obj-y := mysyscall.o
3. Next we need to modify the kernel’s make file. This is located in the root folder of your kernel’s source. Find the line that adds a bunch of folders to the core-y variable and add the folder name that the system call source is in. (mysyscall in this example)
In source/Makefile, the line to change looks something like this:
core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
It should be changed to something like this:
core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mysyscall/
4. Now, navigate to the source/arch/x86/kernel folder. You will need to add your system call to the system call table. This is done in the file syscall_table_32.S. At the end of the file you add an entry for the new system call. Make sure to prefix your entry with “sys_”.
It should look something like this:
.long sys_mysyscall
You should notice the numbers commented out to the right of some of the entries. They tell you what number the system call is. Keep track of which number your new system call is.
5. Next navigate to the source/include/asm-x86 folder and edit unistd_32.h. Add a #define line for the new system call. Use the number that you noted in the last step.
You should add a line similar to this:
#define __NR_mysyscall 327
6. You are now ready to recompile your kernel.
Using the System Call
1. Next to use the system call we need to create a header file that exposes the new call. Create a file, mysyscall.h which will be imported into any program that wants to use the new system call.
This header file should contain the following:
#include "unistd.h"
#define __NR_mysyscall 327
long mysyscall(int i){
return syscall(__NR_mysyscall, i);
}
2. Write a program that includes your newly created header file, and then call the mysyscall (int i) function you have implemented.
Adding a Variable Shared Between a System Call and a Kernel Module
1. Using External Variables
In order to use a variable that has been declared in another file, the keyword extern must be used.
#include <linux/kernel.h>
extern int myVar;
int MyModuleFunction(){
/* Has access to myVar which is defined in a different kernel file*/
}
2. Making Variables Externally Visible
However, variables are not visible to other files by default. For a variable declared in a system call to be visible to a kernel module it must be exported. To export a variable you must use the macro EXPORT_SYMBOL. You can export functions as well using this same macro.
#include <linux/kernel.h>
int myVar;
EXPORT_SYMBOL(myVar);
static int MySystemCall(){
/* Has access to myVar */
}
Adding a system call to Linux can sometimes be a daunting task, especially the first time. I hope this document was helpful.






