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
namespace :export do | |
desc "Prints Country.all in a seeds.rb way." | |
task :seeds_format => :environment do | |
Country.order(:id).all.each do |country| | |
puts "Country.create(#{country.serializable_hash.delete_if {|key, value| ['created_at','updated_at','id'].include?(key)}.to_s.gsub(/[{}]/,'')})" | |
end | |
end | |
end | |
#via http://xyzpub.com/en/ruby-on-rails/3.2/seed_rb.html |
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
#!/bin/bash | |
set -o nounset | |
set -o errexit | |
<<COMMENT | |
via http://robertmuth.blogspot.com/2012/08/better-bash-scripting-in-15-minutes.html | |
To perform a syntax check/dry run of your bash script run: | |
bash -n myscript.sh |
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
var p=/.*(regu).+?\ /gi; console.log( document.body.innerText.match(p) ); |
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
LOAD DATA INFILE '/tmp/stats-2014.csv' | |
INTO TABLE orig_stats | |
FIELDS TERMINATED BY ',' | |
LINES TERMINATED BY '\r\n' | |
IGNORE 1 LINES ; |
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
(set -e && git rev-list --reverse master~3..master | while read rev; do git checkout $rev; python runtests.py; done) | |
# set -e causes shell to stop while loop on test error | |
# via Gary Bernhardt |
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
/*via http://n8henrie.com/2015/03/how-to-batch-like-all-facebook-posts-on-a-page-with-jquery-2/ | |
open javascript console & copy paste jquery latest from | |
http://code.jquery.com/jquery-latest.min.js | |
*/ | |
$('a.UFILikeLink[title="Like this"]').each( | |
function(i, e){ | |
this.click() | |
} |
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
# Your Assignment: | |
# (easy) First, print the numbers 1 to 10 in the console | |
puts "1. ---------------" | |
(1..10).each do |i| | |
puts i | |
end | |
# (medium) Second, Write a method that takes an array [-4,-76, 64, 200, -2, 644] and only prints positive integers |
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
xattr -d com.apple.quarantine /path/to/file |
OlderNewer