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 / sublime-config
Created April 8, 2015 20:24
Sublime Text 3 Configurations
http://martineau.tv/2014/07/sublime-text-for-front-end-development/
http://www.sitepoint.com/10-essential-sublime-text-plugins-full-stack-developer/
http://ipestov.com/the-best-plugins-for-sublime-text/
https://css-tricks.com/sublime-text-front-end-developers/
Package Control
SublimeLinter https://github.com/SublimeLinter/SublimeLinter-jshint
scsslint https://packagecontrol.io/packages/SublimeLinter-contrib-scss-lint
& jshint are particularly useful.
@Ajwah
Ajwah / sml-testing.sml
Last active August 29, 2015 14:20
Basic template to run unit tests in SML
use "johnson_hw.sml";
val name_hw = "2005 - Assignment Two"
(*Unit tests are of format string*bool where bool is represented by evaluation of a function to an expected value*)
val tests = [
];
print ("\n"^Int.toString(List.length(tests))^" TOTAL TESTS RUN----------------------"^name_hw^"--------------------------\n"); (*Name display to assert correct test file is running*)
fun all_tests(tests) =
@Ajwah
Ajwah / print_int_lst.sml
Last active August 29, 2015 14:21
Print int list
val l2s = List.foldl (fn(e,acc)=> acc^" "^Int.toString(e)) ""
val ll2s = List.foldl (fn(e,acc)=>acc^"\n "^(l2s e)) ""
fun display [] = (print "\n END")
| display (l::lls) = (print ("\n "^(l2s l)); display lls)
@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)
@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 / 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 / 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 / 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 / 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 / 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: