Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
@oleganza
oleganza / gist:10458460
Created April 11, 2014 11:00
js password generator
// Based on oi.js by Dan Kaminsky https://gist.github.com/PaulCapestany/6148566
var base58alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
function millis() { return Date.now(); }
function flip_coin() { n=0; then = millis()+1; while(millis()<=then) { n=!n; } return n; }
function get_fair_bit() { while(1) { a=flip_coin(); if(a!=flip_coin()) { return(a); } } }
function get_random_6bit(){ n=0; bits=6; while(bits--){ n<<=1; n|=get_fair_bit(); } return n; }
function get_password(length) {
var password = "";
var offset = 0; // offset allows us to go through the infinite alphabet thus minimizing bias towards lower characters.
@simenbrekken
simenbrekken / flux-test-complex.js
Last active August 29, 2015 14:02
React Flux Multiple Stores test
'use strict';
var EventEmitter = require('events').EventEmitter
var util = require('util')
var Promise = require('bluebird')
var keyMirror = require('react/lib/keyMirror')
var merge = require('react/lib/merge')
var request = require('../build/modules/httpRequest')
var config = require('../build/modules/config')
anonymous
anonymous / config.json
Created May 30, 2015 13:28
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
anonymous
anonymous / config.json
Created May 30, 2015 12:20
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
anonymous
anonymous / config.json
Created June 16, 2015 17:56
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@s4y
s4y / curried.js
Created February 7, 2015 21:02
Tiny curry
function curried(fn) {
function curry() {
if (arguments.length >= fn.length) {
return fn.apply(this, arguments);
}
var args = arguments;
return function() {
return curry.apply(
null, Array.prototype.concat.apply(
Array.prototype.slice.call(args), arguments)
@dchest
dchest / multitouch.rkt
Created November 28, 2010 11:59
Example of using multitouch on a Mac in Racket
#lang racket
; Ported from http://pb.lericson.se/p/FpbYhX/
(require ffi/unsafe
ffi/unsafe/atomic)
(define libmulti (ffi-lib "/System/Library/PrivateFrameworks/MultitouchSupport.framework/MultitouchSupport"))
(define CFArrayRef _pointer)
@dchest
dchest / goswitch
Created April 8, 2011 18:00
Switch between two different installations of Go
#!/bin/sh
#
# Switch between two different installations of Go:
#
# source goswitch dev
# ^ makes GOROOT ~/Sources/go
#
# source goswitch prod
# ^ makes GOROOT ~/go
@dchest
dchest / docgo
Created April 13, 2011 02:31
docgo - Runs godoc with the current path and opens browser (on a Mac).
#!/bin/sh
#
# Runs godoc with the current path and opens browser (on a Mac).
#
godoc -http=":8888" -path="." 2> /dev/null &
pid=$!
trap 'kill $pid' INT
open "http://localhost:8888"
@dchest
dchest / gist:3777526
Created September 24, 2012 18:36
FourDolphins!
#include <stdint.h>
#include <stdio.h>
/* Permutations of {0, ..., 15} */
static const uint8_t SIGMA[14][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },