Skip to content

Instantly share code, notes, and snippets.

@micheleorsi
micheleorsi / Dockerfile
Created February 26, 2017 16:55
Automation in Google Cloud for Kubernetes cluster: terraform + kargo
FROM ubuntu:xenial
MAINTAINER "Michele Orsi <me@micheleorsi.it>"
# ansible
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-add-repository ppa:ansible/ansible
RUN apt-get update
RUN apt-get install -y ansible
@micheleorsi
micheleorsi / stock_trading_example.py
Created October 10, 2016 09:09
Machine Learning with Python for Algorithmic Trading
import numpy as np
import pandas as pd
from pandas_datareader import data as web
from sklearn import linear_model
class ScikitBacktest(object):
def __init__(self,sys):
self.lags = 5
self.symbol = sys
self.get_data()
@micheleorsi
micheleorsi / README.md
Last active August 30, 2015 15:54
Topojson reference
ogr2ogr -f "GeoJSON" california_geojson.json tl_2010_06_zcta510.shp
topojson -o california_topojson.json california_geojson.json

convert counties and zipcode shapefiles to GeoJson

ogr2ogr -f "GeoJSON" working/counties.geo.json assets/ca/counties.shp
ogr2ogr -f "GeoJSON" working/zipcodes.geo.json source/tl_2010_06_zcta510.shp

# merge two shapefils
@micheleorsi
micheleorsi / Prepare raspberry for usage with docker.md
Last active September 18, 2016 09:50
Running docker on ARM processor (tested on Raspberry Pi 2 Model B)

Flash image to SD card

This is a list of disk images to flash on SD card in order to natively run docker on your Raspberry: hypriot download page:

From command line:

flash --hostname <host-name> <url-to-download-the-os-from>
public boolean solution(int[] A) {
if(isArrayInNonDecreasingOrder(A)) {
return true;
}
for(int i=0; i<A.length; i++) {
for(int j=0; j < A.length; j++) {
if(i!=j) {
int[] testArray = A.clone();
int tempValue = testArray[i];
testArray[i]=testArray[j];
@micheleorsi
micheleorsi / docker
Last active September 29, 2015 15:00
Quick reference for personal needs
# Remove all stopped containers.
docker rm $(docker ps -a -q)
# Remove all untagged images
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
[global]
workgroup = WORKGROUP
server string = %h server
wins support = yes
@micheleorsi
micheleorsi / _etc_logstash_conf.d_central.conf
Created January 22, 2015 10:48
Logstash configuration with Google App Engine logs
input {
file {
type => "gae"
path => ["/home/ubuntu/gae_logs/**/*log"]
tags => ["some","tags"]
stat_interval => 30
discover_interval => 180
}
}
@micheleorsi
micheleorsi / crontab
Last active August 29, 2015 14:13
Download logs from Google App Engine with appcfg tool
# REQUEST NORMAL LOGS
# once a day at 23:50
50 23 * * * <full-path>/appcfg.py -A <gae-application-name> -M <module-name> -V <version-name> --oauth2 --include_all --append -n 1 request_logs <full-path>/`date +\%y-\%m-\%d`.log
# REQUEST LOGS WITH WARNING AND SEVERE INFOS
# once a day at 23:50
50 23 * * * <full-path>/appcfg.py -A <gae-application-name> -M <module-name> -V <version-name> --oauth2 --include_all --append -n 1 --severity=2 request_logs <full-path>/`date +\%y-\%m-\%d`-full.log
@micheleorsi
micheleorsi / nginx.conf
Created January 22, 2015 10:36
configuration file to proxy and cache requests from a backend
worker_processes 4;
events {
worker_connections 1024;
}
http {
##
# Basic Settings