Skip to content

Instantly share code, notes, and snippets.

View bensie's full-sized avatar

James Miller bensie

View GitHub Profile
@enlight
enlight / electron-squirell.windows.txt
Last active March 10, 2016 16:35
Using Electron auto-updater with Squirrel.Windows
From #electron Slack
weiway:
Hi guys, I'm really confused by autoUpdater API on windows. On one hand, I believe windows autoUpdater
has an uniform API with OSX, but on the other hand, I know squirrel handles OSX and Windows quite differently.
So my question is do I need to handle to squirrel events? Or I ONLY need to use the autoUpdater events to
handle update logic?
On windows
And also I'm confused when squirrel handles install and when squirrel handles update. If write install logic
into main.js, does that mean every time my app starts squirrel will try to re-install?
@alex-roman
alex-roman / openresty-ubuntu-install.sh
Last active February 28, 2023 14:19
Easy install openresty (used and tested on Ubuntu 14.04, 15.10 and 16.04)
#!/bin/bash
apt-get -y update
apt-get -y install nginx-extras build-essential libpcre3-dev libssl-dev libgeoip-dev libpq-dev libxslt1-dev libgd2-xpm-dev
wget -c https://openresty.org/download/openresty-1.13.6.2.tar.gz
tar zxvf openresty-1.13.6.2.tar.gz
cd openresty-1.13.6.2
./configure \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
@rayrutjes
rayrutjes / detectcontenttype.go
Created December 12, 2015 13:36
golang detect content type of a file
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
// Only the first 512 bytes are used to sniff the content type.
buffer := make([]byte, 512)
_, err = file.Read(buffer)
if err != nil {
@sdieunidou
sdieunidou / rabbitmq.txt
Created October 22, 2015 19:51
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
@nz
nz / oauth lite.md
Last active October 3, 2023 07:46
Light weight HMAC token auth over HTTP Basic Auth

HMAC over Basic Auth

This is a pattern I use fairly frequently for administrative APIs. It's a sort of OAuth lite for non-public APIs that produces good quality tokens. Once you build it a few times, it's not any harder than using arbitrary basic auth in your APIs.

The client and the app share a secret, which is never transmitted across the wire. The client uses this secret to create an HMAC digest of a payload consisting of the current time and a random nonce value. The nonce is provided as the Basic Authorization user, and the resulting HMAC digest is provided as the Basic Authorization password.

A similar process is followed on the server side. The server uses the supplied nonce, its own time, and its own copy of the shared secret. It may want to check against several tokens across a small window of times to account for clock drift.

  • Using HMAC means the secret is never transmitted across the wire. Theoretically these are safe across plaintext connections, but you're using TLS anyway, right?
  • The i
@csabapalfi
csabapalfi / rename.sh
Created January 8, 2015 19:48
Rename JPEGs to match Dropbox format
jhead -n%Y-%m-%d\ %H.%M%.%S *.jpg
@rgcottrell
rgcottrell / gist:5b876d9c5eea4c9e411c
Created September 21, 2014 17:38
An FM Synthesizer in Swift using AVAudioEngine
import AVFoundation
import Foundation
// The maximum number of audio buffers in flight. Setting to two allows one
// buffer to be played while the next is being written.
private let kInFlightAudioBuffers: Int = 2
// The number of audio samples per buffer. A lower value reduces latency for
// changes but requires more processing but increases the risk of being unable
// to fill the buffers in time. A setting of 1024 represents about 23ms of
@simenbrekken
simenbrekken / KeyboardShortcutsMixin.js
Created August 31, 2014 08:15
React Keyboard Shortcuts Mixin
'use strict';
var KEYS = {
enter: 13,
left: 37,
right: 39,
escape: 27,
backspace: 8,
comma: 188,
shift: 16,
@seven1m
seven1m / fix_find_all.rb
Last active August 29, 2015 14:04
Fix old Rails 1.x finder syntax.
#!/usr/bin/env ruby
# A script to convert old Rails 1.x finder syntax, e.g. find(:all, ...) and find(:first, ...)
# to use where() and friends.
# gem install parser unparser
# cd path/to/rails_app
# ruby fix_find_by.rb
require 'parser/current'
@rodleviton
rodleviton / imagemagick-install-steps
Created May 26, 2014 07:37
Installing Image Magick on Ubuntu 14.04
sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall