Skip to main content

Posts

Speedometer

Ukulele Chords

Select your Chord and Match your fingers to the diagram.

Sending and email using Telnet

Open up Telnet telnet smtp.yourdomain.com 25 If you need SSL do this instead openssl s_client -connect smtp.yourdomain.com:465 Tell the server where you are coming from. ehlo localhost Login to the server. You will need your username and password converted to Base 64. Base 64 Encode auth login 334 VXNlcm5hbWU6 username 334 UGFzc3dvcmQ6 password Now compose your email. mail from: <your_email@yourdomain.com> rcpt to: <destination@domain.com> data Type in your email .

God is bigger than the Boogie Man - Guitar Chords

This song is called "God is Bigger than the Boogie Man" which came from Veggietales and is quite the hit for the preschoolers at church. There are some more words that are said when played in the movie however for the kids at church this chorus works wonders. G God is bigger than D the boogie man A He is bigger than Godzilla D Or the monsters on TV G Oh God is bigger than D the boogie man A He is watching out for G you and D me.

Robot moving across a NxM matrix.

Lets say I have a matrix that is a 2 dimensional array of NxM elements and the Robot needs to find all the ways from the top left corner all the way to the bottom right corner. Now the Robot it self has some rules to follow on the way. The Robot can move up, down, left, right in order to get there. However the Robot may not move over the same square more than once. def robot (matrix,n ,m) return 0 if n <0 || m <0 || n > matrix . length -1 || m > matrix . length -1 return 0 if matrix [ n ][ m ] == 1 return 1 if n == m && n ==0 count =0 tmp = matrix tmp [ n ][ m ]=1 count += robot(tmp, n +1 , m) #right count += robot(tmp, n -1 , m) #left count += robot(tmp, n, m +1 ) #up count += robot(tmp, n, m -1 ) #down tmp [ n ][ m ]=0 return count end Now lets say that you have the same size matrix but the Robot can only move down and left. def robot (matrix,n ,m) return 0 if n <0 || m <0 || n > matri...

JRuby Image Comparison - Part 2

In continuation to find ways of comparing if images are equal I decided to try comparing them as byte arrays. First we need to declare some library's. We will be using JRuby for these examples. If you want to use Java this will look simular. require 'java' java_import 'java.awt.image.BufferedImage' java_import 'javax.imageio.ImageIO' java_import 'java.io.ByteArrayOutputStream' Now we need to make a function that will allow us to open an image as a bufferedImage, and a function to convert image to a byte array. def get_image (filename) file = java : :io :: File . new(filename) return ImageIO : :read (file) end def byte_array (image) os = ByteArrayOutputStream . new ImageIO : :write (image, "png" , os) return os . toByteArray() end Lastly we need a way to compare the 2 arrays to see if they are equal def compare (img1, img2) java : :util :: Arrays . equals(b1, b2) end Want to download the whole scri...