Skip to content

Instantly share code, notes, and snippets.

View jkassemi's full-sized avatar

James Kassemi jkassemi

View GitHub Profile
@jkassemi
jkassemi / keybase.md
Created September 19, 2016 21:54
keybase.md

Keybase proof

I hereby claim:

  • I am jkassemi on github.
  • I am jkassemi (https://keybase.io/jkassemi) on keybase.
  • I have a public key whose fingerprint is 5AC3 6838 AECB 93B3 02AF CB44 1B6C 0CFD 9886 AD90

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am jkassemi on github.
  • I am jkassemi (https://keybase.io/jkassemi) on keybase.
  • I have a public key whose fingerprint is 1A60 ADBC 9D51 9E9E 8C99 ECCA 6CAF 0166 3F85 16DA

To claim this, I am signing this object:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQINBFRL/sABEACiG2Bq+GPE5WlfPkHLDvrIRNxlmB6wGEnhchwfvPE63Z5cOlaa
jLs9VqQ6wptIuUpRe9mq7RqBSN5oWBhymo2vZaYM4PfbzZRsBJlbBzjcACQ8BNG1
xSbb1+Ba/Cx449hFxar4khFQBsR2yfB2dTn2YXXirXORPvvReUA0rA3gozCRrh56
ui/u4Y3Qi9NhzsHTxzKvg4cJAjAh30NFO/1urx35d8Pacs3dYZFLvEQ6+hdSFY3X
TbIvHyJ/WiB3BkGCge5hCankyuqPZibzH3907pPvc1+Q/dWY670r8ADIKnXNgGOC
ybO56IZsv+I61bAZJboPOnTAn2/Elv5kpet4+1WaXOfLPEaqAwz/f7dqkwhnvI5a
unQuv185IODOR46JxC1beZO8jAWgzKqDvlmzORiTMARwWxehW38scuM+cmeCRzp6
### Keybase proof
I hereby claim:
* I am jkassemi on github.
* I am jkassemi (https://keybase.io/jkassemi) on keybase.
* I have a public key whose fingerprint is E7F4 E74B 770F 2674 0B7C 9D8E 45D9 6E63 99C3 1CF0
To claim this, I am signing this object:
require 'rubygems'
require 'httpi' # Use whatever http system you've already started using
require 'json'
require 'openssl'
require 'oj'
class Signature
class << self
def signature(rails_request)
payload = "https://dashboard.atpay.com/email_transactions/" +
@jkassemi
jkassemi / gist:8641384
Last active January 4, 2016 15:29
JKSR: Signing url-form-encoded messages

Standardization On: Signing url-form-encoded messages

UPDATE: Please see http://self-issued.info/docs/draft-jones-json-web-token-06.html and the implementation here https://github.com/progrium/ruby-jwt for another method for JSON specific requests.

(if you run into this post and are about to use a different method that doesn't pose any particular benefit, use this one - post an alternative if there's a benefit!)

PROBLEM

When a third party is given the option of sending a url-form-encoded request containing a signature value, we need a method of signing all keys and values as well as a signature, without the inclusion of the signature itself in the hash.

@jkassemi
jkassemi / fun.go
Created January 22, 2014 06:07
Just messing around with some conceptualization of stuff I find myself randomly reading.
/*
The classification of contempts as direct and indirect is merely a semantic device for
differentiating contempts that can be adjudicated summarily from those that can be adjudicated
only after adequate notice and hearing. When a contempt occurs within the "immediate view and
presence of the court" the judge is fully informed of all facts necessary to adjudicate the guilt or
innocence of the alleged contemner. When, however, the court is not so informed of such facts,
notice and hearing are necessary to get them....
In stating that "The failure of an attorney, without valid excuse, to be present... constitutes...
a direct contempt"... the majority opinion itself implicitly concedes that petitioner's contempt, if
@jkassemi
jkassemi / gist:8265426
Created January 5, 2014 07:19
Run until all or condition met
drain := make(chan bool, len(tasks))
answer := make(chan interface{}, 1)
drained := make(chan bool, 1)
for _, v := range tasks {
go func(){
defer func(){
drain <- true
}()
@jkassemi
jkassemi / gist:8193250
Created December 31, 2013 06:09
Run at most every X
loner = (fn, delay)->
lastRun = new Date()
timeout = null
runner = ->
args = arguments
clearTimeout(timeout) if timeout
wait = delay - (new Date() - lastRun)
@jkassemi
jkassemi / gist:7746307
Created December 2, 2013 07:40
Drone delivery range - RE: Amazon
Given
1) A drone can carry a recharge load for another drone
2) A drone can fly 2*X distance before a recharge
3) A drone must leave point A, reach point B, and return to point A.
If distance AB < X then no recharge is required.
If distance AB == 2X then
Drone 1 flies to <X
Drone 2 flies to <X, charges Drone 1, returns to A