Skip to content

Instantly share code, notes, and snippets.

@aj0strow
aj0strow / tenslow.sh
Created August 6, 2014 11:42
Express Heroku 10 Slowest Requests
npm install -g strip-ansi
heroku logs | strip-ansi | grep 'web.\d' | awk '{ if($7 == "ms") print $6, "\t\t", $3, $4 }' | sort -nr | head -n 10
@aj0strow
aj0strow / redis-commands
Created October 12, 2014 00:12
Redis Commands
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
if ARGV.length > 1
puts 'redis-commands [group]'
exit 1
end
@aj0strow
aj0strow / generator.rb
Created November 2, 2014 21:53
Web Generator
system 'touch README.md'
system 'mkdir scripts stylesheets templates'
# git
# http://git-scm.com/
# http://git-scm.com/docs/gitignore
file = <<___
node_modules
bower_components
@aj0strow
aj0strow / switch.css
Last active August 29, 2015 14:10
Switch Checkbox
.switch input {
display: none;
}
.switch i {
display: inline-block;
cursor: pointer;
padding-right: 20px;
transition: all ease 0.2s;
border-radius: 20px;
@aj0strow
aj0strow / moment.js
Created November 27, 2014 23:27
Moment.js twitter-style fromNow
assert(typeof moment == 'function', 'moment dependency')
function gt (input, key) {
var dur = moment.duration(input, key)
return this.as('milliseconds') > dur.as('milliseconds')
}
function lt (input, key) {
var dur = moment.duration(input, key)
return this.as('milliseconds') < dur.as('milliseconds')
@aj0strow
aj0strow / bench.rb
Created December 4, 2014 22:16
ruby curl benchmark
require 'dotenv'
Dotenv.load
require 'benchmark'
require 'multi_json'
require 'firebase'
require 'patron'
Benchmark.bmbm do |x|
@aj0strow
aj0strow / rm_pdf_page.rb
Created December 5, 2014 03:52
Remove PDF Page
require 'combine_pdf'
input = 'filename.pdf'
output = 'filename.pdf'
num = 10
pdf = CombinePDF.new
CombinePDF.new(input).pages.each.with_index(1) do |page, i|
pdf << page unless i == num
end
@aj0strow
aj0strow / diff.rb
Created December 16, 2014 21:22
diff heroku env
require 'set'
one = ARGV.shift
two = ARGV.shift
xs, ys = [ one, two ].map do |app_name|
text = `heroku config -a #{app_name}`
Set.new(text.scan(/^(\w+):/))
end
@aj0strow
aj0strow / index.js
Created December 28, 2014 23:30
firebase child readable stream
var PassThrough = require('stream').PassThrough
function createChildStream(ref) {
var stream = new PassThrough({ objectMode: true })
ref.limitToLast(1).once('child_added', function(snap) {
var stopKey = snap.key()
ref.on('child_added', function(snap) {
stream.push(snap.val())
if (snap.key() == stopKey) {
ref.off('child_added')
@aj0strow
aj0strow / examples.js
Created May 25, 2015 21:03
YQL finance data
YQL('yahoo.finance.quotes')
.where({ symbol: [ '^IXIC' ] })
.select([ 'Symbol', 'LastTradePriceOnly', 'Change', 'PercentChange' ])
.then(function (results) {
console.log(results)
})
YQL('yahoo.finance.historicaldata')
.where('symbol', '=', 'PRFC')
.where({ startDate: new Date(2015, 4, 1), endDate: new Date(2015, 4, 23) })