Jeffkillian.com initially started as a Geocities website when I was in 6th grade. Over the years, it has slowly evolved into a place where I can practice and become familiar with web development as it progresses. I started out coding with Microsoft Frontpage, then moved to Dreamweaver. Initially, there was very little coding, and it was all WYSIWYG. However, as I learned more, I could make it more interactive.


I incorporate drawings and blog posts to keep those that are interested updated. Through the evolution of the website, I was forced to learn HTML, PHP, CSS, XML, jQuery, javascript, and the handling of MySQL Databases. I've put online some code samples.
Simulating and rendering water from liquidfun.js, a box2d port
After some significant development in dangeraffe there was still one thing that really bugged me that I wasn't able to solve. Water just didn't feel right.

Rather than being a continuous liquid, it was just a series of differently sized balls. While the balls did have physics that mimicked liquid flow/properties, I couldn't stand how it looked. I had no idea even where to begin, but after a bit of googling, I was able to find a helpful page that explained the term I was looking for: Rendering.

In essence, I had the locations of all of the balls given to me by the liquidfun engine. What I wanted to do was find a way to render(display) those balls, without displaying the actual balls that were there. Instead I wanted to display something that moved and flowed like water, and looked like one coherent unit when all together.
I ended up on a blog post about Liquid Simulation in WebGL by Chris Wellons, which looked like it was right up my alley. However, it mentioned using something called WebGL, which I had never heard of at the time. From what I coudl tell, it was a way to take some stress off of the CPU when rendering, and instead use the GPU. Again, this was a foreign language to me, so I ignored it. Chris had made a bottle like simulation , and broadly detailed the steps needed to render water:
  1. Do a physics simulation of balls in a container
  2. Render the simulation onto a raster
  3. Blur the image
  4. Apply a threshold
Steps 3 and 4 were the crucial part. They were the actual solution to the question "how do you turn the balls in liquidfun/box2d into a liquid-like substance?"

While I won't get into too much detail about the actual mechanics behind rendering, (you can find more here), you must first blur the balls, and then you apply a threshold. Blurring the balls makes them appear more as one continous body. Applying the threshold allows a clear cut outline of any given water bodies. If the image is above the threshold, we paint it black (or in the case of water, blue). If it is not above the threshold, we paint it white.
While testing, you can alter the threshold to see what it would be best as. Too small, and nothign shows up because everythign is too blurred. Too big, and the threshold does not have any affect, and you get a blurred image.

Blurring and Thresholding
Now that I knew I had to use a blur and a threshold, (and because I had never worked with WebGL), my first thought was to look for a javascript library that would do this for me. My thought was, because my image is on a canvas, I can simulate all of the water balls on a seprate canvas, apply the blurring and thresholding, and then draw the image on that canvas. I looked at a bunch of different libraries, the most helpful were The problem with the libraries above is that they are all javascript based. glfx.js is actually a webgl framework, but I didn't even know enough to know that this is what I should be using, and that it was different. While I was able to get a tiny implementation running via stackblur, it required copying the red,green, and blue values for every pixel on the canvas. I had to do this every frame (the game runs at around 60 fps), and then redraw this on a new canvas. This was much too process intensive, and I was getting at maximum 5 or 6 frames per second. It was at this point that I decided to take a break, and admit defeat....or so I thought.

I developed some new features, but still couldn't get the water rendering out of my head. About three weeks later I decided to revisit the issue, and try from a fresh start. My new implementatation started as an actual copy of the bottle simulation mentioned before. I didn't know WebGL, and wasn't about to learn it. Water was important, but my time could better be used implementing other features. Therefore, I copied the entire bottle simulation repository, and pasted it into my directory. I then worked backwards, figuring out the coordinates relative to my coordinates, deleting the spikes on the sides, and so on. Eventually, I had a bottle simulation that was running over dangeraffe. The canvases were overlaid, with the bottle simulation being above dangeraffe.

I was able to transfer my points via an array to the bottle simulation, but the simulation kept crashing. This was a result of it having a memory leak from using an outdated version of box2d. I spent a while porting the included box2d into liquidfun.js (aka B.Vec2>b2Vec2, B.World>b2World...). I was relying on this fixing the memory leak, and it did.

The last step was to map the water points that I currently had in dangeraffe into points that were appropriate for the bottle simulation. This was the part that took the longest, as it turns out the y axes are inverted and the bottle simulation goes from -1 to 1 on both axes. Once I had a function that could map my points to the bottle canvas, it was just a matter of calling the render function from my source dangeraffe code, and we ended up with beautiful flowing water. It's not the prettiest implementation, but I'm not exactly going for coding points. Dangeraffe is for me, as much of a coding learning tool as it is a game, so the fact that the code is not pristine for the rendering is just fine by me :).
Adding A Custom Notification/Ringtone Sound to your Galaxy S6

Making the custom file available

1. Open the†My Files†application†(The default file manager on Samsung devices). By default this is in the tools folder.
2. Under Local Storage, open the†Device Storage†option
3. Browse to the audio file, long press on it, tap MORE in the upper right, and select the†Copy†option
4. On the new screen that appears, under Local Storage, open the†Device Storage†option

5. Under Device Storage, find the†"Notifications"†folder (or Ringtones folder if you are adding a ringtone), open it, and tap PASTE HERE


Selecting it
6. Open up your phone's Settings
7. Under Device select Sounds and Notifications

8. Select Ringtones and Sounds

9. Tap either†Ringtone or Default Notification Sound, depending on what you are changing

10. On the opened list, select your audio file to activate it.

Box2d/LiquidFun b2EdgeShape
In implementing the paintbrush in dangeraffe I found an interesting aspect of b2Edgeshapes: they cannot collide with each other.

My setup for the brush is to continually draw a line from the last point where the mouse was to the current point. Whenever the current point changes, draw a line between the last and current point, and then update the last point to be the current point.

Each of these lines is a b2EdgeShape, and I'd then attach them to a body and things would work. However, I didn't anticipate that b2EdgeShapes can't collide with each other. It also seems like they have some weird properties that are not ideal for creating proper collisions. Though not ideal, rather than drawing a line in box2d it would make more sense to draw a very short/long rectangle. The only tricky part about this is rotating the rectangle correctly.

Below is the commented code for drawing a rectangle from a previous point (this.lastbrushPos) to the current point (currPos):
Drawing.prototype.addBrushStroke = function(point) {
    var color = "#000000"; //make the brushstroke black

    //currPos and this.lastbrushpoint are points relative to the center point of the body
    var currPos = new b2Vec2(point.x - this.start.x, point.y - this.start.y); //Make it relative to where you start

    //the length of the line is the distance between the points
    var width = Point.distance(currPos, this.lastBrushPos);

    if (width < .5) return; //For optimization, only draw lines when it is greater than .5 

    //Drawing a body requires knowing where it's center will be. This midpoint is the center.
    var midPoint = getMidpoint(currPos, this.lastBrushPos);

    //We will rotate around the midpoint to a certain angle.
    var angle = getAngleBetweenPoints(currPos, this.lastBrushPos);

    //Initialize the brushStrokeProperties
    var brushStrokeProps = {
        color: color,
        desc: "brushStroke",
        extDesc: "Custom Object",
        width: width,
        height: .25,
        density: 8,
        angle: angle,
        classID: 1,
        canTrash: 1,
        offSet: midPoint
    };
    //Create the fixture definition
    var brushStrokeFixDef = createFixtureDef(brushStrokeProps);

    //Add the fixture to the body
    addFixtureToBody(brushStrokeFixDef, this.drawing);

    //Update the old position to be the new position.
    this.lastBrushPos = currPos;
    return;
};
The initialization of brushStrokeProps, createFixtureDef, and addFixtureToBody is code specific to me. They allow creation of bodies and fixtures to be a lot easier in the long run. They can be found in BodyGen.js.

getAngleBetweenPoints does exactly what it states-it gets the angle between two points. Keep in mind, this works for my coordinate system which has Y increasing as we get lower on the screen.
function getAngleBetweenPoints(p1,p2){
    var newPoint=new Point(p1.x-p2.x,p1.y-p2.y);
    var pointAngle = Math.atan2(newPoint.y, newPoint.x);//get the point angle
    return pointAngle;
}
Where to Buy Chance The Rapper's Acid Rap On Vinyl (and other info)
Below youíll find the information I found when I was looking to get Chance the Rapperís Acid Rap on vinyl. Iím writing this to spare others the same research I did, and to get the information all into one place.

To set things straight, there is not an official release of "Acid Rap" on vinyl. The only official release of "Acid Rap" has been via download online. There was a bootleg CD that came about, and actually managed to make it into the billboard top 100 but the CD has since been discontinued.

Pressing
The reason you canít find an official release (and probably wonít in the future) is because the album features some samples that were never cleared. Despite this, vinyl-digital decided to press the album in 2014, limiting the pressing to 1000 hand-numbered copies (original sale page, obviously out of stock). Vinyl Digital pressed in three different colors:
Despite pressing the same amount of yellow and pink records, the pink is more sought after as it matches the art of the sleeve. The album cover features art from chance the rapper's official mixtape, and has the tracklisting for the two double-sided LPs on the back:
Though I'm not an audiophile, the quality of the sound on the record I received was very good. I cannot hear a quality difference between this bootleg and other officially pressed records that I have. From various sources online, the quality of vinyl-digital bootlegs is excellent.

Where to get it
Vinyl digital has not stated they intend to make more pressings, so you could try them first, but the odds are they will still be sold out. There have also been a few floating around on eBay, but the most reliable place to get it is via discogs.com. If you don't care about the color, the clear albums were going for around $30 a few months after it was released, but have been steadily climbing in price (currently, the cheapest is around $50+shipping). The starting price for pink is around $228+shipping.


More Images


Thanks to user Billobatch on reddit for some images
Conclusion to the Ballpit

If you didn't know, a while back I created a ballpit with my two roommates. It was exactly as we'd hoped it to be, and we had a bunch of fun playing in it and making various puns. After two years of ownership, I was moving into an apartment, and no longer had the space for it. As sad as it was, I knew I had to let it go.

I decided to post an ad on craigslist to see if anybody was interested. I was going to leave it at that, but driving to work the next day I had an idea. What if I could get the fact that a ballpit was being sold on air? Now I'd gone my whole life without ever paying for radio advertisements, and I'll be damned if I was about to break that streak. So I called in during a commercial break, and had a little chat with the hosts. I figured if I called in, maybe they'd mention it for a bit on their show. Fortunately for the ballpit, and unfortunately for me and my radio-awkwardness, they were recording the call. Once the commercials were over, they eventually played our conversation in full. Lucky me.

As it turns out, I received over 20 responses. Some just wanted more information, some just wanted to say the post was funny. I was able to sell it for $375, which gives the world the concrete fact that ballpits depreciate at a rate of $25 every two years. After it was sold, I still got emails inquiring. Many were wondering, now that it was gone, how do build their own. To make things easier so I didn't have to copy and paste the same thing to each inquiry, I made a page which helps you plan out making your ballpit. Making that page was also a good refresher in php and javascript, so it was a win for me as well.

Fast forward 9 months or so, and I see a thread on reddit for another ballpit being sold in Madison. The ad is similar enough that you can tell they based their ballpit off of mine (structure is the same, sippy cups, same dimensions, ball numbers, etc). However, I could tell it was not my baby because the ball colors were way off.

Overall, it was a great journey, and I would advise anyone who is thinking of building a ballpit to just get some balls and do it.

Flywheel Toy

I was browsing reddit and came across this flywheel toy. It's a really neat demonstration of physics. I looked online trying to find one to buy, but it looks like the guy made it himself.

1st Annual Killian Family Turkey Trot

The first annual Killian family turkey trot was this morning, and it went off without a hitch. †I was a huge success, and everyone involved had a great time. †Race results are now online, and can be viewed here.

Dangeraffe - 11/6 Update

Today, I added a few new things to Dangeraffe:

September, 2014

I've recently gotten back into learning new coding languages, and I'm trying my hand at javascript and java. I was ultimately interested in making an Android game - if only to learn the basics of how that all works - but am putting that on hold. I had an idea for a game where there is a very lovely giraffe who is a victim of his own surroundings. 

The basic premise is a sandbox with a giraffe, and you can play around with him and do various physics related things. To get the physics aspect right, I initially wanted to use jbox2d and java in order to create an applet. However, that turned out to be much more of a pain to install. I then had the idea of honing up my web skills, and making the game with javascript/HTML5/CSS. This is so far turning out to be a lot more fun. It doesn't have all the functionality that can come with Java, but it's a blast to learn and see what happens to the poor giraffe.

As of now, there's just a giraffe you can drag around a physics sandbox, and you can press any key to give him a space helmet. Take a look at it here.

Creating a Python Script to Email Pictures of Ryan Gosling Each Morning
I've a friend who's a big fan of a couple of celebrities (Ryan Gosling, Chris Hemsworth, and Silja Norendal). He'd been throwing out the idea of making a program which would email him a picture of one of them every morning.† He'd asked me how to do it and I did a bit of research and came up with a quick estimate. I knew it would be a python script, and I knew it would have to use a cron job of some sort (I'd never worked with cron jobs but had an interest in them). A cron job is a way you can program a certain file or program to run repeatedly every so often. I'd made something similar (Mara's fake twitter account) a while back, but instead of using cron, I'd just scheduled a task on my computer. The downside of this is that if my computer was not on, the program would not run. You run a cron job on a server (which I have for this website), and by using a cron job I would be able to have it run regardless of whether or not my personal PC was on.

I was sitting at a bar with this friend, and after a few drinks he started asking questions like "how many hours would it take" and "what would you charge per hour". We threw the estimate around and it ended up being $120 to get this done completely. We shook on it right there, with five witnesses. However, I knew this friend was always up for a bet, so I offered him the chance to double or nothing it, meaning I'd either do it for free or he'd pay me $240 to do it. He accepted. We flipped a coin, and, as he often does, he came out on top and I did it for free. To be honest I'm glad that happened, as I would have felt bad accepting $240 for this. Plus, I tend to put a lot more effort into something if I'm doing it for myself rather than doing it for somebody else. Because this was now just on me, I was much more inclined to take a bit of extra time and make sure it's solid. The following is a breakdown of what I did, and how I got it working.

Automatically Sending an Email with a Python Script Using a CronJob:

I broke it down into the following parts
Pull a random image of one of the celebrities:
This one was a bit easy. Initially we were envisioning it would be a random image pulled off of google images every day. However, we settled that we could have 20 images of each person (60 total). Therefore, he'd start seeing repeats on day 61. This made it a lot easier to code, and still has enough variation that he'd not get bored. I found 20 pictures of each celebrity online, and saved them to my server, labelling them accordingly (ryan_1, ryan_2, etc) so that it would be easy to programmatically retrieve the names.
I retrieved the names using the following lines in python:

dayOfYear = datetime.now().timetuple().tm_yday #which day of the year it is:0-364
prefixes = ['silje','ryan','chris'] #all files are named silje_2,ryan_5,chris_1, ranging from 0-19.
prefix=prefixes[dayOfYear%3] #get the day of the year, mod 3. This will give us a number which indicates whether we show silje, ryan, or chris today
picToUse=((dayOfYear)/3)%20 #get which picture we want (0-19). Divide by three because this rounds down if it's not a whole number.
filename=prefix+"_"+str(picToUse)+'.jpg' #create the filename "aka silje_4.jpg"

Send an email:
I had done this before with Mara's twitter program, so it was possible, and not that difficult. However, I ended up using something completely different, as somebody had already done a lot of the hard work (see website link in next section). I was able to create a new gmail account just for this which I use to send the emails.

Attach the image so that it would appear in the body of the email:
My first instinct was to use straight html to just display the image using an tab. However, this resulted in an†emailing containing the html tag (instead of the image). A google search lead me to this website, which had the basics for embedding an image in an email with python. I did a copy/paste and modified what I needed to, and had that solved.

Schedule a server to run this python script using a cron job:
This was the most frustrating part (though it shouldn't have been). I decided that I'd send it at 4:30am Monday-Friday. †Even after googling, there were †a couple of syntax issues that prevented me from getting the python script to work. Eventually I got the following to work:
30 2† * * 1-5 /usr/bin/python /path/from/home/to/my/script.py†To explain the cron settings in detail, you can check out this helpful page.
30: This will run 30 minutes past every hour it is specified to run.
2: This should only run on hour 2 (2am) of every day specified. Though I wanted the email to send at 4:30 am (after he went to bed but before he woke up), I realized the server exists in a different timezone than I do; 2AM there is 4AM here.
1-5: Run on the first through fifth day of each week (M-F)
I then had to specify the path to the program that should run the script, and the path to the script.

I added in a couple more additions. Mainly, I made a giant list of different possible subjects for the email, and select one at random each day as a little bonus.
That's about it. Each M-F he now gets an email. He's also mentioned it to some others, who requested to get the emails as well. As of now there are 7 or 8 people getting emails.

It was a a fun project, and a neat way to learn about cron jobs. The source python file I created can be found here.
Want more? Check the blog archives
Untitled Document