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
# Provides a basic query interface to organize the interface between controller and model | |
module Query | |
attr_reader :scope_methods, :params, :args | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
attr_reader :scope_methods |
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
# Split mysqldump into databases | |
csplit -f 'db_' dump.sql "/Current Database/" '{1000}' | |
# Split mysqldump into tables | |
csplit -f 'table_' db_dump.sql "/Dumping data for table/" '{1000}' |
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
<% @jobs.in_groups_of(3, false).each do |group| %> | |
<div class="row"> | |
<% group.each do |job| %> | |
<div class="col-md-4"> | |
<%= job.title %> | |
</div> | |
<% end %> | |
</div> | |
<% 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
jQuery.exists = function (selector, context) { | |
return ($(selector, context).length > 0); | |
}; |
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
// reseting a form set it back to his original value. | |
(function ($) { | |
$.fn.reset = function () { | |
$(this).each(function () { | |
this.reset(); | |
}); | |
return this; | |
}; | |
}(jQuery)); |
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
(function () { | |
'use strict'; | |
var matched, browser; | |
matched = (function (ua) { | |
ua = ua.toLowerCase(); | |
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || | |
/(webkit)[ \/]([\w.]+)/.exec(ua) || |
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
# Install with: | |
# bash < <(curl -L https://raw.github.com/gist/2216529) | |
# | |
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug | |
echo "Installing ruby-debug with $rvm_ruby_string ..." | |
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem | |
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem |
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
# from http://blog.brunomiranda.com/post/5660219139/100-light-bulbs-brain-teaser | |
bulbs = Array.new(100, true) | |
(2..100).each do |num| | |
(1..(100/num)).each do |step| | |
position = num * step - 1 | |
bulbs[position] = !bulbs[position] | |
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
#!/usr/local/bin/ruby | |
# Import your Wordpress posts to Tumblr | |
# How-to: | |
# 1. Install disqus (http://disqus.com/) in your Wordpress blog and import your comments to Disqus | |
# 2. Export your Wordpress posts (http://en.blog.wordpress.com/2006/06/12/xml-import-export/) | |
# 4. Open your XML and rename all <link> tags to <link_>. Don't forget to rename the closing tag too. | |
# Is necessary to use link_ because hpricot thinks link is the HTML tag. | |
# 3. Edit the information to match your settings | |
# 4. Create a empty file named like FILE_URLS_TO_TIDS |
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
#page_posts {} | |
#page_posts.page_posts_index {} | |
#page_posts.page_posts_show {} |
NewerOlder