Skip to content

Instantly share code, notes, and snippets.

View psychocandy's full-sized avatar

Amir Friedman psychocandy

  • Berlin, Germany
View GitHub Profile
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@psychocandy
psychocandy / git-unmerged
Last active December 12, 2015 00:08 — forked from antirez/gist:4554824
#!/usr/bin/tclsh8.5
#
# Install: clone and copy to somewhere in your $PATH, e.g:
# git clone https://gist.github.com/4681074.git git-unmerged && cd git-unmerged && chmod +x git-unmerged && sudo mv git-unmerged /usr/bin && cd .. && rm -rf git-unmerged
# Usage: git-unmerged branch1 branch2
#
# Shows all the non-common commits in the two branches, where non-common
# commits means simply commits with a unique commit *message*.
proc getlog branch {
@psychocandy
psychocandy / mock_tire.rb
Created October 18, 2012 10:58 — forked from dvdplm/mock_tire.rb
Mocking helper to stop Tire from submitting searches to Elasticsearch
module Tire
module Disable
module ClassMethods
def mock_es_response_doc
@mock_es_response_doc ||=
'{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 0,"max_score": null,"hits": []}}'
end
def enable! &blk
old_enabled = @tire_enabled || false
@psychocandy
psychocandy / test.rb
Created July 13, 2012 19:51 — forked from Constellation/test.rb
Extracting id from a crx package
require 'crxmake'
require 'digest/sha2'
# generate id from pem
def generate_id pkey
key = CrxMake::KEY + pkey.public_key.to_der
id = Digest::SHA256.hexdigest(key)
id[0..32].split('').map{|ch| ('a'.ord + ch.hex).chr }.join('')
end