Skip to content

Instantly share code, notes, and snippets.

View sixtyfive's full-sized avatar
🐯
Rawrrr.

J. R. Schmid sixtyfive

🐯
Rawrrr.
View GitHub Profile
# Throw this in config/initializers and add
# @import variables.sass to the top of application.sass
# to have all variables in app_config.yml
# available as variables in your sass stylesheets
#
# First draft by unixmonkey (http://gist.github.com/323198)
# flatten method added by J. R. Schmid <jrs+git@weitnahbei.de>
app_config = YAML::load(File.open(File.join(RAILS_ROOT, 'config', 'app_config.yml')))
class Week < ActiveRecord::Base
has_many :days
def activities
activities = []
days.each {|day| activities = activities | day.activities}
return activities
end
end
# Adapted from the recently uploaded Rails initializer file for
# loading the content of app_config.yml into a variables.sass file.
#
# Useful for:
#
# Flattening a Hash, i.e.:
# irb> {:foo => :bar, :foobar => {:foo => :bar}}.flatten
# => {"foobar_foo"=>:bar, "foo"=>:bar}
class Hash
root@gaia:~$ rvm 1.9.2
root@gaia:~$ rvm info
ruby-1.9.2-p136:
system:
uname: "OpenBSD gaia 4.5 GENERIC.MP#2133 amd64"
bash: "/usr/local//bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-unknown-openbsd4.5)"
zsh: "/usr/local//bin/zsh => zsh 4.3.9 (x86_64-unknown-openbsd4.5)"
muaddib@gaia:~$ gem install iconv
Fetching: iconv-0.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing iconv:
ERROR: Failed to build gem native extension.
/usr/local//rvm/rubies/ruby-1.8.7-p330/bin/ruby extconf.rb
checking for iconv() in iconv.h... no
checking for iconv() in -liconv... no
...
create_table :files do |t|
t.string :image
end
SELECT id,
TIMESTAMPADD(HOUR, 1, starts_on) AS starts_on,
TIMESTAMPADD(HOUR, 1, ends_on) AS ends_on,
user_id
FROM activity_years
WHERE YEAR(starts_on) = ? OR YEAR(ends_on) = ?;
SELECT id, user_id,
CASE
WHEN HOUR(starts_on) = 22 THEN TIMESTAMPADD(HOUR, 2, starts_on)
WHEN HOUR(starts_on) = 23 THEN TIMESTAMPADD(HOUR, 1, starts_on)
END AS starts_on,
CASE
WHEN HOUR(ends_on) = 21 THEN TIMESTAMPADD(HOUR, 2, ends_on)
WHEN HOUR(ends_on) = 22 THEN TIMESTAMPADD(HOUR, 1, ends_on)
END AS ends_on
FROM activity_years
@sixtyfive
sixtyfive / gist:984987
Created May 21, 2011 23:12
date_range_scoped_by_user_and_month(start_date, end_date, user, month)
SELECT id, user_id, activity_month_id, activity_week_id,
CASE
WHEN HOUR(starts_on) = 22 THEN DATE(TIMESTAMPADD(HOUR, 2, starts_on))
WHEN HOUR(starts_on) = 23 THEN DATE(TIMESTAMPADD(HOUR, 1, starts_on))
ELSE DATE(starts_on)
END AS starts_on,
CASE
WHEN HOUR(ends_on) = 21 THEN DATE(TIMESTAMPADD(HOUR, 2, ends_on))
WHEN HOUR(ends_on) = 22 THEN DATE(TIMESTAMPADD(HOUR, 1, ends_on))
ELSE DATE(ends_on)
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://...
[branch "master"]
remote = origin