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
def profile(prefix = "profile") | |
result = RubyProf.profile { yield } | |
dir = File.join(Rails.root, "tmp", "performance", params[:controller].parameterize | |
FileUtils.mkdir_p(dir) | |
file = File.join(dir, "callgrind.%s.%s.%s" % [prefix.parameterize, params[:action].parameterize, Time.now.to_s.parameterize] ) | |
open(file, "w") { |f| RubyProf::CallTreePrinter.new(result).print(f, :min_percent => 1) } | |
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
# Assumes you're using homebrew. | |
# Adjust the version to your convenience. | |
env ARCHFLAGS="-Os -g -fno-strict-aliasing -arch x86_64" gem install mysql2 -v '0.3.19' -- \ | |
--with-mysql-include=`brew --prefix mysql`/include \ | |
--with-mysql-config=`brew --prefix mysql`/bin/mysql_config |
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
do ($ = jQuery, exports = window) -> | |
class ActiveDataBinder | |
constructor: (uid) -> | |
# Use a jQuery object as simple PubSub | |
pubSub = $ {} | |
# We expect a 'data' attribute specifying the binding |
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
/* jQuery core team does not want to add 'reduce' - | |
* Details: http://dev.jquery.com/ticket/1886 | |
*/ | |
(function($) { | |
$.reduce = function(array, callback, initialValue) { | |
if (Array.prototype.reduce) { | |
return Array.prototype.reduce.call(array, callback, initialValue); | |
} |
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
ssh-reagent () { | |
for agent in /tmp/ssh-*/agent.*; do | |
export SSH_AUTH_SOCK=$agent | |
if ssh-add -l 2>&1 > /dev/null; then | |
echo Found working SSH Agent: | |
ssh-add -l | |
return | |
fi | |
done | |
echo Cannot find ssh agent - maybe you should reconnect and forward 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
<?php | |
// displays some comments for a certain url | |
$url = 'http://developers.facebook.com/docs/reference/fql/comment/'; | |
// fql multiquery to fetch all the data we need to display in one go | |
$queries = array('q1' => 'select post_fbid, fromid, object_id, text, time from comment where object_id in (select comments_fbid from link_stat where url ="'.$url.'")', | |
'q2' => 'select post_fbid, fromid, object_id, text, time from comment where object_id in (select post_fbid from #q1)', | |
'q3' => 'select name, id, url, pic_square from profile where id in (select fromid from #q1) or id in (select fromid from #q2)', | |
); |
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
<!-- Place this tag just before your close body tag and NOT in your <head> --> | |
<script> | |
(function(d, t) { | |
var g = d.createElement(t), | |
s = d.getElementsByTagName(t)[0]; | |
g.async = true; | |
g.src = 'https://apis.google.com/js/plusone.js'; | |
s.parentNode.insertBefore(g, s); | |
})(document, 'script'); | |
</script> |
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
@mixin background-rgba($r,$g,$b,$a) { | |
// To mimic this in Internet Explorer, you can use the proprietary filter | |
// property to create a gradient with the same start and end color, along | |
// with an alpha transparency value. | |
@if experimental-support-for-microsoft { | |
$color: ie_hex($r,$g,$b,$a); | |
$value: unquote("progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=##{$color},endColorstr=##{$color})"); | |
background-color: transparent\9; |
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
Spork.each_run do | |
# This code will be run each time you run your specs. | |
load "#{Rails.root}/config/routes.rb" | |
Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f } | |
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
Array.max = function(array){ | |
return Math.max.apply(Math, array); | |
}; | |
Array.min = function(array){ | |
return Math.min.apply(Math, array); | |
}; |