Skip to content

Instantly share code, notes, and snippets.

View bsima's full-sized avatar
drinking coffee

Ben Sima bsima

drinking coffee
View GitHub Profile
@bsima
bsima / immutant-ubuntu-setup.sh
Last active August 29, 2015 14:04
Immutant Ubuntu Setup
# Shamelessly stolen from http://marianoguerra.org/posts/install-immutant-10-full-as-a-service-on-debianubuntu.html
# and updated with new Immutant versions.
#
# This is executable, so you can simply curl and execute it
# install needed packages
sudo apt-get install wget unzip openjdk-7-jdk daemon
# create a dir to download files
mkdir ~/soft
@bsima
bsima / Gruntfile
Last active August 29, 2015 14:07
Grunt task(s) for compiling SASS and autoprefixing
/**
* Grunt task(s) for compiling SASS and autoprefixing
*
* To use:
*
* npm install grunt --save-dev
* npm install grunt-contrib-sass --save-dev
* npm install grunt-autoprefixer --save-dev
* npm install grunt-contrib-watch --save-dev
* curl --output Gruntfile.js https://gist.github.com/bsima/a30dd43ccc5ffed7922a/download
@bsima
bsima / books.org
Last active August 29, 2015 14:09
books to buy.

Books to buy:

roughly in order of priority

@bsima
bsima / main.py
Last active August 29, 2015 14:09
ocr thing
dictionary = {
' _ | ||_|': 0,
' | |': 1,
' _ _||_ ': 2,
' _ _| _|': 3,
' |_| |': 4,
' _ |_ _|': 5,
' _ |_ |_|': 6,
' _ | |': 7,
' _ |_||_|': 8,
;;; The Bolzmann formula for entropy as a measure of molecular disorder.
;;;
;;; Consider a container partitioned into two equal volumes. The number of ways,
;;; P, in which N molecules can be divided into two groups, N1 and N2, is given by
;;; the simple combinatorial formula
;;;
;;; P = N! / N1! N2!
;;;
;;; in which N! = N(N-1)(N-2)...3*2*1. The quantity P is called the "number of
;;; complections" (see Landau and Lifschitz, 1968) [p. 10]
top -o cpu -O +rsize -s 5 -n 20
Sort the processes according to CPU usage (descending) and
resident memory size (ascending), sample and update the display
at 5 second intervals, and limit the display to 20 processes.
top -c d Run top in delta mode.
top -stats pid,command,cpu,th,pstate,time
Display only the specified statistics, regardless of any growth of
the terminal. If the terminal is too small, only the statistics

Compinvesti-prog-quiz

ref: http://wiki.quantsoftware.org/index.php?title=Compinvesti-prog-quiz

General Programming

Here's a self test you can take to see if you have strong programming skills. For each of these questions, feel free to use your programming language of choice. The questions are progressively more challenging:

  1. Write a program to generate 100 random integers between 1 and 100. It should generate exactly the same numbers each time you run it. Bonus: If you wonder whether the distribution should be normal or uniform, give yourself extra points.
% Say you have a matrix and you want to quickly understand what the
% data distribution looks like.
% The following snippet will do the trick.
A = magic(5) % create a random matrix
imagesc(A), colorbar, colormap grey;
% This will create a greyscale image of the values of the matrix, with
% each number corresponding to a different value of grey. It will also
@bsima
bsima / boot-project.clj
Last active August 29, 2015 14:10
Sometimes you want to use boot as a scripting platform on top of Leinengen. Paste this code at the top of your build.boot file. It reads in the project.clj file and stores it as a map named "project" which you can then use with `set-env!` to setup your environment.
(set-env! :dependencies '[[leiningen-core "2.5.0"]])
(use 'leiningen.core.project)
(eval (read-string (slurp "project.clj")))
(set-env!
:source-paths (:source-paths project)
:resource-paths (:resource-paths project)
:dependencies (:dependencies project))
@bsima
bsima / s3.json
Last active August 29, 2015 14:10
Permissions policy for AWS S3-hosted static websites
{
"Version": "2008-10-17",
"Statement": [{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mybucketname/*"