This file contains 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
\def\reftextcurrent {} | |
\newrefformat{fig}{Fig.~\ref{#1}\vpageref{#1}} | |
\newrefformat{par}{Section~\ref{#1}\vpageref{#1}} | |
\newrefformat{sec}{Section~\ref{#1}\vpageref{#1}} | |
\newrefformat{sub}{Section~\ref{#1}\vpageref{#1}} | |
\newrefformat{table}{Table~\ref{#1}\vpageref{#1}} | |
\newrefformat{alg}{Algorithm~\ref{#1}\vpageref{#1}} | |
\newrefformat{chap}{Chapter~\ref{#1}} | |
\newrefformat{eq}{equation~\eqref{#1}} |
This file contains 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
\begin{tikzpicture} | |
\coordinate (root) {} | |
child[level distance=8em, sibling distance=8em] { | |
node (A) {$X$} | |
edge from parent node[left] {$0.1$} | |
} | |
child[level distance=4em] { | |
coordinate {} | |
child { | |
node {$Y$} |
This file contains 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
import Control.Arrow | |
data Trie a = Trie (Maybe a) [(Char, Trie a)] deriving Show | |
find :: Trie a -> String -> Maybe a | |
find (Trie v _) [] = v | |
find (Trie v ts) (c:cs) = case lookup c ts of | |
Just t -> find t cs | |
Nothing -> Nothing |
This file contains 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
import qualified Data.HashMap.Lazy as M -- from unordered-containers | |
firstNonRep :: String -> Char | |
firstNonRep = | |
head . M.keys . M.filter (==1) . M.fromListWith (+) . map (\c -> (c,1)) | |
main = print $ firstNonRep "aabcbcdeef" == 'd' |
This file contains 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
// gcc --std=c99 trigraph.c -o test && ./test | |
#include <stdio.h> | |
int main(int argc, const char *argv[]) | |
{ | |
int x = 1; | |
// what is going on here??/ | |
x = 0; |
This file contains 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
" Highlight Function names. From | |
" http://stackoverflow.com/questions/736701/class-function-names-highlighting-in-vim/773392#773392 | |
syn match cCustomParen "(" contains=cParen contains=cCppParen | |
syn match cCustomFunc "\w\+\s*(" contains=cCustomParen | |
hi def link cCustomFunc Function | |
hi Function term=bold gui=bold |
This file contains 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 http://vim.wikia.com/wiki/VimTip857 | |
function! TextEnableCodeSnip(filetype, start, end, textSnipHl) | |
let ft=toupper(a:filetype) | |
let group='textGroup'.ft | |
if exists('b:current_syntax') | |
let s:current_syntax=b:current_syntax | |
" Remove current syntax definition, as some syntax files (e.g. cpp.vim) | |
" do nothing if b:current_syntax is defined. | |
unlet b:current_syntax | |
endif |
This file contains 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
#returns current path, but shortens it if it's longer than $COLUMNS/4, so that | |
# /usr/share/doc/foo would become /u…/s…/d…/foo | |
# Usage: PS1="\u@\h \$(_dynpath) \$ " | |
_dynpath() | |
{ | |
CURR="${PWD/#$HOME/~}" | |
MAX_WIDTH=$(($COLUMNS/4)) | |
while [[ ${#CURR} -gt $MAX_WIDTH && $CURR =~ /.[^…].*/ ]] ; do |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from os import * | |
from os.path import * | |
from sys import exit | |
homedir = environ["HOME"] | |
dotfiles = join(homedir, ".dotfiles") |
This file contains 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
#include <mpi.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#define SIZE 4 | |
int main(int argc, char *argv[]) | |
{ | |
int rank, size; // for storing this process' rank, and the number of processes |