Skip to content

Instantly share code, notes, and snippets.

James Duncombe jamesduncombe

Block or report user

Report or block jamesduncombe

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
@jamesduncombe
jamesduncombe / config.ru
Last active Nov 13, 2018
Sinatra basic setup
View config.ru
# Mock app for Timber.io
# Ruby v2.2.1p85
# Sinatra v1.4.7
# Started with just `rackup`
require 'bundler'
Bundler.require
require 'json'
@jamesduncombe
jamesduncombe / amnesia.sh
Last active Mar 20, 2017
Amnesia.io bash alias
View amnesia.sh
amn() {
if [ $# -ge 1 -a ! -f $1 ]; then
input=$(cat -)
temp=$(mktemp)
echo $input > $temp
curl -sF "file=@$temp;filename=xyz.$1" https://amnesia.io
rm $temp
elif [ $# -ge 1 -a -f $1 ]; then
curl -sF "file=@$1" https://amnesia.io
else
@jamesduncombe
jamesduncombe / sample new mailbox response.json
Last active May 23, 2016
Sample response for new mailbox - Letterb.in
View sample new mailbox response.json
{
"email": ":bin_public_id@letterb.in",
"bin_url": "https://letterb.in/m/:bin"
}
@jamesduncombe
jamesduncombe / letterbin - stream download attachments.sh
Created May 21, 2016
Letterb.in - Stream downloading attachments
View letterbin - stream download attachments.sh
curl -s https://letterb.in/m/:bin_key/stream --no-buffer | jq --unbuffered --raw-output '.attachments[0].data' | xargs -I {} open "https://letterb.in/{}"
View curl download - letterbin.sh
curl https://letterb.in/m/$(curl -s https://letterb.in/m/:bin/json | jq -r '.[0].attachments[0].data') > mydownload
@jamesduncombe
jamesduncombe / sample response.json
Last active May 23, 2016
Sample letterb.in JSON response
View sample response.json
[
{
"to": "2LrV4qq@letterb.in",
"text": "The text version of the email if it exists or an empty string",
"subject": "Test",
"received": "2016-04-29T14:26:24Z",
"raw_mime": "raw_mime/bf7900f6d3077859ba649ad5b4556512e8de7fc…",
"original_html": "Unmodified HTML from the email OR the raw text version (liable to change)",
"id": "a3e2b1e0-cd13-48a8-bd51-abcf5c99f137",
"html": "Modified HTML of the email - all attachments that were inlined are changed to <img> tags etc",
@jamesduncombe
jamesduncombe / vaultoro api signature.exs
Last active May 5, 2016
Function for generating the API signature for Vaultoro's API - https://api.vaultoro.com
View vaultoro api signature.exs
defmodule Vaultoro do
@doc """
secret = The Vaultoro secret generated along with your API key
endpoint = The full URL that you are requesting (with all params) e.g: https://api.vaultoro.com/1/balance?nonce=9&apikey=_MY_API_KEY_
"""
def signature(secret, endpoint) do
:crypto.hmac(:sha256, secret, endpoint)
|> Base.encode16(case: :lower)
end
@jamesduncombe
jamesduncombe / svgripper.rb
Last active Mar 30, 2016
Quick and dirty SVG icon spriter
View svgripper.rb
#!/usr/bin/env ruby
#
# Sprites SVG icons into a single output
#
# Sample output which you'd put in the page:
#
# <svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="display: none;">
# <symbol id="icon-name" viewBox="0 0 76.7 89.6">
# <path d="M71.2,28.1c-3,0-5.5,2.5-5.5" />
# </symbol>
View .docker-aliases
alias dc="docker"
alias dr="dc run"
alias ds="dc stop"
alias di="dc images"
alias drmi="dc rmi"
alias drm="dc rm"
alias dip="dc inspect -f '{{ .NetworkSettings.IPAddress }}'"
@jamesduncombe
jamesduncombe / haversine.sql
Last active Aug 29, 2015
Haversine formula in SQL
View haversine.sql
/*
6371 for Kms
3956 for Miles
$lat, $lng are passed in
*/
SELECT *,
( 3956 * acos( cos(radians($lat)) * cos(radians( lat.field_latitude_value )) *
cos(radians( lng.field_longitude_value ) - radians($lng)) + sin(radians($lat))
* sin(radians( lat.field_latitude_value )) ) )
You can’t perform that action at this time.