Skip to content

Instantly share code, notes, and snippets.

View jkassemi's full-sized avatar

James Kassemi jkassemi

View GitHub Profile
@jkassemi
jkassemi / gist:3797001
Created September 27, 2012 23:09
Select2.js capybara
def select2_select(text, options)
page.find("#s2id_#{options[:from]} a").click
page.all("ul.select2-results li").each do |e|
if e.text == text
e.click
return
end
end
end

Description

Dashing widget to show the build status of a CircleCI project.

Usage

  • Get a Circle API Token from your Account Dashboard and set it in your environment as CIRCLE_CI_AUTH_TOKEN
  • Add the httparty to your Gemfile and run bundle install

Then:

@jkassemi
jkassemi / gist:7034805
Created October 18, 2013 00:47
Watch files, make. Easy.
# https://news.ycombinator.com/item?id=6568137
inotifywait -m -e modify,close_write,move,move_self,create,delete,delete_self -r . | while read; do make; done
@jkassemi
jkassemi / gist:7621426
Created November 23, 2013 23:39
Server / Client Form Validation - Reminder
1) Render content for page
2) Parse form contents from page before delivery, parse validation fields, save, sign, inject content
3) Validate signature on validation content on form, validate according to HTML form validation rules.
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.22 (Darwin)
hQIMAw+MY6dm20KGAQ//ZKHiKW1q9Teo3C66GvVV2jPbfyI+XhTKnAnJQe6uHCtn
tNBw8qjbfADGqaEkX/drrWBhLeiuYaE1EzkNj9dxrLy1Z2ZoX8tT8U/uKpyIpZXZ
KBtY++g7vnJJPMJ90f8MEyEqejzggXFjwGkhVaV9e1b1KFq8YOJjLVKd2tGTctia
RZUC2wZGBAGvUcuHxvX4cTKUwENgnNUqZRLLO6X4YvZCtpNdIoxbipFc9ENeZgGw
ApDwOJIDcFVI+dEu661pqUBRok4+dQiQ6PLMNNTIfHQ3898lFuYkrYm2bGA0Z5VK
mSUP4HiYL9zNq0hzRmpDjyccXRhH7pJw5RbGYVEOVetMM86tLZPkul7IbHJ0wErO
MSYw3nZK5lwQPcjMPJugTpzy/f7pPWeK8qthsBX/I71gF0rx9QEatgm5kEEeq6So
@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
@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: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 / 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: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.