Skip to content

Instantly share code, notes, and snippets.

View masukomi's full-sized avatar

masukomi (a.k.a. Kay Rhodes) masukomi

View GitHub Profile

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@masukomi
masukomi / pr.md
Created March 26, 2013 18:20 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@masukomi
masukomi / spreadsheet_float_test.rb
Created April 25, 2013 15:00
a simple shell script to expose a bug in the spreadsheet gem
#!/usr/bin/env ruby
# it expects you're going to pass it the spreadsheet found here
# http://masukomi.org/misc/spreadsheet_float_test.xls
raise "Needs a path argument" unless ARGV[0]
require 'spreadsheet'
file_path = ARGV[0]
Spreadsheet.client_encoding = 'UTF-8'
@masukomi
masukomi / bad_dwolla_sig_validator.rb
Created June 1, 2013 18:35
a failed attempt at a method that validates dwolla signatures
# This is a failed attempt to validate the signuature Dwolla passes back with
# a payment as described under *Dwolla's Signature on this page:
# https://developers.dwolla.com/dev/pages/button#configuration
Class Foo
def self.valid_dwolla_signature?(proposed_signature, checkout_id, amount)
require 'base64'
require 'openssl'
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@masukomi
masukomi / git_push_without_checkout.txt
Last active August 29, 2015 14:03
attempting to push to a git repo without doing a checkout
# first create a bare repo
git init --bare test_origin.git
# now create a repo that will push to it
git init test_1
Initialized empty Git repository in /Users/masukomi/workspace/temp/test_1/.git/
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()
;;;; pretty-literals.lisp - pretty hash table & vector literal syntax
;;;; inspired by and uses code from http://frank.kank.net/essays/hash.html
(in-package #:pretty-literals)
;; vector literal syntax using brackets
(set-macro-character #\[
(lambda (str char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil))

Found here by Stephan Farestam

Here is a bash-only YAML parser that leverages sed and awk to parse simple yaml files:

function parse_yaml {
   local prefix=$2
   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
   sed -ne "s|^\($s\):|\1|" \
        -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \

-e "s|^($s)($w)$s:$s(.*)$s$|\1$fs\2$fs\3|p" $1 |