Skip to content

Instantly share code, notes, and snippets.

Dan Vine danvine

Block or report user

Report or block danvine

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View share-last-screenshot.rb
#!/usr/bin/ruby -w
# INSTALL (zsh)
# mkdir -p ~/Screenshots; defaults write location ~/Screenshots
# echo 'alias share="~/share-last-screenshot.rb"' >> ~/.zprofile
filename = Dir.glob("#{ENV['HOME']}/Screenshots/*").max_by {|f| File.mtime(f)}
url = `curl -T '#{filename}' 2> /dev/null`.chomp
View gist:198a2d1e05b9d6f55337
imagesnap ~/Desktop/$(date +%y%m%d%H%M)_camera.png
screencapture ~/Desktop/$(date +%y%m%d%H%M)_screen.jpg
danvine / .laptop.local
Last active Aug 29, 2015
View .laptop.local
# curl > ~/.laptop.local
# sh mac 2>&1 | tee ~/laptop.log
brew_tap 'caskroom/cask'
brew tap 'caskroom/versions'
brew_install_or_upgrade 'brew-cask'
brew cask install 1password
View url2png.js
var API_KEY = "XXX";
var crypto = require('crypto');
var url2png = function() {
this.generateLink = function(url) {
var options = "?url="+url + "&viewport=1480x1037&thumbnail_max_width=500";
var token = crypto.createHash('md5').update(options + SECRET_KEY).digest('hex');
return ""+API_KEY+"/"+token+"/png/"+options;
danvine /
Created Apr 19, 2014
Simple bash workflow script for managing ever growing api documented using
#!/usr/bin/env bash
# Be sure to install the apiary gem;
# gem install apiary
# You'll need to get a token here;
# Your apiname here; docs.$
View timeout.rb
# Runs a specified shell command in a separate thread.
# If it exceeds the given timeout in seconds, kills it.
# Returns any output produced by the command (stdout or stderr) as a String.
# Uses to wait up to the tick length (in seconds) between
# checks on the command's status
# If you've got a cleaner way of doing this, I'd be interested to see it.
# If you think you can do it with Ruby's Timeout module, think again.
def run_with_timeout(command, timeout, tick)
output = ''
View gist:9679002
def generate_secure_s3_url(s3_key)
# s3_key would be a path (including filename) to the file like: "folder/subfolder/filename.jpg"
# but it should NOT contain the bucket name or a leading forward-slash
# this was built using these instructions:
s3_base_url = MyApp::Application::S3_BASE_URL # i.e.
import urllib
import hashlib
class Url2png(object):
def __init__(self, options):
self.apikey = 'PXXXX'
self.secret = 'SXXXX'
self.query_string = urllib.urlencode(options)
View url2png.rb
# place this file in _plugins/url2png.rb
# add this to your _config.yml
# url2png:
# apikey: <apikey>
# secret: <secret>
require 'liquid'
require 'cgi' unless defined?(CGI)
require 'digest' unless defined?(Digest)
You can’t perform that action at this time.