Skip to content

Instantly share code, notes, and snippets.

@codeswimmer
codeswimmer / random-range.js
Last active August 29, 2015 13:56
js: get a random integer within a specific range
function getRandomIntWithinRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@codeswimmer
codeswimmer / git-clone-specific-branch.md
Created February 9, 2014 15:33
git: clone a specific branch
git clone -b branch remote_repo
@codeswimmer
codeswimmer / git-revert-to-previous-commit-sha.md
Last active August 29, 2015 13:56
git: revert to previous commit sha
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch "file"' --prune-empty -- --all
@codeswimmer
codeswimmer / git_push_to_existing_repo.md
Created January 8, 2014 14:47
git: How to push to existing repo
  1. Create the remote repository, and get the URL
    If your local GIT repo is already set up, skips steps 2 and 3

  2. Locally, at the root directory of your source, git init

  3. Locally, add and commit what you want in your initial repo (for everything, git add . git commit -m 'initial commit comment')

  4. To attach your remote repo with the name 'origin' (like cloning would do) git remote add origin [URL From Step 1]

http://channel9.msdn.com/coding4fun/articles/Project-Detroit-How-to-Read-Your-Cars-Engine-Data-with-OBD-II
@codeswimmer
codeswimmer / .gitconfig
Last active December 21, 2015 15:49
my .gitconfig file
[color "diff"]
meta = blue black bold
ui = true
[core]
editor = mate -w
[github]
user = codeswimmer
token = a99dfdd250ec9af4352a1c416cede0e8
[push]
default = simple
@codeswimmer
codeswimmer / js_parser_example.js
Created March 17, 2013 00:19
JS: Parser example
$.tablesorter.addParser({
id:'stormtimestr',
is:function (s) {
return false;
},
format:function (s) {
if (s.search('All time') != -1) {
return 1000000000;
}
var total = 0;
@codeswimmer
codeswimmer / ycombinator.clj
Created March 6, 2013 20:33 — forked from z5h/ycombinator.clj
Applicative-Order Y Combinator (Clojure Version)
; Stumbling towards Y (Clojure Version)
;
; (this tutorial can be cut & pasted into your IDE / editor)
;
; The applicative-order Y combinator is a function that allows one to create a
; recursive function without using define.
; This may seem strange, because usually a recursive function has to call
; itself, and thus relies on itself having been defined.
;
; Regardless, here we will stumble towards the implementation of the Y combinator.
@codeswimmer
codeswimmer / shadow.sh
Created January 25, 2013 03:37
bash: unmount SSD drive
#!/bin/sh
diskutil umount /Volumes/ShadowSSD/
// NSMutableArray_Shuffling.h
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#include <Cocoa/Cocoa.h>
#endif
// This category enhances NSMutableArray by providing
// methods to randomly shuffle the elements.