This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
#!/bin/bash | |
GITREPO=ssh://haldean@haldean.org/srv/dotfiles.git | |
APT_PACKAGES='emacs awesome zsh biblatex texlive-latex-extra emacs-goodies-el' | |
BREW_PACKAGES= | |
cd | |
HOMEDIR=`pwd` | |
GITDIR=$HOMEDIR/.dotfiles |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
def gen_toc(html, ignore_h1_in_toc=False): | |
if ignore_h1_in_toc: | |
first_level = 2 | |
else: | |
first_level = 1 | |
soup = BeautifulSoup.BeautifulSoup(html) | |
headers = soup.findAll(re.compile('^h[%d-6]' % first_level)) | |
output = [] | |
for header in headers: |
for (int k=0; k<20; k++) { | |
for (int i=1; i<N+1; i++) { | |
for (int j=1; j<N+1; j++) { | |
if (!m_has_fluid(i, j)) continue; | |
int adj_fluid_cells = 0; | |
scalar p = pressure(i, j); | |
pressure(i, j) = div(i, j); | |
if (!m_has_solid(i-1, j)) { |
void StableFluidsSimWithMarkers::project( | |
int N, ArrayXs * u, ArrayXs * v, ArrayXs * u0, ArrayXs * v0) { | |
// Set velocities on solid boundaries to zero | |
zeroSolidBoundaries(u, v); | |
// Compute discrete divergence on velocity field | |
ArrayXs div(N+1, N+1); | |
div.setZero(); | |
for (int i=1; i<N; i++) { |
#!/usr/bin/env pypy | |
a = ord('a') | |
for offset in range(26): | |
print ''.join( | |
map(lambda char: chr((ord(char) - a + offset) % 26 + a), 'umqra')) |
# Testing results (lower number is faster): | |
# while True while 1 | |
# pypy 1.7.0: 0.0733 0.0201 | |
# cpython 2.7.1 0.146 0.109 | |
# cpython 3.2.2 2.79 2.72 | |
loops = 10000 | |
trials = 1000 | |
def while_True(): |
float safeDiv(float a, float b) { | |
if (abs(a) < 1e-10 && abs(b) < 1e-10) return 0; | |
else return a / b; | |
} | |
float b(vector<float> kn, int i, int n, float t) { | |
if (n == 0) { | |
return (kn[i] <= t < kn[i+1]) ? 1 : 0; | |
} | |
return |
- (Mesh)generateMesh { | |
int numRings = [spine count]; | |
/* Triangles in the cylinder */ | |
int triCount = 2 * (numRings - 1) * SEGMENTS_IN_CIRCLE; | |
/* Triangles in flat end cap (m - 2 triangles required for an m-gon) */ | |
triCount += 2 * SEGMENTS_IN_CIRCLE - 4; | |
Mesh* result = (Mesh*) malloc(sizeof(Mesh)); | |
/* 3 verteces for each triangle */ |
\input{latex_template.tex} | |
\title{Astrophysics Final Exam} | |
\begin{document} | |
\maketitle | |
\section{Helium-burning stars} | |
\begin{enumerate} | |
\item To find the energy liberated in the reaction, we must find the mass lost | |
in the reaction, then use $E=mc^2$ to find the equivalent quantity of energy | |
released. |