This file contains hidden or 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 'socket' | |
| require 'openssl' | |
| require 'net/ftp' | |
| class Net::FTPS < Net::FTP | |
| end | |
| class Net::FTPS::Implicit < Net::FTP | |
| FTP_PORT = 990 |
This file contains hidden or 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
| Warden::Manager.serialize_into_session{|user| user.id } | |
| Warden::Manager.serialize_from_session{|id| User.get(id) } | |
| Warden::Manager.before_failure do |env,opts| | |
| # Sinatra is very sensitive to the request method | |
| # since authentication could fail on any type of method, we need | |
| # to set it for the failure app so it is routed to the correct block | |
| env['REQUEST_METHOD'] = "POST" | |
| end | |
This file contains hidden or 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
| EASY MARSHMALLOWS | |
| ----------------- | |
| Marshmallows are perhaps one of the simplest confections you can make. They only | |
| require a handful of ingredients, a batch can be thrown together in 10-15 minutes | |
| (plus *cough* 3 hours for them to set), and you can flavor them however you like. | |
| (You haven't LIVED until you've had coconut marshmallows!) | |
| Hardware needed: |
This file contains hidden or 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 'rubygems' | |
| require 'sinatra' | |
| require 'datamapper' | |
| require 'dm-paperclip' | |
| require 'haml' | |
| require 'fileutils' | |
| APP_ROOT = File.expand_path(File.dirname(__FILE__)) | |
| DataMapper::setup(:default, "sqlite3://#{APP_ROOT}/db.sqlite3") |
This file contains hidden or 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 'rubygems' | |
| require 'mechanize' | |
| BASE = 'http://manure.myshopify.com/admin' | |
| LOGIN = '/auth/login' | |
| USER = '[email protected]' | |
| PWD = 'moo-moo' | |
| agent = Mechanize.new | |
| page = agent.get(BASE+LOGIN) | |
| form = page.forms.first | |
| form.login = USER |
This file contains hidden or 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
| # | |
| # Create a new repo on Github and directly push your initial commit with this shell script | |
| # | |
| url=https://github.com/api/v2/json/repos/create | |
| username=$(git config github.user) | |
| token=$(git config github.token) | |
| name=${1-$(basename $(pwd))} | |
| curl -F login=$username -F token=$token $url -F name=$name -F public=1 1>/dev/null |
This file contains hidden or 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
| ## /config/initializers/dynamic_job.rb | |
| require 'heroku' | |
| # base class for all jobs that you wish to automatically scale and go down in Heroku | |
| class DynamicJob | |
| #set a cap on maximum number of users ever - just in case. | |
| MAX_CONCURRENT_WORKERS = 100 | |
| def initialize |
This file contains hidden or 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 'rubygems' | |
| require 'rack' | |
| class Object | |
| def webapp | |
| class << self | |
| define_method :call do |env| | |
| func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
| [200, {}, send(func, *attrs)] | |
| end |
This file contains hidden or 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
| @import "flag/*.png"; | |
| @import "emblem/*.png"; | |
| .flag-sprite { | |
| width: image-width("flag/us.png"); | |
| height: image-height("flag/us.png"); | |
| padding: 0; | |
| } | |
| .emblem-sprite { |
This file contains hidden or 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
| # When anything, including nil, is a valid param and you need | |
| # a clear way to know if a param was set or not, use `None`. | |
| None = Object.new | |
| def foo(a, b=None) | |
| result = [a] | |
| if b != None | |
| result << b | |
| end |
OlderNewer