Skip to main content

Posts

Showing posts from 2014

Crude Ruby Script to ask for a Password to use for Private git Repo

The Intro Good ole Docker. It is a powerful tool to setup your environments whether in production, dev or test. Plowing through and building a new container I discovered I had the need or want to pass an argument to the Dockerfile and let it log me into a private repo.

The Environment Variable.  Looking through the Dockerfile documentation on
the docker.io website I saw this wonderful looking thing called an environment variable. When I first looked at it I thought that meant that we could pass them in from the host cli running the docker command. I was dead wrong. The environment variable does create a variable but its only for the container's environment. So what does that mean for us. Well if you think about the reason for Docker is for an unattended setup of an environment. Now if I were going to do this completely automated then I would probably create a ssh key and copy it over using Dockerfile. This is not what I wanted. I really wanted a seperation where I didn't stor…

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.GGod is bigger than Dthe boogie manAHe is bigger than GodzillaDOr the monsters on TVGOh God is bigger than Dthe boogie manAHe is watching out for Gyou and Dme.

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.defrobot(matrix,n ,m) return0if n<0|| m<0|| n>matrix.length-1|| m>matrix.length-1return0if matrix[n][m]==1return1if 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]=0return count end Now lets say that you have the same size matrix but the Robot can only move down and left.defrobot(matrix,n ,m) return0if n<0|| m<0|| n>matrix.length-1|| m>matrix.length-1return0if matrix[n][m]==1return1if n==m && n==0 count=0 tmp=matrix tmp[n][m]=1 …

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.defget_image(filename) file =java::io::File.new(filename) returnImageIO::read(file) enddefbyte_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 equaldefcompare(img1, img2) java::util::Arrays.equals(b1, b2) end Want to download the whole script checkout Github

JRuby Image Comparison

Working on a project to validate some images and I thought this would be a good opportunity to show a simple way to compare 2 images to see if they are equal.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.event.InputEvent' java_import 'java.awt.image.BufferedImage' java_import 'javax.imageio.ImageIO' Now we need to make a function that will allow us to open an image as a bufferedImagedefget_image(filename) file =java::io::File.new(filename) returnImageIO::read(file) end Lets start figuring out if the images are the same. A good place to start is to define a function that with tell us whether the width and height are the same. If they are equal then the images could be the same.defcompare_size(img1, img2) if (img1.getWidth == img2.getWidth && img1.getHeight == img2.getHeight) returntrueelsereturnfalseendend Now we ar…

Setup Sinatra Application on Hostmonster.

Step 1 - Environment SetupMake sure that you have ruby installed on environment, and have SSH access. To your account.Step 2 - Create Ruby on Rails EnvironmentLogin to your Hostmonster C-Panel.Click Ruby on Rails icon.Fill out form with your informationStep 3 - Setup Directory LinkSSH into your account and goto where you would like the base of your app to be in. For example if you have website www.example.com and you want it hosted at www.example.com/myAppln -s ~/rails_apps/myApp ~/public_html/myApp
Step 4 - Clean up automatic Rails files.rm -Rf ~/rails_apps/myApp/* Once you have cleaned up the directory copy your sinatra files to ~/rails_apps/myAppIf you have a Gemfile this would also be a good time to run a "bundle install" while you are in the directory. If you don't get your gems loaded you will experience problems.Step 5 - Setup your .htaccess fileOpen up your .htaccess file for the myApp directory and make it look like this. Make sure that you replace the sections …

Set Git to stop tracking file

I have found the need to ignore a file with out using the .gitignore. In my case its because of a chrome driver that we using for Cucumber and Watir. The office has a standard setup with a certain repository, however on my Mac chrome likes to update. This causes an issue with versioning of the driver. So I wanted to put a new chromedriver in my repository folder but not ignore it from the repository. To do this little trick I can update the index and tell it to assume the file is unchanged.git update-index --assume-unchanged <file> If you have the need to reverse the tracking of the file.git update-index --no-assume-unchanged <file>

Git Autocomplete

Step 1Run this command to get the .git-completion.bash file downloaded to your home directory.curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
Step 2Add the following code to your .bash_profile which is located in the root of your home directory.if[ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi Now when you open up your shell you will be able to use the TAB key for your Git commands.

What Isaiah might say.

During my daily bible study I came upon Isaiah 1:1-20 and thought wow this sounds really familiar. I thought to myself... I wonder what it would sound like if Isaiah the prophet lived in the United States and saw all the things that are happening today. What would he say. This is my take. Maybe this could inspire you to take a crack at it on your own.
Ladies and Gentlemen of the United States of America please take this to your heart. The sons and daughters of current and future generations are revolting against the Lord God Most High. We have lost the common knowledge of whom we serve, and placed and idol of money, and property in His glorious place. We are the richest sinful nation in the world, and are weighed down by the luxurious appeal of corruption and iniquity of others. We have abandoned the Lord, have no regret for the sin in our hearts and have completely turned away from him. When will this rebellion end? When will we see that the pain and suffering of bad health, depr…