This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from numpy import * | |
| # The Matrix! | |
| x = matrix([ | |
| [1,6,0,0,0,0], | |
| [1,1,5,0,0,0], | |
| [1,1,1,4,0,0], | |
| [1,1,1,1,3,0], | |
| [1,1,1,1,1,2], | |
| [1,1,1,1,1,1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Source: http://stackoverflow.com/questions/11671731/in-r-how-can-i-make-a-running-count-of-runs | |
| x <- data.frame(end.group=c(0,0,1,0,0,1,1,0,0,0,1,1,1,0,1)) | |
| # create groups | |
| x$group <- rev(cumsum(rev(x$end.group))) | |
| # re-number groups from smallest to largest | |
| x$group <- abs(x$group-max(x$group)-1) | |
| x$group.count <- ave(x$end.group, x$group, FUN=seq_along) | |
| # Even Better: http://stackoverflow.com/questions/9961700/how-to-partition-when-ranking-on-a-particular-column |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| marriage is a long-term contract | |
| and if u put it in nominal terms | |
| by eating recklessly, | |
| he is shortening the benefits of this contract |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| class Lint(defaultdict): | |
| def __init__(self, item): | |
| super(Lint, self).__init__(int) | |
| if isinstance(item, int) or isinstance(item, long): | |
| st = str(item)[::-1] | |
| d = {i: int(st[i]) for i in xrange(len(st))} | |
| elif isinstance(item, dict): | |
| d = item | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Start R Grading Helper | |
| # ========================== | |
| # === Global Variables === | |
| # ========================== | |
| folder <- "/Users/dfeng/Downloads/Grading" | |
| roster_filename <- "ml_roster.csv" | |
| grade_filename <- "ml_hw.csv" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass{article} | |
| \usepackage[pdftex,active,tightpage]{preview} | |
| \setlength\PreviewBorder{2mm} | |
| \usepackage{tikz} | |
| \usetikzlibrary{positioning, calc} | |
| % \usepackage[minionint, loosequotes, swash]{MinionPro} | |
| % \usepackage{lmodern} | |
| \renewcommand{\familydefault}{\sfdefault} | |
| \begin{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @namespace url(http://www.w3.org/1999/xhtml); | |
| @-moz-document domain('reddit.com') { | |
| body{ | |
| background:#1a1a1a; | |
| color:#ddd | |
| } | |
| .comment .usertext .md p>a:visited,.md a,.res.res-nightmode .tagline a,a,h2 a:visited{ | |
| color:#3498db; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function gists() { | |
| /usr/local/bin/gist $1 | sed s/gist.github/rawgit/ | sed s/.com/.com\\\/dfeng/ | sed -e "s/$/\\/raw\/$1/" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #main-window .tab-close-button { display:none!important; } | |
| #tabbrowser-tabs ~ #alltabs-button { display:none!important; } | |
| .tabbrowser-tabs[treestyletab-mode="vertical"] | |
| .tabbrowser-arrowscrollbox > scrollbox { | |
| overflow-y: hidden !important; | |
| } | |
| /*.tabbrowser-tabs[treestyletab-mode="vertical"] | |
| .tabbrowser-tab { |