Skip to content

Instantly share code, notes, and snippets.

View VincentTam's full-sized avatar
🏀
Rolling around

Vincent Tam VincentTam

🏀
Rolling around
View GitHub Profile
@VincentTam
VincentTam / bday-prblm.c
Last active January 27, 2017 23:47
Catalan no. & Pascal Triangle use GNU MP
#include <stdio.h>
float myfct(int i) {
return i == 1? 1 : (366.0-i)/365.0*myfct(i - 1);
}
int main() {
int i;
double ans;
printf("Enter a value: ");
@VincentTam
VincentTam / sample-output.txt
Last active January 25, 2017 22:04
Octave script for French postal fee with min no. of stamps, run on http://octave-online.net/
Valeur de timbre (€) | Quantité
---------------------+---------
0.71 | 0
0.73 | 0
1.46 | 1
2.92 | 6
0.85 | 0
1.70 | 0
3.40 | 7
1.30 | 0
@VincentTam
VincentTam / .vimrc
Last active April 5, 2017 09:04
My VIMRC for Vim in Git for Windows
" Vundle settings
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=$HOME/vimfiles/bundle/Vundle.vim
"call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
call vundle#begin('$HOME/vimfiles/bundle/')
@VincentTam
VincentTam / .vimrc
Last active January 10, 2017 22:19
My VIMRC on USB
set nocompatible
filetype off
let iCanHazVundle=1
let vundle_readme=expand("~/.vim/bundle/vundle/README.md")
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
\documentclass[tikz]{standalone}
\usetikzlibrary{calc,through}
\begin{document}
\begin{tikzpicture}[scale = 2]
\coordinate [label=left:$O$] (O) at (0,0);
\coordinate [label=left:$L$] (L) at (0.7,1.1);
\coordinate [label=below:$S_n$] (Sn) at (0.6,0.7);
\coordinate (SqCorn1) at (0.2,0.6);
\coordinate (SqCorn2) at (1.2,1.6);
\coordinate (SqCorn3) at (1.2,0.6);
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw [fill] (0,0) circle [radius = 0.025];
\node [below] at (0,0) {$x$};
\draw (0,0) circle (1);
\draw (0,0) -- (120:1) node[pos=0.5,above] {$r$};
\draw [fill] (2,2) circle [radius = 0.025];
\node [below] at (2,2) {$y$};
\draw (2,2) circle (0.7);
@VincentTam
VincentTam / EulersCriterion.cpp
Created May 16, 2015 13:47
Programs related to number theory written in C++ when I was a high school student. I don't guarantee that they're error-free.
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <string.h>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
@VincentTam
VincentTam / test.cpp
Last active August 29, 2015 14:18
Calculate P(A > B) and P(A = B), where A and B are independent Poisson variables.
#include <iostream>
#include <cmath>
using namespace std;
double pXy(double x, double y, int N);
double pxy(double x, double y, int N);
int main(void) {
double pAb,paB,pab,a,b;
int N;
@VincentTam
VincentTam / _vimrc
Last active February 24, 2016 12:32
My VIMRC for GVim on M$ Win* 7
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
"behave mswin
set diffexpr=MyDiff()
function! MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
@VincentTam
VincentTam / .bash_aliases
Created December 15, 2014 09:57
My Bash Aliases
alias cp="cp -i"
alias lm="ls -al | more"
alias md="mkdir"
alias mv="mv -i"
alias rd="rmdir"
alias rm="rm -i"
alias xclip="xclip -selection c"