herro, [missing varue]!1!

Posted by MahFreenAmeh on Jan. 18, 2011, 10:47 a.m.

hello again 64digits. yes, i returned, to plague you with even more thoughts that I do not think i originally thought but may have originally thought if i had the chance to originally think them. wait, i think i just confused myself, or maybe that was you. i'm never really good at identifying what exactly i mean to do or what exactly i have done. in any case, here we go:

i'm going to reshare the link that I put up last time:

http://ht.ly/3ESfq

and again, this was a jam session between my friend, kirk, and i. i played the guitar on tracks one through five, and drums on track six and seven. it was a pretty fun night. i got to jam with some other friends last night too, but they were too structure, too… rigid. no room for really just having fun, no room for noise. some people try too hard to sound good, but good lord, is it fun to jam in any case. who knows? maybe i'm just insane. maybe not. in other news, my site went down temporarily today. that made me a bit upset.

but right now i'm in the process of coding a miniature social network based off of sms/email. i've got most of it done, but i'm doing the backend maintenance right now, and soon will code the online part. here are some snippets from what i've got so far with the backend maint service:

require 'sinatra'
require 'haml'
require 'mysql'
$host = "localhost"
$username = "user"
$pass = "pass"
$db = "database:
db = Mysql::new($host,$username,$pass,$db)
before do
	begin
		db.ping()
	rescue Mysql::Error => msg
		puts "MySql server went away/down, reinstating connection"
        db = Mysql::new($host,$username,$pass,$db)
	end
end
get '/' do
	haml :index
end
get '/list' do
	puts "yay"
	users = Array.new
	db.query("SELECT name,id FROM txt").each_hash do |row|
		id = row['id'].to_i
		name = row['name']
		users[id]=name;	
	end
	haml :list, :locals => {:usr => users}
end
get '/list/:id' do  
	sql = ""
	db.query("SELECT * FROM txt WHERE id=#{params[:id]}").each_hash do |row|
		row.each do |field, val|
			puts "field: #{field}, val: #{val}"
			puts
			sql += "#{field}: #{val}\n"
		end
	end
	haml :id, :locals => {:sql => sql}
end

and some example code from one of the views:

id.haml

%html
	%head
		%title= "Details for UserID #{params[:id]}" 
	%body
		.content
			.header
				Header content
				%br
			.body
				="User ID #{params[:id]}"
				%br
				Data from SQL server:
				%br
				%pre= sql
			.footer
				Lorem ipsum dolor foot amet
				%br

list.haml

%html
	%title List users
	%script{:src => "<a rel="nofollow" href="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js">http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js</a>"}
	%body
		.content
			.header
				Header content
				%br
			.body
				We list the users here
				%select.id#id{:name => "id"}
					-for i in 0..usr.length-1 do 
						-id = i
						-name = usr[ i ]
						%option{:value => id}=name
					
				%br
			.footer
				Lorem ipsum dolor foot amet
				%br
			%script
				$(document).ready(function() {
				$(".id").bind("change",function() {
				window.location="list/"+$(this).val();
				})
				})

so far, things are going pretty swell.

i might post some code that i used for my handling of emails/sms's, but that's about it for now. maybe more code next time, maybe not.

edit

oh come on, code tag doesn't properly indent. whatevs

Comments

melee-master 13 years, 3 months ago

What are you writing that in?

Castypher 13 years, 3 months ago

Good stuff. Now tell Serprex to get his ass back here.

MahFreenAmeh 13 years, 3 months ago

melee: ruby.

kilin: y