Skip to content

Instantly share code, notes, and snippets.

@bos
bos / CRS.f
Created April 7, 2011 01:09
Sparse matrix-vector multiplication in Haskell and Fortran 77
! From http://netlib.org/linalg/html_templates/node98.html
!
! val: non-zero values from the matrix
! col_ind: indices into val at which columns start in successive rows
! row_ptr: indices into val at which successive rows start
for i = 1, n
y(i) = 0
for j = row_ptr(i), row_ptr(i+1) - 1
y(i) = y(i) + val(j) * x(col_ind(j))
@sebfisch
sebfisch / gist:931419
Created April 20, 2011 14:10
Type Safe Interpreter for Simple Functional Language in Haskell
This literate Haskell program implements a type safe interpreter for a
simple functional language. Such an interpreter is the "hello world"
example for dependently typed languages and this program mimics it in
Haskell. Generalized algebraic data types and type families are
sufficient.
> {-# LANGUAGE GADTs #-}
> {-# LANGUAGE TypeFamilies #-}
> {-# LANGUAGE TypeOperators #-}
> {-# LANGUAGE MultiParamTypeClasses #-}
@sathishmanohar
sathishmanohar / recover_grub_2.sh
Created May 21, 2012 17:15
Recovering GRUB 2 Boot Loader - Steps and Instructions
# This is text format of the instructions shown in the below Youtube video
# http://www.youtube.com/watch?v=ajs9rO5upZA
# First get a ubuntu Live CD or USB Stick and boot from it
# Check all the Hard disk and Partitions using following command
sudo fdisk -l # Now take a note of the partition, on which linux is installed which may be like: /dev/sda1
# 3. Mount the partition where you need to install GRUB 2 (Hard disk partition)
# Now the file system appears in nautaulis and command line is not file system of Hard disk
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@iamatypeofwalrus
iamatypeofwalrus / roll_ipython_in_aws.md
Last active January 22, 2024 11:18
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.

What

Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active July 7, 2024 19:32
A badass list of frontend development resources I collected over time.
@acdha
acdha / paramiko-using-ssh-config.py
Created July 23, 2013 17:16
Connecting with paramiko using the user's OpenSSH config
client = paramiko.SSHClient()
client._policy = paramiko.WarningPolicy()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_config = paramiko.SSHConfig()
user_config_file = os.path.expanduser("~/.ssh/config")
if os.path.exists(user_config_file):
with open(user_config_file) as f:
ssh_config.parse(f)
@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@tboggs
tboggs / dirichlet_plots.png
Last active July 10, 2024 13:49
A script to generate contour plots of Dirichlet distributions
dirichlet_plots.png
@syhw
syhw / dnn.py
Last active June 23, 2024 04:13
A simple deep neural network with or w/o dropout in one file.
"""
A deep neural network with or w/o dropout in one file.
License: Do What The Fuck You Want to Public License http://www.wtfpl.net/
"""
import numpy, theano, sys, math
from theano import tensor as T
from theano import shared
from theano.tensor.shared_randomstreams import RandomStreams