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 'rewindable_input' | |
| ActionController::Dispatcher.middleware.insert_before ActionController::ParamsParser, RewindableInput |
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
| #!/bin/sh | |
| # -*- bash -*- | |
| if [ $# -gt 0 ]; then | |
| if [ ! -f $1 ] && [ ! -d $1 ]; then | |
| touch $1 | |
| fi | |
| if [ -d $1 ]; then | |
| realpath=`cd $1;pwd` |
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
| # i think the way to do it is that the route definitions in app/config/routes.rb need to be exactly the same, | |
| # but with your additions, as the route definitions in the clearance gem. then, your definitions will override | |
| # clearance's ...or something | |
| # in my case though, i actually have a SessionsController and UsersController in my app that inherit from | |
| # clearance's, but confirmations still works. don't remember the specifics | |
| ActionController::Routing::Routes.draw do |map| | |
| map.root :controller => 'home' | |
| map.dashboard '/dashboard', :controller => 'home', :action => 'dashboard' |
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
| describe SomeController do | |
| before(:each) do | |
| # exisiting mock setup | |
| end | |
| # add to mocks, placement after before is key | |
| it_should_behave_like "a before filter thingie" | |
| it "blah" | |
| 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 org.sinatraLikeServlet.*; | |
| public class MyApplication extends SinatraLikeHTTPServlet { | |
| @get("/") | |
| public void index(SinatraLikeHTTPServletRequest req | |
| SinatraLikeHTTPServletResponse resp) { | |
| MyResource[] resources = MyResource.findAll(); | |
| req.setAttribute("resources", resources); | |
| } |
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
| # send email using STARTTLS; Net::SMTP#enable_starttls requires ruby >=1.8.7 | |
| # this hack is needed for rails <2.3; apparently >=2.3 has something for this already | |
| ActionMailer::Base.class_eval do | |
| private | |
| def perform_delivery_smtp(mail) | |
| destinations = mail.destinations | |
| mail.ready_to_send | |
| smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port]) |
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 'time' | |
| loop do | |
| if Time.now > Time.parse('06:30') | |
| `/usr/bin/open "/Users/ryanbriones/Music/iTunes/iTunes Music/Daft Punk/Discovery/01 One More Time.mp3"` | |
| break | |
| end | |
| puts "#{Time.now} not #{Time.parse('06:30')}" | |
| sleep 5 |
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
| if [ "$1" ]; then | |
| BRANCH=$1 | |
| else | |
| BRANCH=$(git branch | grep '*' | cut -d ' ' -f2) | |
| fi | |
| REMOTE=$(git config --get branch.$BRANCH.remote) | |
| REMOTE_BRANCH=$(git config --get branch.$BRANCH.merge) | |
| echo "$REMOTE/${REMOTE_BRANCH##*/}" |
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
| //node()[@attribute and not(@attribute <= preceding-sibling::node()/@attribute) and not(@attribute <=following-sibling::node()/@attribute)] |
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
| # getting more power out of Enumerable | |
| # this is to convert an RGB data structure, into RGBA | |
| RGB_WIDTH = 3 | |
| raw_data = [1,1,1,2,2,2,3,3,3,4,4,4] | |
| # returns an enumerable object with the raw data split up into chunks of 3 | |
| pixels = raw_data.enum_slice( RGB_WIDTH ) |