Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

#!/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
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 August 29, 2015 14:27
.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
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 April 19, 2014 15:20
Simple bash workflow script for managing ever growing api documented using blueprintapi.org
#!/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=
# 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 = ''
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
import urllib
import hashlib
class Url2png(object):
def __init__(self, options):
self.apikey = 'PXXXX'
self.secret = 'SXXXX'
self.query_string = urllib.urlencode(options)
# 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)

Custom CSS

Embed your own CSS in the target page.

Sample

Direct Link