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
<script type="text/javascript"> | |
timeOfLastKeyPress = new Date().getTime() * 2; // make it in the future | |
maxMillisecondsBetweenKeystrokes = 1000; | |
millisecondsBetweenCheckingForStoppage = 250; | |
function logKeyPress(){ | |
timeOfLastKeyPress = new Date().getTime(); | |
} | |
function userStoppedTyping(){ |
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
SELECT DISTINCT 'script/generate scaffold ' + t.name + ' ' + column_names | |
FROM sys.tables t | |
CROSS APPLY ( | |
SELECT c.name + | |
case when max_length > 255 then ':text' else ':string' end + ' ' | |
FROM sys.columns c | |
WHERE c.object_id = t.object_id | |
ORDER BY c.column_id | |
FOR XML PATH('') ) dummy_identifier ( column_names ) |
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
# Pass the container name, ID variable name, and options with those names | |
# surrounded by ## on either side, and this function will replace those, | |
# closing the string and referring to a javascript variable in each place | |
# | |
# An example of when it's useful: Suppose you have a set of lists on screen | |
# with some items. You periodically want to refresh the items for one of | |
# the lists, and you don't want to generate the same function for each list | |
# in the page. Instead, you'd rather just have one function and pass the ID | |
# of the list to it, and figure out the DOM ID and route based on the ID | |
# passed to the javascript function. |
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
ActiveRecord::QueryMethods.class_eval do | |
# this is code from the original file, with the .map do |x| ... added to build_where | |
# ideally, we would alias original_where where and work with the relation.where_values, but | |
# I haven't yet been successful in that attempt. | |
def where(opts, *rest) | |
return self if opts.blank? | |
relation = clone | |
relation.where_values += |
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
2012-02-06 09:16:21 | |
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.4-b02-402 mixed mode): | |
"Attach Listener" daemon prio=9 tid=101ab8000 nid=0x10e607000 waiting on condition [00000000] | |
java.lang.Thread.State: RUNNABLE | |
"Thread-14" daemon prio=5 tid=10c89c800 nid=0x10e404000 in Object.wait() [10e403000] | |
java.lang.Thread.State: TIMED_WAITING (on object monitor) | |
at java.lang.Object.wait(Native Method) | |
at org.jruby.util.ShellLauncher$StreamPumper.run(ShellLauncher.java:1323) |
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
--colour | |
-I app |
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
# I have read http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resources | |
# and remain clueless. | |
MyApp::Application.routes.draw do | |
resources :blogs do | |
resources :comments | |
end | |
# then imagine tons of routing below this | |
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
# See http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-set_trace_func for docs on this function | |
require 'ostruct' | |
module Friendly | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
def method_missing(name, *args, &block) |
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
git clone git://github.com/etsy/statsd.git | |
cd statsd | |
# yak shaving: | |
# install nodejs if you don't have it | |
brew install node # assuming you have/use homebrew | |
# install python if you don't have it | |
# I already had python due to it being packaged with MacOS, but if you don't have it, you'll need it |
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
apps = [ | |
"/path/to/rails/project/root", | |
"/path/to/another/rails/project/root" | |
] | |
def number_of_migrations_since_first_reference(attribute, directory, indexed_in) | |
grep_command = "grep -H \"#{attribute.gsub(/[\[\]\s]/,'')}\" #{directory}/*.rb" | |
all_refs = `#{grep_command}` | |
return -1 unless all_refs.length > 0 # probably defined with t.references :other_table |
OlderNewer