Skip to content

Instantly share code, notes, and snippets.

View Ajwah's full-sized avatar

Kevin Johnson Ajwah

  • Toronto, Canada
View GitHub Profile
@Ajwah
Ajwah / google.styleguide
Created August 23, 2015 03:41
Google Style Guide Javascript - Interesting Discussions
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
http://benalman.com/news/2012/05/multiple-var-statements-javascript/
https://www.reddit.com/r/javascript/comments/15m252/best_javascript_coding_style_guide_i_have_found/
http://blog.founddrama.net/2010/08/annotated-google-javascript-style-guide/
Single quotes versus double:
http://stackoverflow.com/questions/242813/when-to-use-double-or-single-quotes-in-javascript
http://www.2ality.com/2012/09/javascript-quotes.html
@Ajwah
Ajwah / gist:9d7015d73e92cc8ec3be
Created July 17, 2015 19:32
referential transparency
A spot of code is referentially transparent when it can be substituted for its evaluated value without changing the behavior of the program.
https://github.com/DrBoolean/mostly-adequate-guide/blob/master/ch3.md
@Ajwah
Ajwah / constant.js
Created July 17, 2015 19:17
Create Constant
https://github.com/DrBoolean/mostly-adequate-guide/blob/master/ch3.md
var immutableState = Object.freeze({
minimum: 21
});
@Ajwah
Ajwah / recent_commits_move
Last active August 29, 2015 14:24
[Git] Move Recent Commits To New Branch
git log --> obtain commit id
git branch newbranch
git reset --hard a1b2c3d4
(git checkout newbranch) if need be
http://stackoverflow.com/questions/1628563/move-the-most-recent-commits-to-a-new-branch-with-git
Two push issues:
1) On master when doing push you get following error:
@Ajwah
Ajwah / shortcuts
Created July 7, 2015 06:36
Sublime Text - Handy Shortcuts
BOOKMARK
Toggle: CMD F2
Next: F2
GOTO
Functions etc: CMD R
EDIT NAVIGATION
PREV EDIT: CMD SHFT OPT K
NEXT EDIT: CMD SHFT OPT J
@Ajwah
Ajwah / format_string_with_namedtuple
Created July 3, 2015 22:31
Usage of namedtuple to format a string
Score = namedtuple("Score", 'Id W L D')
p1s = Score(p1, 1, 0, 0)
p2s = Score(p2, 0, 1, 0)
c.execute("update players set wins = wins + {0.W}, losses = losses + {0.L}, draws = draws + {0.D} where id={0.Id}".format(p1s))
@Ajwah
Ajwah / git_fatal_pathspec
Created June 29, 2015 05:30
Git: fatal: Pathspec is in submodule
https://stackoverflow.com/questions/24472596/git-fatal-pathspec-is-in-submodule/24473037#24473037
Problem:
I was unable to commit changes to a repository I cloned as a subdirectory to my existing project directory.
✘ ☪  ~/Documents/Python   master±  git add fullstack/vagrant/forum/*.*
fatal: Pathspec 'fullstack/vagrant/forum/forum.py' is in submodule 'Python/fullstack'
In this case, Python is the main project directory I would commit to github.
fullstack is a repo I cloned from udacity as a subdirectory.
@Ajwah
Ajwah / undo_latest_push
Created May 23, 2015 06:43
Delete latest commit pushed to remote
http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html
git push origin +2f90b076c3c8349adca4883497a24aed4d8d4a54^:master
@Ajwah
Ajwah / convert_cards2string.sml
Created May 16, 2015 04:12
Convert (suit*rank) to string
fun c2s (s,r) =
let val r = Int.toString r
in case s of
Spade => " (Spade,"^r^")"
| Heart => " (Heart,"^r^")"
| Diamond => " (Diamond,"^r^")"
| Club => " (Club,"^r^")"
end
fun cl2s lst = List.foldl (fn(c,acc)=> acc^(c2s c)) "" lst
@Ajwah
Ajwah / quicksort.sml
Created May 14, 2015 12:31
efficient quicksort implementation
(*Source: http://www.webber-labs.com/mpl/source%20code/Chapter%20Twelve/quicksort.sml.txt *)
fun quicksort nil = nil
| quicksort (pivot :: rest) =
let
fun split(nil) = (nil,nil)
| split(x :: xs) =
let
val (below, above) = split(xs)
in
if x < pivot then (x :: below, above)