Skip to content

Instantly share code, notes, and snippets.

View umitanuki's full-sized avatar

Hitoshi Harada umitanuki

  • Alpaca
  • California
View GitHub Profile
@umitanuki
umitanuki / MLP.py
Created August 2, 2018 22:30
blog-mlp-scripts
import argparse
import sys
import tempfile
from time import time
import random
from os import listdir
from os.path import isfile, join
import pandas
import matplotlib.pyplot as plt
from datetime import datetime
import alpaca_trade_api as tradeapi
import numpy as np
from positionhandling import positionHandler
import loader
api = tradeapi.REST()
@umitanuki
umitanuki / turtle.py
Created March 22, 2016 21:23
Turtle in quantopian
# For this example, we're going to write a simple momentum script.
# When the stock goes up quickly, we're going to buy;
# when it goes down we're going to sell.
# Hopefully we'll ride the waves.
from collections import deque
import math
import talib
atr = ta.ATR(timeperiod=20) # used to calculate 20-day ATR
@umitanuki
umitanuki / multicast.go
Last active December 21, 2015 15:29
Multicast replies in unicast
package main
import "log"
import "net"
import "os"
var gaddr *net.UDPAddr = &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254), Port: 12345}
func listener(c chan int) {
logger := log.New(os.Stdout, "[L]", log.Ltime | log.Lshortfile)
conn, err := net.ListenMulticastUDP("udp", nil, gaddr)
PROG = run
OBJS = main.o
all: $(PROG)
$(PROG): $(OBJS)
$(CC) -o $(PROG) $(OBJS)
clean:
rm -f $(PROG) $(OBJS)
@umitanuki
umitanuki / Makefile
Created April 29, 2013 16:47
Attempt to cause EINTER but read is not interrupted by signal...
PROG = run
OBJS = main.o
all: $(PROG)
$(PROG): $(OBJS)
$(CC) -o $(PROG) $(OBJS)
clean:
rm -f $(OBJS) $(PROG)
@umitanuki
umitanuki / create 1000 inherit table.sql
Created June 14, 2011 06:11
create 1000 inherit table
do $$ declare declare begin for i in 1 .. 1000 loop execute 'create table myt' || i || '(check (id between ' || (i * 99) || ' and ' || (i * 100) || ' )) inherits(size_m)'; end loop; end; $$;
@umitanuki
umitanuki / pg-config.sh
Created May 25, 2011 08:42
run configure wrapper
#!/bin/bash
VERSION=`pwd | perl -ne 's/.+postgresql-([^\/]+).*/$1/;print'`
./configure CC="ccache gcc" CFLAGS=-pthread --prefix=$HOME/local/pgsql-$VERSION --enable-debug --enable-cassert
# planner dev
#./configure OPTIMZER_DEBUG=1 CFLAGS=-pthread --prefix=$HOME/local/pgsql-$VERSION --enable-debug --enable-cassert
# mac
#./configure CC="ccache gcc" CFLAGS='-pthread -arch x86_64' --prefix=$HOME/local/pgsql-$VERSION --enable-debug --enable-cassert --with-python
@umitanuki
umitanuki / switch-local.sh
Created May 25, 2011 08:41
switch ~/local/{foo}-{bar}
#!/bin/bash
base=$1
version=$2
if [ -z "$base" -o -z "$version" ]
then
echo "Usage $0 <base> <version>"
else
rm -f ~/local/$base
@umitanuki
umitanuki / gist:950872
Created May 1, 2011 21:02
Join fix issue
create table size_m as select i as id, repeat(i::text, i % 100) as val from generate_series(1, 20000) i;
create table size_l as select i as id, m.id as m_id, repeat(i::text, i % 100) as val from generate_series(1, 1000000) i, size_m m where i.i / 10 = m.id;
--create index idx_m_id on size_l (m_id);
analyze size_m;
analyze size_l;
----