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
# convenience script to obfuscate, but not completely redact, *some* | |
# identifier information from a list of Instagram images, such as | |
# all likes and commenters. Image unique ID is left in so original data | |
# can be recovered | |
import json | |
from random import choice | |
from string import ascii_letters, digits | |
FNAME = './examples/images.json' | |
jdata = json.load(open(FNAME)) |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<!-- | |
copied from Mike Bostock: | |
http://bl.ocks.org/mbostock/5735770 | |
http://bost.ocks.org/mike/example/#1 | |
--> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></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
# Not great, but better than doing everything by hand... | |
def prepare_erb_for_slim(body) | |
# remove all %> | |
body.gsub!(/%> */, '') | |
# convert <%-/= to - | |
body.gsub!(/<%(-|=) */, '\1 ') |
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
npage = Nokogiri::HTML(html) | |
h[:text] = Loofah.fragment(npage.search('.displaytext').to_html).to_text |
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
Sector.all.each do |sector| | |
files = Dir.glob("./**/skift/#{sector.slug}.png").reject{|f| f =~ /-blue\.\w{3,4}$/} | |
files.each do |fname| | |
cmd = "convert #{fname} -fill '#2b74a5' +opaque darkblue #{fname}" | |
puts cmd | |
`#{cmd}` | |
end | |
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
{ | |
"always_show_minimap_viewport": true, | |
"auto_complete_commit_on_tab": true, | |
"auto_find_in_selection": true, | |
"binary_file_patterns": | |
[ | |
"*.log", | |
"*.jpg", | |
"*.jpeg", | |
"*.png", |
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
[ | |
{ | |
"keys": ["shift+tab"], "command": "move", "args": {"by": "characters", "forward": true} | |
} | |
] |
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 @field_name = "place_of_service"; | |
SET @tablename = "payments"; | |
SET @query = CONCAT('SELECT ', @field_name, ', count(1), length(', @field_name, ') AS lt FROM ', @tablename,' GROUP BY ', @field_name, ' ORDER BY lt desc'); | |
PREPARE stmt FROM @query; | |
EXECUTE stmt; |
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
# Needed files: | |
# - Rakefile | |
# - Gemfile | |
# - spec/spec_helper | |
##### | |
## Gemfile | |
source 'https://rubygems.org' | |
gem 'rspec' |
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
stores.each do |store| | |
if country == store[:name] | |
store_id = store[:id] | |
break | |
end | |
end | |
# http://ruby-doc.org/core-1.9.3/Enumerable.html | |
### With #select |
OlderNewer