Skip to content

Instantly share code, notes, and snippets.

@tsterker
tsterker / mermaid-gannt.css
Created September 16, 2020 12:02
mermaid-gannt.css
.grid .tick {
stroke: lightgrey;
opacity: 0.3;
shape-rendering: crispEdges;
}
.grid path {
stroke-width: 0;
}
#tag {
void drawFaceNormals()
{
glColor3f(0,0,1); // The colour we will be drawing is white (red = 1, green = 1, blue = 1).
vector<vec3> verts = trig.Vertices();
vector<vec3> fnorms = trig.FaceNormals();
vec3 fnorm, pos, from, to;
glBegin(GL_LINES);
for(int i = 0; i < fnorms.size(); i++){
1) tabs to spaces
:set tabstop=4 shiftwidth=4 expandtab
:retab
2) Whitespace found at end of line
:%s/^M\+$//g
:%s/\s\+$//g
NOTE: ^M must be inserted using CTRL-v RETURN
@tsterker
tsterker / fancyhdr_template.tex
Created August 9, 2012 19:38
[LaTeX] fancyhdr template
\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\fancyhf{}
\rhead{\bfseries\nouppercase\leftmark}
\cfoot{\bfseries\thepage}
@tsterker
tsterker / ex1.py
Created December 21, 2011 01:15 — forked from gorlum0/ex1.py
[py] ml-class - ex1
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
from numpy import newaxis, r_, c_, mat
from numpy.linalg import *
def plotData(X, y):
plt.plot(X, y, 'rx', markersize=7)
plt.ylabel('Profit in $10,000s')
plt.xlabel('Population of City in 10,000s')
@tsterker
tsterker / multlin.py
Created December 21, 2011 01:14 — forked from marcelcaraciolo/multlin.py
[py] multivariate linear regression
def feature_normalize(X):
'''
Returns a normalized version of X where
the mean value of each feature is 0 and the standard deviation
is 1. This is often a good preprocessing step to do when
working with learning algorithms.
'''
mean_r = []
std_r = []
@tsterker
tsterker / linregr.py
Created December 21, 2011 01:12 — forked from marcelcaraciolo/linregr.py
[py] linear regression
#Evaluate the linear regression
def compute_cost(X, y, theta):
'''
Comput cost for linear regression
'''
#Number of training samples
m = y.size
predictions = X.dot(theta).flatten()
@tsterker
tsterker / Evolution of a Python programmer.py
Created December 21, 2011 00:58
[py] programmer levels
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@tsterker
tsterker / file_sizeof.c
Created December 20, 2011 22:47
[c] Get filesize
/* Returns file size in BYTES */
int file_sizeof(FILE *fp)
{
int filesize;
fseek(fp, 0L, SEEK_END); /* jump to end of file */
filesize = ftell(fp); /* current byte of file == f
@tsterker
tsterker / circle.py
Created November 27, 2011 02:00
[py] circle in pyglet
def circle(x, y, radius):
iterations = int(2*radius*pi)
s = sin(2*pi / iterations)
c = cos(2*pi / iterations)
dx, dy = radius, 0
glBegin(GL_TRIANGLE_FAN)
glVertex2f(x, y)
for i in range(iterations+1):