Skip to content

Instantly share code, notes, and snippets.

View barce's full-sized avatar

Barce barce

View GitHub Profile
@barce
barce / gist:856021
Created March 5, 2011 01:53
puzzle
8fc42c6ddf9966db3b09e84365034357
2fa47f7c65fec19cc163b195725e3844
8bf8854bebe108183caeb845c7676ae4
9e925e9341b490bfd3b4c4ca3b0c1ef2
b45cffe084dd3d20d928bee85e7b0f21
df491a4de50739fa9cffdbd4e3f4b4bb
639bae9ac6b3e1a84cebb7b403297b79
600d6af0f320a021dc494cfa2daca569
c68271a63ddbc431c307beb7d2918275
a181a603769c1f98ad927e7367c7aa51
def test_stuff
stuff
end
= f.input :start_day_month, :label => false, :placeholder => "dd/mm"
@barce
barce / gist:979151
Created May 18, 2011 18:12
change this for changing name of rails app
Rakefile:Changethis::Application.load_tasks
app/views/layouts/application.html.erb: <title>Changethis</title>
config/application.rb:module Changethis
config/environment.rb:Changethis::Application.initialize!
config/environments/development.rb:Changethis::Application.configure do
config/environments/production.rb:Changethis::Application.configure do
config/environments/test.rb:Changethis::Application.configure do
config/initializers/secret_token.rb:Changethis::Application.config.secret_token = 'ff165cfc185d1428471341b176d2c7883acbdd500140dadd3b9d7f732caad7ad4283ad908fdc0a95723eaad13f914f77e3e1fc06fe3534557e9f1654cd98e3d4'
config/initializers/session_store.rb:Changethis::Application.config.session_store :cookie_store, :key => '_changethis_session'
config/initializers/session_store.rb:# Changethis::Application.config.session_store :active_record_store
@barce
barce / classifier_hack.rb
Created May 30, 2011 00:35
monkey patch for Array if using classifier gem
class Array
def sum(identity = 0, &block)
return identity unless size > 0
if block_given?
map(&block).sum
else
a = inject( nil ) { |sum,x| sum ? sum+x : x }
# Hack to remove the to_f error
a.is_a?(Array) ? a : a.to_f
@barce
barce / gist:1175940
Created August 27, 2011 22:23
Monkeypatching FTW
class NilClass
def teetimes_for(date)
puts 'hi'
end
end
a = nil
date = ''
@barce
barce / auth_ruby.rb
Created December 1, 2011 21:53
how i authorize a facebook app in ruby
def authorize
@oauth = Koala::Facebook::OAuth.new(APP_ID, SECRET_KEY, CALLBACK_OAUTHS_URL)
stuff = @oauth.parse_signed_request(params[:signed_request])
@redir_url = @oauth.url_for_oauth_code(:permissions =>
"publish_stream,email,offline_access,user_about_me,user_likes,user_interests,friends_interests,friends_likes")
@redir_url
end
@barce
barce / rails_time_zones.txt
Created January 10, 2012 17:03
How I handle Timezones
Server: EST
Database: UTC
User: Time.zone = <User's chosen time zone>
Rails config: UTC
Dev machine: EST
@barce
barce / wtf1.sql
Created February 2, 2012 17:15
wtf sql
SELECT * FROM `activities` WHERE ((`asset_type` = 'youtube_video') AND (`id` IN (15, 47, 53, 55, 289, 302, 397, 534, 647, 750, 770, 771, 773, 792, 820, 821, 828, 1016, 1088, 1367, 1367, 1367, 1432, 1462, 1530, 1595, 1597, 1806, 2113, 2498, 2523, 2552, 2558, 2674, 2700, 2701, 2717, 2745, 2770, 2777, 2794, 2813, 2934, 2941, 2955, 2963, 3015, 3017, 3058, 3111, 3115, 3132, 3156, 3164, 3178, 3179, 3188, 3223, 3228, 3232, 3246, 3297, 3305, 3307, 3321, 3347, 3385, 3393, 3394, 3395, 3396, 3397, 3410, 3412, 3413, 3418, 3420, 3421, 3424, 3428, 3431, 3432, 3433, 3434, 3435, 3436, 3439, 3440, 3442, 3444, 3445, 3447, 3449, 3454, 3455, 3456, 3462, 3463, 3465, 3467, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3479, 3480, 3481, 3483, 3485, 3487, 3488, 3490, 3492, 3496, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3507, 3508, 3509, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3536, 3537, 3538, 3539, 3541, 3543, 3558, 3559, 3560, 3561, 3562, 3563, 3566, 3567, 3568
@barce
barce / nginx.conf
Created March 2, 2012 21:20
nginx conf for php
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.nginx.org/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################