Skip to content

Instantly share code, notes, and snippets.

View PaulCapestany's full-sized avatar

Paul Capestany PaulCapestany

View GitHub Profile
@jgarzik
jgarzik / paychanproto.md
Last active August 29, 2015 13:57
Payment channel JSON-RPC protocol

This protocol describes a simple payment channel protocol, such as the one presented in https://en.bitcoin.it/wiki/Contracts#Example_7:_Rapidly-adjusted_.28micro.29payments_to_a_pre-determined_party

JSON-RPC methods shown here may be sent via HTTPS or stratum protocol. It is easily adaptable to protocol buffers or another favored marshalling method.

Open channel

Client requests a public key. Server responds with a public key (K2). K2, converted to a bitcoin address, forms the unique identifier for this payment channel. Each public key returned must be unique.

@oleganza
oleganza / filter-api-diff.rb
Created June 5, 2014 06:10
Strip away "method->property" updates from iOS/OSX API diffs
# Oleg Andreev @oleganza
#
# This is a script that strips away all lines about converting methods to properties.
# Filtered file is easier to read to find what's new.
#
# 1. Save html file with API diff.
# 2. Run filter-api-diff.rb <name-of-the-file.html>
# 3. Open <name-of-the-file.html>-filtered.html in Safari.
#
# This script adds absolute URLs for stylesheets, no worries about them.
@felixrabe
felixrabe / s
Last active August 29, 2015 14:03
Reliable subl wrapper
#!/usr/bin/env bash
if [[ $# -eq 0 ]] ; then
subl -w . &
else
subl -w "$@" &
fi
sleep 1
kill $!
=baselined-font($font-size, $cap-ratio, $bottom-space-ratio)
$cap-height: $font-size * $cap-ratio
$top-space-ratio: 1 - $cap-ratio - $bottom-space-ratio
$top-to-bottom-space-ratio: $top-space-ratio / $bottom-space-ratio
// TODO: Depending on fontsize, increase line height. Allow some control
// of this via an arg.
$line-height: ((ceil($font-size/$baseline) * $baseline))
top-space-ratio: $top-space-ratio
top-space-height: ($line-height - $cap-height) * $top-space-ratio
@ianblenke
ianblenke / add-xfleet-conflicts.sh
Created March 10, 2015 18:56
Fix fleet's naive unit count based scheduling of deis application units by resubmitting fleet units with an X-Fleet Conflicts glob
#!/bin/bash -e
tmpdir=/tmp/add-xfleet-conflicts
mkdir -p $tmpdir
fleetctl list-units -fields=unit -no-legend | grep -v -e '@\|deis' | cut -d. -f1-2 | sort | uniq | while read name ; do
max=$(fleetctl list-machines -no-legend | wc -l)
count=$(fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | wc -l)
fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | sort -n | while read service; do
tmpfile=$tmpdir/$service
fleetctl cat $service >| $tmpfile
if ! grep X-Fleet $tmpfile > /dev/null; then
@scole-scea
scole-scea / systemd-reload.service
Last active August 29, 2015 14:17
Systemd reload hack for fleet
[Unit]
Description=Systemd Reload Hack for coreos fleet
After=fleet.service
# So: comments outside the script part itself, so I don't exceed
# command line length.
#
# The point here is to detect services which are stuck in "not-found"
# state when they shouldn't be. This failure originates from
# fleet-submitted unit files, so we try hard not to affect units
@afterthought
afterthought / host-dynamic-service-prod.tf
Created September 10, 2015 18:44
Dynamic ASG setup using kubernetes
resource "aws_autoscaling_group" "dynamic-service-prod" {
name = "${var.platform_prefix}-dynamic-services-production"
# Network
availability_zones = ["${split(\",\", var.availability_zones)}"]
vpc_zone_identifier = ["${split(\",\", var.private_subnet_ids)}"]
# Cluster Size
max_size = 12
min_size = 1
// static var to store shared date formatter
static NSDateFormatter *_formatter = nil;
@implementation NSDate (Extras)
// Simple comparison, create a string from today and date, see if they're the same
- (BOOL)isToday
{
// Lazy load and cache formatter, date formatters are slow to init
if (!_formatter)
@cspickert
cspickert / Search Xcode Documentation.applescript
Created April 26, 2012 16:36
Jump to the documentation search field in Xcode 4 using AppleScript.
#!/usr/bin/osascript
-- Jump to the documentation search field in Xcode 4's Organizer
-- To use, make sure "Enable access for assistive devices" is enabled in the Universal Access pref pane
tell application "System Events"
tell process "Xcode"
-- Activate Xcode if necessary
set frontmost to true
@joerussbowman
joerussbowman / gist:3639754
Created September 5, 2012 16:48
apache parsing script
package main
import (
"bufio"
"bytes"
"compress/gzip"
"flag"
"fmt"
"io"
"log"