Skip to content

Instantly share code, notes, and snippets.

View spiceee's full-sized avatar
🏠
Working from home

Fabio Mont Alegre spiceee

🏠
Working from home
View GitHub Profile
@spiceee
spiceee / fb_sdk.js
Created May 11, 2017 16:06 — forked from 6temes/fb_sdk.js
Compatibility between Facebook Plugin and Turbolinks 5
// FacebookSDK
// https://developers.facebook.com/docs/plugins/page-plugin/
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk')); // Replace 'facebook-jssdk' with your page id.
@spiceee
spiceee / gist:1712244
Created January 31, 2012 19:07
rake task to sync your development Redis as a slave of your production master
namespace :redis do
desc "start sync redis databases to local"
task :start => :environment do
uri = URI.parse REDISTOGO_URL
redis = Net::Telnet::new("Host" => "localhost", "Port" => 6379, "Prompt" => /\z/n)
redis.cmd("CONFIG SET MASTERAUTH #{uri.password}")
redis.cmd("SLAVEOF #{uri.host} #{uri.port}")
redis.close
end
Surround these with : e.g. :calling:
+1
-1
bulb
calling
clap
cop
email
feet
namespace :delayed_job do
desc "Start delayed_job process"
task :start, :roles => :app do
run "cd #{current_path}; RAILS_ENV=production script/delayed_job start"
end
desc "Stop delayed_job process"
task :stop, :roles => :app do
run "cd #{current_path}; RAILS_ENV=production script/delayed_job stop"
end
namespace :open_directory do
# http://www.google.com/Top/
# http://rdf.dmoz.org/rdf/structure.rdf.u8.gz
desc "tasks that deal with Google Open Directory importing"
task :import => :environment do
seeds = []
Category.delete_all
module Telephone
module Push
class Config
class FileNotFoundException < StandardError;end
class MissingKeyException < StandardError;end
attr_accessor :params
def render(opts = {}, extra_options = {}, &block)
if opts[:to_yaml] then
headers["Content-Type"] = "text/plain;"
render :text => Hash.from_xml(render_to_string(:template => opts[:to_yaml], :layout => false)).to_yaml, :layout => false
elsif opts[:to_json] then
# headers["Content-Type"] = "text/javascript;"
render :json => Hash.from_xml(render_to_string(:template => opts[:to_json], :layout => false)).to_json, :layout => false
else
super opts, extra_options, &block
end
#!/bin/sh
cat gem_list | sed -n '4,$ p' | \
while read gem versions; do
for version in $(echo ${versions} | sed "s/[(),]//g"); do
echo ${gem} ${version}
gem install --no-rdoc --no-ri ${gem} -v ${version}
done
done
REGIOES_BRASILEIRAS = {
'Norte' => [
['Acre', 'AC'],
['Amapá','AP'],
['Amazonas', 'AM'],
['Pará', 'PA'],
['Rondônia', 'RO'],
['Roraima', 'RR'],
['Tocantins', 'TO']
],
# Lo-fi client for the Facebook API. E.g.:
#
# fb = FacebookClient.new(:api_key => 'api-key', :secret => 'secret')
# fb.call 'users.getInfo', :session_key => 'session-key', :uids => 'user-id', :fields => 'birthday'
#
class FacebookClient
def initialize(default_params={})
@default_params = default_params.reverse_merge({
:rest_server => 'http://api.new.facebook.com/restserver.php',
:format => 'JSON',