Skip to content

Instantly share code, notes, and snippets.

View liy's full-sized avatar
🏠
Working from home

liy liy

🏠
Working from home
View GitHub Profile
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-color.md
Last active August 29, 2022 15:54
GLSL color functions

RGB - YUB

mat3 yuv2rgb = mat3(1.0, 0.0, 1.28033, 1.0, -0.21482, -0.38059, 1.0, 2.12798, 0.0);
mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722, -0.09991, -0.33609, 0.43600, 0.615, -0.5586, -0.05639);

RGB - HSV

@mattt
mattt / UTTypeForImageData.m
Created March 27, 2014 23:19
A quick function for determining an image's file type by its first couple of bytes
@import MobileCoreServices;
static CFStringRef UTTypeForImageData(NSData *data) {
const unsigned char * bytes = [data bytes];
if (data.length >= 8) {
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) {
return kUTTypePNG;
}
}
@tomykaira
tomykaira / git-rebase--interactive-full.sh
Created September 27, 2012 14:24
Specify rebase comment in git-rebase-todo instantly. \\ in the comment will be replaced with \n on commit.
#!/bin/sh
#
# Copyright (c) 2006 Johannes E. Schindelin
# SHORT DESCRIPTION
#
# This script makes it easy to fix up commits in the middle of a series,
# and rearrange commits.
#
# The original idea comes from Eric W. Biederman, in
@ishida
ishida / gist:2719962
Created May 17, 2012 16:21
change alias in keystore using keytool
$ keytool -changealias -keystore MY_KEYSTORE_2.jks -alias XXX-XXX-XXX-XXX-XXX -destalias MY_ALIAS
@sandfox
sandfox / CertificateGeneration.sh
Created February 15, 2012 00:11
TLS certificate inspection example (using nodejs)
###
#Step 1 - Generate server certificates etc... (most of this code is horribly ripped off from nodejs docs currently -> http://nodejs.org/docs/latest/api/tls.html)
###
#Assuming your starting from a clean directory
mkdir server
cd server
#generate private key
@rorydriscoll
rorydriscoll / Shader.glsl
Created November 26, 2011 00:14
Shader experiment
// bind gloss {label:"Gloss", default:0.5, max:1, step:0.01}
// bind cdiff {label:"Diffuse Colour", r:0.6, g:0.0, b:0.0}
// bind cspec {label:"Specular Colour", r:0.3, g:0.3, b:0.3}
// bind lightstrength {label:"Light Strength", default:3, max:100, step:0.1}
// bind envtop {label:"Environment Top", r:0.0, g:0.2, b:0.4}
// bind envmiddle {label:"Environment Middle", r:0.2, g:0.2, b:0.2}
// bind envbottom {label:"Environment Bottom", r:0.01, g:0.1, b:0.01}
// bind refractiveindex {label:"Refracive Index", default:1.5, max:3, step:0.1}
// bind normalmap {label:"Normal Map", default:false}
// bind diffuse {label:"Diffuse", default:true}
@Rio517
Rio517 / elasticsearch.yml
Created September 28, 2011 17:22
elasticsearch configuration fail
#/usr/local/elasticsearch/elasticsearch-0.17.7/logger.yml/elasticsearch.yml
# The cluster name
cluster.name: traceful_elasticsearch
cloud:
aws:
access_key: AKIAIPILOGJA7ORIBDNQ
secret_key: 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
@artero
artero / launch_sublime_from_terminal.markdown
Last active May 15, 2024 03:38 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt