Skip to content

Instantly share code, notes, and snippets.

View felipecruz's full-sized avatar

Felipe Cruz felipecruz

  • Berlin, Germany
View GitHub Profile
@felipecruz
felipecruz / gurobi_cffi.py
Last active August 29, 2015 14:05
gurobi cffi interface major WIP
import cffi
GRB_EQUAL = 61
ffi = cffi.FFI()
ffi.cdef('''
typedef ... GRBenv;
typedef ... GRBmodel;
@felipecruz
felipecruz / kamikaze_trader.txt
Last active August 29, 2015 14:06
kamikaze trader
Profit é o lucro total e não lucro da operação.
Buy 5000 PETRF20 at: 0.140000
Buy 1000 PETRF18 at: 0.200000
Sell 1000 PETRF18 at: 0.220000
Profit: -20.000000
Buy 1200 PETRF18 at: 0.220000
Sell 5000 PETRF20 at: 0.230000
Profit: 390.000000
Buy 1300 PETRF16 at: 0.770000
@felipecruz
felipecruz / perceptron.cpp
Created November 19, 2014 04:28
Perceptron
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
class Perceptron {
vector<double> w;
double learning_rate;
bool error;
@felipecruz
felipecruz / linear_regression_hr.cpp
Last active September 22, 2015 14:46
cpp linear regression - no regularization
/* Author: felipe cruz felipecruz@gmail.com
*/
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <random>
@felipecruz
felipecruz / pyaio_example.py
Created October 21, 2010 20:18
experimental aio.h implementation for python
import pyaio
import time
def aio_callback(buf):
print 'python callback %s' % buf
#file name, offset, lenght, callback function
pyaio.aio_read('/tmp/b.txt', 10, 20, aio_callback)
static PyObject *
pyaio_write(PyObject *dummy, PyObject *args) {
const char *filename;
const char *buffer;
struct aiocb cb;
int ret, offset, numbytes;
Pyaio_cb *aio;
PyObject *result = NULL;
# Original WSGI application.
def application(environ, start_response):
...
# Logging WSGI middleware.
import pprint
class LoggingMiddleware:
# if you're on linux host, you need xvfb
sudo apt-get install xvfb
git clone git://github.com/felipecruz/jasmine-gem.git
cd jasmine-gem
git submodule init
git submodule update
gem install rails
gem install gem-release
gem install bundler
module Jasmine
class Config
# Add your overrides or custom config code here
def jasmine_xvfb
'xvfb-run --server-args="-screen 0 2000x1400x24"'
end
end
end
rake jasmine:phantomjsci