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
#!/bin/bash | |
# see https://stackoverflow.com/questions/59895 | |
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
BACKUP_ROOT=$SCRIPTDIR/backup | |
BACKUP_ROOT_USER=$BACKUP_ROOT/$USER | |
mkdir -p $BACKUP_ROOT_USER | |
BACKUP_ERROR_FILE=$BACKUP_ROOT_USER/error.log | |
function handle_error { |
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
#ifndef C_MOST_USEFUL_EXTENSION_EVER | |
#define C_MOST_USEFUL_EXTENSION_EVER | |
class _t{ | |
public: | |
static int _count; | |
_t(){}; | |
virtual ~_t(){}; | |
friend const void operator+(const int n, const _t t){_count=n;} | |
}; | |
int _t::_count=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
#include<stdio.h> | |
#define MAXSIZE 20 | |
volatile char counterarray[MAXSIZE] = {0}; | |
#define MAXDEPTH 10 | |
int depth=0; | |
int olddepth=0; | |
int searcher=0; | |
int searchermax[MAXDEPTH]; |
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
volatile char _A[19] = {0}; | |
#define _Y 10 | |
int _D=0,_O=0,_S=0,_M[_Y],_C[_Y],_L; | |
#define _ _C[_D] | |
#define times [_A]=1;_D++;_S=0;for(_S \ | |
=-1;_A[_S]==0;++_S){ _M \ | |
[_D]=_S+1;}_A[_S]=0;for \ | |
(_C[_D]=0;_O=_D,(_L=!!( \ | |
_C[_O]<_M[_O] )),_C[_O] \ | |
==_M[_O]?_D--: 1,_O=_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
def neighbours(a, x, y): | |
xs = [] | |
ys = [] | |
if x > 0: | |
xs.append(-1) | |
xs.append(0) | |
if x < len(a[0]) - 1: | |
xs.append(1) | |
if y > 0: | |
ys.append(-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
from random import random | |
import operator | |
def E_M(m): | |
"""Computes E(max(X_1,...,X_m)), where X_i ~ Uni(0,1)""" | |
return float(m)/(m+1) | |
def hire1(l): | |
"""Scans list l from left to right and hires i if l[i] is greater than | |
E(max(l[i+1],...,l[-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
" latex_helper.vim | |
python << EOP | |
import os | |
import os.path | |
import re | |
import codecs | |
import vim |
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 Data.List | |
import Maybe | |
-- taken from | |
-- http://www.haskell.org/haskellwiki/Prime_numbers_miscellaneous#Prime_Wheels | |
primes = 2:3:primes' | |
where | |
l:p:candidates = [6*k+r | k <- [0..], r <- [1,5]] | |
primes' = p : filter isPrime candidates | |
isPrime n = all (not . divides n) |
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
main(int a,char*s[]){int b[atoi(s[2])],*z=b,p;char*c=s[1],v,w;while(p=1, | |
*c){q('>',++z)q('<',--z)q('+',++*z)q('-',--*z)q('.',putchar(*z))q(',',*z | |
=getchar())if(*c=='['||*c==']'){v=*c,w=184-v;if(v<w?*z==0:*z!=0)while(p) | |
v<w?c++:c--,p+=*c==v?1:*c==w?-1:0;}c++;}}//gcc -D"q(a,b)"="*c-a||(b);" |
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
type Variable = String | |
data Term = Variable Variable | | |
Function String [Term] deriving Eq | |
instance Show Term where | |
show (Variable v) = v | |
show (Function f []) = f | |
show (Function f l) = f ++ (show l) | |
NewerOlder