Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / mongo
Created July 21, 2014 19:51
Mongo cmds with Mongoid config
#!/usr/bin/env ruby
# put in scripts folder, and make executable
# $ chmod +x scripts/mongo
require 'yaml'
HELP = '''
@aj0strow
aj0strow / bower.json
Created July 17, 2014 04:11
RequireJS Hello World
{
"private": true,
"name": "helloworld",
"version": "0.0.0",
"dependencies": {
"requirejs": "~2.1.9"
}
}
@aj0strow
aj0strow / root.js
Created July 8, 2014 19:18
Node App Root
var path = require('path')
var dirname = path.dirname(require.main.filename)
var root = dirname.split('/node_modules/')[0]
module.exports = root