This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/md5' | |
class FbJsConnect | |
# When using the Facebook Javascript SDK to connect users to your site, | |
# a cookie will be placed in your applications session store. This class | |
# will verify your cookie, tell you if you're connected, and provide | |
# you with a User and other information | |
# | |
# cookie = cookies["fbs_YOUR FACEBOOK APP ID"] | |
# fb = FbJsConnect.new(cookie) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# put this somewhere in your project, ie: /lib | |
# use: | |
# crontab -e | |
# */30 * * * * /usr/bin/ruby /your_rails_project/lib/this_file.rb | |
# that will insert this job into your delayed_job queue every 30 minutes. | |
require 'rubygems' | |
require 'mysql' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note model has a column, :important, :boolean, :default => false | |
# This goes in your HTML erb | |
<% @user.notes.find(:all, :order => 'updated_at DESC').each do |user_note| %> | |
<% remote_form_for user_note, {:url => | |
remote_toggle_important_user_note_path(:user_id => @user.id, :id => user_note.id)} do |f| %> | |
<%= f.check_box :important, :onclick => "$('edit_user_note_#{user_note.id}').onsubmit()" %><%= f.label :important %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'redis' | |
require 'mysql2' | |
# assuming redis is running on the default port. | |
# if not, example: redis = Redis.new(:host => "10.0.1.1", :port => 6380) | |
redis = Redis.new | |
# Make sure queue exists, if not create it. When clearing a queue with the resque web interface, resque removes the queue, so here we just check to make sure it exists. | |
if redis.sismember('resque:queues', 'update_payment') == false | |
redis.sadd('resque:queues', 'update_payment') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails c | |
> @kitten = Kitten.first | |
> Rails.cache.write("kitten_#{@kitten.id}", @kitten) | |
=> "OK" | |
> Rails.cache.read("kitten_1") | |
=> #<Kitten id: 1, cute: "no"> | |
> exit | |
$ rails c | |
> Rails.cache.read("kitten_1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env == "development" | |
Dir.foreach("#{Rails.root}/app/models") do |model_name| | |
require_dependency model_name unless model_name == "." || model_name == ".." | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName yourdomain.com | |
ServerAlias www.yourdomain.com | |
DocumentRoot /home/yourserverusername/sites/yourappname/current/public | |
<Directory /home/yourserverusername/sites/yourappname/current/public> | |
AllowOverride all | |
Options -MultiViews |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticleSweeper < ActionController::Caching::Sweeper | |
observe Article # This sweeper is going to keep an eye on the article model | |
# If our sweeper detects that a article was created call this | |
def after_create(article) | |
expire_cache_for(article) | |
end | |
# If our sweeper detects that a article was updated call this | |
def after_update(article) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Increase LED Brightness with Reset | |
Each press of the button increases the LED brightness by 10%. | |
Press and hold the button for 3 seconds to reset the LED to 0%. | |
created 2012 | |
by Aaron Van Bokhoven | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Increase LED Brightness with long press, Lower LED brightness with short press | |
Holding down the button with increase the brightness continuously. | |
A short press of the button will decrease the brightness by 20% | |
created 2012 | |
by Aaron Van Bokhoven | |
*/ |
OlderNewer