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
;;; 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/*"
//Setting the position of the Glastonbury map marker.
var markerPositionGlastonbury = new google.maps.LatLng(51.159803, -2.585585);
//Setting the icon to be used with the Glastonbury map marker.
var markerIconGlastonbury = {
url: 'icons/icon_glas_uk.png',
//The size image file.
size: new google.maps.Size(225, 120),
//The point on the image to measure the anchor from. 0, 0 is the top left.
origin: new google.maps.Point(0, 0),

Regarding this /r/clojure thread

How would such a generator work? First, relevant quotes on the bootstrapping process, from the boot wiki

The bootstrapping process can be expressed in terms of input and output:

FuserBOOTSTRAPJcp + Fcp + Fasset + E

Book the First -- Recalled to Life
Chapter I
The Period
It was the best of times, it was the worst of times, it was the age of
wisdom, it was the age of foolishness, it was the epoch of belief, it
was the epoch of incredulity, it was the season of Light, it was the
season of Darkness, it was the spring of hope, it was the winter of
The sample text is here: https://gist.github.com/0474c33e403ab243019c
Undo justification: replace all newline characters with two spaces
regex: "\n\b"
subst: "\ \ "
Replace all paragraph markers with actual paragraphs
regex: "-P-"