Skip to content

Instantly share code, notes, and snippets.

{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@greeness
greeness / gist:8363819
Created January 10, 2014 22:19
UFLDL - parameter initialization
{
"metadata": {
"celltoolbar": "Raw Cell Format",
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "Sparse AutoEncoder Part1"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@greeness
greeness / gist:8344890
Created January 10, 2014 00:39
Test ipython viewer against an octave run
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
### mac
```brew install gfortran
brew install r
brew install gsl
R> install.packages("BTYD", dependencies = TRUE)
```
### ubuntu
```sudo apt-get install libgsl0-dev```
@greeness
greeness / bdd
Last active December 19, 2015 18:09
Behavior driven development
http://net.tutsplus.com/tutorials/python-tutorials/behavior-driven-development-in-python/
Note: feature files needs newline at each "given", "when", etc (otherwise you get errors like below:)
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/lettuce/core.py", line 143, in __call__
ret = self.function(self.step, *args, **kw)
File "/Users/greeness/Documents/workspace/hehe/tests/features/steps.py", line 9, in compute_its_fatorial
world.number = factorial(world.number)
AttributeError: 'thread._local' object has no attribute 'number'
@greeness
greeness / gist:4273631
Created December 13, 2012 02:53
fast way of loading data into mysql table
cat mysql-statement
> insert into mytable (k, v) values (1,2);
> insert into mytable (k, v) values (2,2);
> insert into mytable (k, v) values (3,2);
scp mysql-statement to an ec2 machine
ssh to the ec2 machine
$ mysql -h hostname -u username -p password database_name < mysql-statement
@greeness
greeness / gist:4199796
Created December 4, 2012 01:46
iap purchase update
public UserIapModel Calculate(double? currentTotalIap,
double? currentElapsedHours,
double? currentPlayedTurns,
double newIap,
double newElapsedHours,
double newPlayedTurns)
{
// default setting for new users: spending $0.01 in every 24 hours or 10 turns
double totalIap = currentTotalIap ?? 0.01;
double totalElapsedHours = currentElapsedHours ?? 24;
@greeness
greeness / gist:4186012
Created December 2, 2012 00:02
hill_climb_params.py
import numpy as np
import copy
n_params = 5
upper_bound = 5
lower_bound = 0
def get_neighbors(solution):
neighbors = []
for i in range(n_params):