Skip to content

Instantly share code, notes, and snippets.

View fijimunkii's full-sized avatar
🦁
𐂃͠

Harrison Powers fijimunkii

🦁
𐂃͠
View GitHub Profile
@fijimunkii
fijimunkii / README.md
Created September 25, 2013 14:33
gistle

I get the gist of this.

@fijimunkii
fijimunkii / ask_question.rb
Last active December 24, 2015 00:09
ruby: ask question
def ask(question)
puts question
user_input = gets.chomp
end
def ask_num(question)
ask(question).to_f
end
@fijimunkii
fijimunkii / float$.rb
Created October 6, 2013 01:41
ruby: puts format money (print float with $ preceeding it)
f = 10.5; p "$%.1f" % f
@fijimunkii
fijimunkii / params.rb
Last active December 24, 2015 22:59
ruby: params from scratch
url = 'http://www.google.com/?q=123&y=2950&z=9500&p=950'
params = {}
query = url.split('?').pop
query.split('&').each do |x| y = x.split('='); params[y[0]] = y[1] end
@fijimunkii
fijimunkii / sinatra_pg_connect_helper.rb
Created October 9, 2013 20:44
ruby: sinatra PG.connect helper
helpers do
def db_exec(sql)
conn = PG.connect(:dbname =>'DB_NAME', :host => 'localhost')
result = conn.exec(sql)
conn.close
result
end
end
@fijimunkii
fijimunkii / active_record.rb
Last active December 25, 2015 05:19
ruby: manually set up active_record
require 'active_record'
ActiveRecord::Base.logger = Logger.new( STDOUT )
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:host => "localhost",
:username => "EDIT ME",
:password => "",
:database => "EDIT ME"
@fijimunkii
fijimunkii / PG.connect.escape.rb
Created October 11, 2013 00:11
ruby: PG.connect escape method
def self::quote_connstr( value )
return "'" + value.to_s.gsub( /[\\']/ ) {|m| '\\' + m } + "'"
end
@fijimunkii
fijimunkii / database.yml
Created October 17, 2013 13:31
database.yml template
development:
adapter: postgresql
encoding: unicode
database: <%= File.basename(Rails.root) %>_development
pool: 5
host: localhost
username: <%= ENV['PG_USERNAME'] %>
password:
test:
@fijimunkii
fijimunkii / index.html.slim
Last active December 25, 2015 19:49
index.html.slim template
doctype html
== "<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->"
== "<!--[if lt IE 7 ]> <html class=\"ie6\" lang=\"en\"> <![endif]-->"
== "<!--[if IE 7 ]> <html class=\"ie7\" lang=\"en\"> <![endif]-->"
== "<!--[if IE 8 ]> <html class=\"ie8\" lang=\"en\"> <![endif]-->"
== "<!--[if IE 9 ]> <html class=\"ie9\" lang=\"en\"> <![endif]-->"
== "<!--[if (gt IE 9)|!(IE)]><!--> <html lang=\"en\"> <!--<![endif]-->"
head
meta charset="utf-8"
@fijimunkii
fijimunkii / rails_log.sh
Last active December 28, 2015 01:49
sh: tail rails log
tail -f log/development.log