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
require 'digest/md5' | |
=begin | |
About: | |
This script automatically runs on a 2-second loop, searches the current directory for haml & sass files that have been modified since the last iteration and builds them as needed into a file with the same name minus the .haml/sass extension. I wrote it so I could use Haml & Sass to develop Wordpress themes. | |
How-to: | |
1) Name your source files with the extension you'd like them to have, then add ".haml" or ".sass" as appropriate... | |
For example: index.php.haml and styles.css.sass |
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
# copy and paste this into your terminal to start an IRB session and use Capybara's DSL to write tests interactively | |
# Thanks to Tom Clements | |
# http://tom-clements.com/blog/2012/02/25/capybara-on-the-command-line-live-browser-testing-from-irb/ | |
# I prefer using chrome... | |
# First you need to install the chromedriver https://sites.google.com/a/chromium.org/chromedriver/downloads | |
# Unzip, and move the executable somewhere in your path... | |
# e.g. | |
mv ~/Downloads/chromedriver /usr/local/bin |
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
require 'json' | |
require 'net/http' | |
def get_json(url) | |
JSON.parse(Net::HTTP.get_response(URI.parse(url)).body) | |
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
/** | |
* The first commented line is your dabblet’s title | |
*/ | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-height: 100%; | |
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
#Fix those annoying "invalid byte sequence in UTF-8" errors when parsing CSVs, etc. | |
#prints to STDOUT where you can redirect to a new file, etc. | |
#NOTE: this just strips out invalid/undef characters which may be a Very Bad Thing™ - YMMV | |
#suggestions welcome... | |
#also fix annoying newlin chars created by excel... replace \r with \r (weird but works) | |
input_file = ARGV[0] or raise "No input file specified" | |
puts IO.read(input_file).encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/\r/,"\r") |
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
#handy bash functions to easily add things to text files | |
#todo list | |
td() { echo $@ >> /path/to/your/todo.txt; } | |
#log (with date time stamp) | |
log() { echo $(date) $@ >> /path/to/your/log.txt;} |
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
#my rails 4 gemfile with | |
#bootstrap | |
#sass | |
#postgresql | |
#slim templates | |
#puma | |
#blahblahblah :) | |
#for heroku, make a Procfile like so: | |
# web: bundle exec rails server -p $PORT |
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
# What: Turn a multi-column CSV file into the nested "flare.json" structure required by D3 for a collapsible tree diagram like this: https://bl.ocks.org/mbostock/4339083 | |
# I couldn't find a generic way to do this so I wrote this script. Help & comments welcome! | |
# How: Nested hashes group the data. Then a recurive function builds a new hash with the correct format for the JSON. | |
# Caveats: Currently supports up to 4 levels/columns of depth | |
# TODO: make it generically support n-levels | |
# Who: Peter Kappus (http://kapp.us) | |
# CSV Format: | |
# Create a CSV called "data.csv" with any headers you like. It might look like this: | |
# group_name, team_name, person_name |
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
<body xonload="convert()"> | |
<script language="javascript"> | |
function convert(){ | |
source_rows = document.getElementById('raw_input').value.split("\n") | |
headers = source_rows.shift().split("\t"); | |
//rows now contains only data | |
data = [] | |
for(i in source_rows){ | |
interim_row_data = {} |
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
#usage: ruby build... [INPUT_FILE] | |
#what it does: makes a folder named after the input file and builds the necessary versions for S6 | |
#requirements: rsvg-convert to rasterise the SVG and imagemagick to make the versions | |
file = ARGV[0] or abort ("No input file specified.") | |
big_width = 6500 | |
basename = File::basename(file,".svg") | |
Dir::mkdir(basename,0700) unless File.exists? basename |
OlderNewer