Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
@jeremyBanks
jeremyBanks / expanded.md
Created June 22, 2010 05:10
one-line self-executing c header and expanded explanation
//

Since we don't want this visible in C, we put it in a comment.

&>/dev/null

Unfortunately // is interpreted as an invalid shell command and produces an error message, so we need to redirect that to /dev/null to get rid of it.

;x="${0%.*}"
@sanxiyn
sanxiyn / lisp.c
Created August 14, 2010 04:16
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
@mathiasbynens
mathiasbynens / setZeroTimeout.js
Created September 14, 2010 22:23
Cross-browser-compatible setZeroTimeout
/*! Cross-browser-compatible setZeroTimeout
*
* I took the original setZeroTimeout and made it cross-browser-compatible, using setTimeout(fn, 0) as a fallback in case postMessage is not supported.
* Mathias Bynens <http://mathiasbynens.be/>
* See <http://mathiasbynens.be/notes/settimeout-onload>
*
* Copyright statement below:
*
* See <http://dbaron.org/log/20100309-faster-timeouts>
* By L. David Baron <dbaron@dbaron.org>, 2010-03-07, 2010-03-09

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@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 / multitouch.rkt
Created November 28, 2010 13:25
Apple's multitouch with demo (run using gracket)
#lang racket/gui
; 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)
@briancavalier
briancavalier / simple-promise-retry.js
Created February 24, 2011 18:35
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@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"
@vrotaru
vrotaru / Base58.java
Created February 6, 2012 18:30
Base58 encoding an decoding
package core;
public class Base58 {
private static final char[] ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
.toCharArray();
private static final int BASE_58 = ALPHABET.length;
private static final int BASE_256 = 256;
private static final int[] INDEXES = new int[128];