Skip to content

Instantly share code, notes, and snippets.

@pkyeck
pkyeck / gist:5757161
Created June 11, 2013 14:11
clickable "sass watch" command
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@pkyeck
pkyeck / gist:5318298
Last active December 15, 2015 20:28
GIT colors
[color]
ui = always
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold

Code Style

  • Space indentation (2 spaces)
  • Double-quotes
  • Semicolon
  • Strict mode
  • No trailing whitespace
  • Variables at the top of the scope
  • Multiple variable statements
  • Space after keywords and between arguments and operators
@pkyeck
pkyeck / gist:2020764
Created March 12, 2012 08:47
ios background thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
/* do your copying here */
dispatch_async(dispatch_get_main_queue(), ^{
/* anything in here will happen on the main thread after the background thread has finished copying. For example, update your UI. */
});
});
@pkyeck
pkyeck / sha256.js
Created February 17, 2014 10:12
creating two different sha256 hashes
var crypto = require("crypto");
var hash1 = crypto.createHash("sha256");
hash1.update("topsecret", "utf8");
console.log(hash1.digest("base64")); // UzNqZ2xkwTllU7K3yS84EmdognyTtk2RQgacEO2npyE=
var hash2 = crypto.createHash("sha256");
hash2.update("topSecret", "utf8");
console.log(hash2.digest("base64")); // mFuUzsUvYbRLt21+34+fwP6IpapAhqBLsbycLnGfQIc=
@pkyeck
pkyeck / retrieving.js
Last active August 29, 2015 13:56
Storing and retrieving secure passwords
var crypto = require("crypto");
// user submitted form with email + pwd
var pwd = req.params.pwd;
// fetch result from DB ...
// retrieve hash from DB and compare to pwd
var result = <RESULT>;