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/bash | |
| debug=`git diff --cached | grep -C 2 -E '+\s*And (open|show me the page)'` | |
| conflicts=`git diff --cached | grep -C 2 -E '<<<|>>>'` | |
| if [ -n "$debug" ]; then | |
| echo "debugging statements added in this commit" | |
| echo $debug | |
| fi |
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
| # autoload concerns | |
| module YourApp | |
| class Application < Rails::Application | |
| config.autoload_paths += %W( | |
| #{config.root}/app/controllers/concerns | |
| #{config.root}/app/models/concerns | |
| ) | |
| end | |
| 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
| def tip(msg); puts; puts msg; puts "-"*100; end | |
| # | |
| # 30 Ruby 1.9 Tips, Tricks & Features: | |
| # http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
| # | |
| tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
| tip "Ruby 1.9 supports named captures in regular expressions!" |
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
| // UITextFieldDelegate method, called when the "Return" key is pressed. | |
| // Either advance the cursor to the next empty field, or submit the form. | |
| // | |
| - (BOOL)textFieldShouldReturn:(UITextField *)textField { | |
| if([usernameField.text length] == 0) { | |
| [usernameField becomeFirstResponder]; | |
| } else if ([passwordField.text length] == 0) { | |
| [passwordField becomeFirstResponder]; | |
| } else { |
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
| module Mongo | |
| module Instrumentation | |
| def self.instrument(clazz, *methods) | |
| clazz.module_eval do | |
| methods.each do |m| | |
| class_eval %{def #{m}_with_instrumentation(*args, &block) | |
| ActiveSupport::Notifications.instrumenter.instrument "mongo.mongo", :name => "#{m}" do | |
| #{m}_without_instrumentation(*args, &block) | |
| end | |
| 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
| require 'socket' | |
| require 'syslog' | |
| require 'logger' | |
| require 'hoptoad_notifier' | |
| # TcpSyslog is used are a dead-simple replacement for | |
| # syslog ruby libs. None of them is able to send logs | |
| # to a remote server, and even less in TCP. | |
| # | |
| # Example: |
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 'eventmachine' | |
| require 'em-websocket' | |
| require 'json' | |
| class Connection | |
| attr_accessor :socket, :user_id | |
| def initialize(socket, user_id) | |
| @socket = socket |
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Cross-browser kerning-pairs & ligatures</title> | |
| <style> | |
| body { font-family: sans-serif; background: #f4f3f3; color: rgba(40, 30, 0, 1); width: 500px; margin: 80px auto; padding: 0px; } | |
| a { color: rgba(15, 10, 0, 0.8); text-decoration: none; border-bottom: 1px solid; padding: 1px; -webkit-transition: background 1s ease; } | |
| a:hover { background: rgba(0, 220, 220, 0.2); } | |
| p { line-height: 1.5; padding: 0px 1em 0em 0em; } |
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
| gunzip -c production.log.1.gz |awk '/MyController#create/ {freq[substr($7,0,5)]++} END {for (time in freq) printf "%d\t%s\n", freq[time], time }' | sort -nr | head -n 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
| # checkout: http://github.com/igrigorik/async-rails/ | |
| From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001 | |
| From: Ilya Grigorik <ilya@igvita.com> | |
| Date: Thu, 10 Jun 2010 00:46:48 -0400 | |
| Subject: [PATCH] async rails3 | |
| --- | |
| Gemfile | 6 ++++++ | |
| app/controllers/widgets_controller.rb | 6 ++++++ |