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 com.apple.screencapture 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}' http://chunk.io 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
danvine / .laptop.local
Last active Aug 29, 2015
.laptop.local
View .laptop.local
#!/bin/sh
# curl https://gist.githubusercontent.com/danvine/5bf13971980126853964/raw > ~/.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 SECRET_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 "http://api.url2png.com/v6/"+API_KEY+"/"+token+"/png/"+options;
@danvine
danvine / preview.sh
Created Apr 19, 2014
Simple bash workflow script for managing ever growing api documented using blueprintapi.org
View preview.sh
#!/usr/bin/env bash
# Be sure to install the apiary gem; https://github.com/apiaryio/apiary-client
# gem install apiary
# You'll need to get a token here; https://login.apiary.io/tokens
APIARY_API_KEY=
# Your apiname here; docs.$APINAME.apiary.io
APINAME=
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 Kernel.select 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:
# http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?S3_QSAuth.html
# http://aws.amazon.com/code/199?_encoding=UTF8&jiveRedirect=1
s3_base_url = MyApp::Application::S3_BASE_URL # i.e. https://mybucket.s3.amazonaws.com
View url2png.py
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.