Skip to content | Skip to navigation
I've been thinking alot lately and just realized that there is a truely magical thing in this life that I had not fully comprehended until now. That is music and it's glorious properties... It has the power to heal, change mood, battle depression, conquer inhabitions and lighten life.
Music paints the soundtrack of our life, it can be a mechanism to describe our mood, our personality, our goals, our loves, our lives, our misfortunes and our successes. Music is powerful, emotional, unequalled and unparalled by most aspects of humanism with exception to religion.
Music is deeply part of my life and cannot be separated for if it was I'd fall into deep depression and dispair. I have different music for different moods, I have music to lift me up and music to exercise my frustration. I have music to pull out emotions that I have buried inside, I have music that relaxes me and I also have music that takes me from this material world and lets me escape into a religious sanctum. I have music for when I'm happy and for when I'm sad. I have music that puts me in a frame of mind suitable for doing things that I am nervous and apprehensive to do.
Music is a drug that helps me get through this hard and frustrating life. Music is a habit, an obsession and something I am not scared to say is an important part of my life. I shudder to think of what I'd become without the joy and incomprehensible beauty of music.
If only we could live in a moment and stay there eternally and never leave and never stray. Life would be perfect, never pain, never hurt and never depression of any kind.
I'd live in April 2004 with the white sands, rolling waves and immense feeling of family and communion that ensued with my vacation to Hawaii... If life was ever perfect and family ever functional it was then, it was now, it was like nothing you can ever dream of... The sand, the air, the sky, the water and the relationships were perfect, we were invincible, inpenetrable and that feeling will forever last inside a place I've come to love inside my heart.
The pictures, the laughs, the smiles and the people will never escape a sacred dwelling inside my mind. I know this place like I've known nothing else in my life, I can distinguish it by smell, touch, sight and instinct... it's like a piece of music that we can't shake out of our minds, it's that song in the morning that we sing but cannot figure out why we are doing so. It's that fragrance that reminds us of something we love, something we know and something we've been after for oh so long.
Life is unmistakibly forgiving, loving and providing. It's our job to figure out the how and when... When we do we must never let go, no matter the odds, the hardships or the distractions. Find your moment, find that place, that song, that fragrance that reminds you of why you are here and why you keep forging alone... Take life by the hand and lead it to where you want to go and make every possibility limitless!
After all it's your moment, live in it!
Even after all the bitching and complaining it turns out that the wait was truly worth it. I finally did land that *killer* job doing exactly what I want to be doing and doing it for exactly the people I want to be doing it for. The pay is excellent and the change of scenery will be varied. I'll end up traveling around the world as if I am somebody important with something needing done. It's going to be a wild ride!
The work will be in network administration. Looks like at some point in the future I'll finally get to admin some Linux servers as the project that I'll be working on moves towards Linux with Oracle.
I've been messing with Ruby on Rails for a little while now trying to see if I can finally get something done on my website plans. I am a terrible procrastinator and when things get challenging I usually start dragging my feet. So the wheels have been spinning lately and I've been so preoccupied with other crap that I could barely focus on what I've been wanting to do with my website for GOD knows how long. Literally years, but I digress.
I've been trying to plan out a website for a long time and one aspect of the website will have anonymous posting. I wanted to add anonymous posting because it's extremely quick to add thoughts to a particular blurb/blog/headline/whatever. Normally websites just add a form to the end of the page being shown and you fill in a little bit of information and click the submit button and your thoughts are added to the page. While this is great the spam bots will find you sooner or later and start filling your pages up with Free Texas Holdem links. So the new thing website admins are doing to combat this is by adding an image embedded with a random code that you also have to enter before you can submit a form. This type of security test is known as CAPTCHA (defined below) and is something that has sparked my interest of late. Today I wrote up some code to demonstrate this and I hope that maybe somebody can find it useful (besides me).
The following represents a CAPTCHA "completely automated public Turing test to tell computers and humans apart" test. What you see is an image with an embedded code. This code can be used to validate a form has been submitted by a human and not a spam bot. The code in plain text represents the embedded code taken from a session variable.
This documents the code I used to generate this test. I'm hoping this can be used by others if they are getting into web development with Ruby on Rails. The actual image creation is done with GD which is available for a number of scripting languages and it can easily be applied to those as the API is pretty consistant.
|
Image |
Plain Text |
|---|---|
|
|
3897 |
-- Oops -- Seems I updated my tutorial and I didn't think about the image I had posted here. The image doesn't correspond to the code below anymore. Silly me. I've updated it to make it more sophisticated. The tutorial can be found here
The code below is the ApplicationController of a test Rails app.
class ApplicationController < ActionController::Base
require 'MyCodeImage'
def index
ci = MyCodeImage.new
ci.generate 6
@session['captchaFilename'] = ci.captchaFilename
@session['captchaCode'] = ci.captchaCode
render("captcha")
end
end
The following sample HTML illustrates how you'd insert the CAPTCHA image into your page.
<html>
<title>CAPTCHA Test</title>
<body>
<img src="images/captcha/<%= @session['captchaFilename'] %>">
</body>
</html>
The following code is of the MyImageCode class which creates the CAPTCHA image using the GD library and a small password generator class. This class creates an image with a random name. The image file name can be accessed by captchaFilename and the plain text code can be accessed by captchaCode. The files are saved in public/images/captcha and will be automatically deleted after they reach an age of 60 seconds. As far as I can tell letting them live that long should not cause any problems. If you have a suggestion about the image files and how they are handled please let me know.
class MyCodeImage
require 'GD'
require 'PasswordGenerator'
attr_reader :captchaFilename, :captchaCode
def initialize
if ! FileTest.directory?("public/images/captcha") then
Dir.mkdir("public/images/captcha")
end
end
def generate length
deleteOldCaptchaFiles
# create a new image
im = GD::Image.new((length*9)+5, 25)
# allocate some colors
black = im.colorAllocate(0,0,0)
white = im.colorAllocate(255,255,255)
code = PasswordGenerator.new
code.gen length
codeword = code.password
im.string(GD::Font::GiantFont, 3, 5, codeword, white)
filename = rand 99999
imgFile = File.new("public/images/captcha/#{filename}.png", "w")
im.png imgFile
imgFile.close
im.destroy
@captchaFilename = filename.to_s + ".png"
@captchaCode = codeword
end
private
def deleteOldCaptchaFiles
captchaDir = "public/images/captcha/"
Dir.open(captchaDir) do |dir|
dir.each do |file|
unless (file=="." or file=="..") then
# The CAPTCHA image will live for 60 seconds before it's deleted
if Time.now.to_i - File.mtime(captchaDir + file).to_i > 60 then
File.delete(captchaDir + file)
end
end
end
end
end
end
The last piece of code is the code generator for which I'm using a simple password generator class.
class PasswordGenerator
require 'digest/md5'
attr_reader :password
def initialize
@password="";
chars="abcdefghijklmnopqrstuvwxyz"
num="1234567890"
spec='!@#$%^&*()-+=~'
lower = chars.split('')
upper = chars.upcase.split('')
number = num.split('')
special = spec.split('')
@tokens = [lower, upper, number, special]
end
def gen length
@password = ""
length.times do
type = rand @tokens.length
seed = rand(@tokens[type].length-1)
@password << @tokens[type][seed]
end
end
def md5
Digest::MD5.hexdigest(@password)
end
end
The actual image creation could be more sophisticated to make it extremely difficult or impossible for OCR software to decode. The point is that for most uses of this software spammers would not waste their time to try to spam your site. This is exactly what we want! What I did here was demonstrate that it's pretty easy to add this stuff to your website. I am new to Ruby (a little over 1 week) so the code I've written is probably less than optimal. If you see any areas for improvement please let me know.
This post was edited by majic on May 15, 2005.
"I like sally but I'm going out with heather who is her best friend and sally is dating my best friend steve and well I want sally so bad but I don't want to break my friendship with steve cuz I really really like him..."
All I think of when I read this kind of crap is throwing up. Come on spare me the pleasure of spilling my own fluids all over the front of my shirt. The development of the human brain at the age of 14 is really a disappointment.
Anyway red is my favorite color!
After further evaluation and review J2EE is not (currently) the web server platform I'm looking for. Don't get me wrong it is extremely powerful and well suited to even the most complex web applications, but I don't feel it's something I need right now. I feel that the learning curve and the hardware requirements are not suited to my personal home server with two fairly minimal websites and a DSL connection. I was extremely impressed with Servlets/JSPs/Custom Tags and I know that they would go well towards what I'd like to implement but from development to release in my current schedule will just take too long.
What I am looking for is something a bit simpler with a nice object oriented language which runs decently on older hardware (P4 1.6Ghz). What I'm doing now is evaluating Ruby and Ruby on Rails. It looks very promising and much simpler to set up and maintain than a J2EE solution and it runs good on my old hardware. From the onset Ruby has been very easy to learn, it's object oriented and has a nice clean simple syntax. Let's see how this one works out. There are quite a few tutorials on it that are impressive and really show off the benefits of a Rails web solution. If anyone has broadband and is interested in seeing what Ruby on Rails can do I suggest you look at this 10 minute setup video with a sample application video. I thought it was pretty impressive but then again I get off on these kinds of things.
From what I've seen of this technology it looks like it's the simplest from development to release. The whole thing just looks very well put together and thought out. Let's see how far this goes. =)