Skip to content

Instantly share code, notes, and snippets.

View jonathanmarvens's full-sized avatar

Jonathan Barronville jonathanmarvens

View GitHub Profile
@jonathanmarvens
jonathanmarvens / pgm.lex
Created November 28, 2012 07:45 — forked from dwf/pgm.lex
A lexer for portable graymap (PGM) files. Use lex or flex to compile into C code.
/* Scanner that reads in a Portable Graymap (PGM) file.
*
* By David Warde-Farley -- user AT cs dot toronto dot edu (user = dwf)
* Redistributable under the terms of the 3-clause BSD license
* (see http://www.opensource.org/licenses/bsd-license.php for details)
*/
enum { PRE_START, PARSE_START, GOT_X, GOT_Y, GOT_MAX } parserstate
= PRE_START;
@jonathanmarvens
jonathanmarvens / pgm.lex
Created November 28, 2012 07:45 — forked from dwf/pgm.lex
A lexer for portable graymap (PGM) files. Use lex or flex to compile into C code.
/* Scanner that reads in a Portable Graymap (PGM) file.
*
* By David Warde-Farley -- user AT cs dot toronto dot edu (user = dwf)
* Redistributable under the terms of the 3-clause BSD license
* (see http://www.opensource.org/licenses/bsd-license.php for details)
*/
enum { PRE_START, PARSE_START, GOT_X, GOT_Y, GOT_MAX } parserstate
= PRE_START;
function ClosurePattern() {
this.someMethod = function someMethod() {
console.log('foo');
}
}
var closurePattern = new ClosurePattern();
def isBalanced (string):
if isinstance(string, basestring) is False:
return True
STRUCTURE_OPN = 1
STRUCTURE_CLS = 2
structures = {
'(': (')', STRUCTURE_OPN),
')': ('(', STRUCTURE_CLS),
/* See:
http://bit.ly/WhXvb3
for the Traceur */
var foo = [9, 9, 9],
bar = [2, 2, 2],
baz = [1, 1, ...foo, 1, 1, ...bar, 1, 1];
console.log(baz);
/* Output: 1,1,9,9,9,1,1,2,2,2,1,1 */
Create separate SSH key for your personal account and your company. Named them with different extensions in your .ssh folder. Upload them to your github account and finally create a config file for your SSH
Create a config file in ~/.ssh/
vim config:
# PERSONAL ACCOUNT Github
Host github.com-COOL
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_COOL

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@jonathanmarvens
jonathanmarvens / javascript-string-format.js
Last active December 12, 2015 12:39
This function extends String adding minimal *printf-like* functionality.
String.prototype.format = function (format_object) {
// TODO: Find better way to do this. Works great for now.
// I don't know how efficient this is, but it works.
var string_current = this.valueOf();
var string_new = '';
var format_matches = string_current.match(/\%\([a-zA-Z0-9_]+\)/g); // Definitely has edge cases.
var replace_object = {};
if (format_matches.length > 0) {
@jonathanmarvens
jonathanmarvens / binary_search.js
Created March 14, 2013 09:11
Binary search in multiple languages...
function binarySearch (key, array) {
var low = 0;
var high = (array.length - 1);
while (low <= high) {
var mid = floor(((low + high) / 2));
var val = array[mid];
if (val < key) {
low = (mid + 1);
@jonathanmarvens
jonathanmarvens / integer-to-binary.js
Created March 19, 2013 01:28
Convert an integer to its binary representation using a simple stack-based algorithm.
function integer_to_binary ( integer ) {
if ( ( toString.call( integer ) !== '[object Number]' ) || ( integer < 0 ) ) {
return null;
} else if ( integer === 0 ) {
return '0';
} else {
var stack = [];
// var STACK_CAPACITY = 8;