Skip to content

Instantly share code, notes, and snippets.

View pyykkis's full-sized avatar

Jarno Keskikangas pyykkis

  • Subtle Insights Oy
  • Finland
View GitHub Profile
@pyykkis
pyykkis / scid_parser.py
Created November 7, 2022 11:26
Sierra Chart Intraday Data File parser
import numpy as np
import pandas as pd
from struct import unpack, calcsize
from collections import namedtuple
def parse_scid_file(filename):
SIERRA_CHART_EPOCH = pd.to_datetime('1899-12-30')
@pyykkis
pyykkis / market_scanner.py
Last active March 4, 2021 07:42
Download 1 year history of all Nasdaq traded companies for market analysis
import datetime
import pandas as pd
import yfinance as yf
symbols = pd.read_csv('ftp://ftp.nasdaqtrader.com/symboldirectory/nasdaqtraded.txt', delimiter='|')
# Excluded symbols:
# - Test symbols
# - ETFs
# - Financial status: Other than Normal
fs = require 'fs'
{Transform} = require 'stream'
class Reverser extends Transform
_transform: (data, encoding, done) ->
@push data.toString().split('').reverse().join ''
done()
class UpperCaser extends Transform
_transform: (data, encoding, done) ->
@pyykkis
pyykkis / -
Created January 5, 2014 19:35
bin/ansible:#!/usr/bin/env python
bin/ansible-doc:#!/usr/bin/env python
bin/ansible-galaxy:#!/usr/bin/env python
bin/ansible-playbook:#!/usr/bin/env python
bin/ansible-pull:#!/usr/bin/env python
docsite/build-site.py:#!/usr/bin/env python
examples/scripts/uptime.py:#!/usr/bin/python
hacking/module_formatter.py:#!/usr/bin/env python
hacking/test-module:#!/usr/bin/env python
lib/ansible/runner/action_plugins/synchronize.py:#!/usr/bin/python
@pyykkis
pyykkis / xls2csv.py
Created September 24, 2013 19:04
Convert xls and xlsx files to csv and print to stdout.
#!/usr/bin/python
from sys import *
import xlrd
import csv
def to_utf8(val):
if isinstance(val, basestring):
return val.encode('utf-8')
else:
@pyykkis
pyykkis / search.coffee
Last active December 21, 2015 15:49
Streaming mongodb queries
search: ({query: {q}}, res) =>
@collection.then((coll) ->
coll.find(key: new RegExp(q, 'i'))
.sort(_id: -1)
.limit(20)
.stream()
.pipe(JSONStream.stringify())
.pipe(res))
.done()
@pyykkis
pyykkis / gist:6298695
Created August 21, 2013 18:59
Listen two http on two different ports
express = require 'express'
http = require 'http'
app = express()
app.get '/hello', (_, res) -> res.send "Hello world!"
http.createServer(app).listen 3000
http.createServer(app).listen 3010
@pyykkis
pyykkis / app.coffee
Last active December 20, 2015 02:09
Calculate sum of variable amount of values
reduce = (f, initial) -> (xs) -> Array::reduce.call xs, f, initial
butlast = (xs) -> xs.slice 0, xs.length - 1
sum = (x, y) -> x + y
addInputStream = (xs) ->
input = $('<input />')
.appendTo('#inputs')
.asEventStream('input')
.map('.target.value')
.map(parseInt)
module.exports = class FooController
get: ({params: {foo}}, res) ->
get("http://localhost:9292/api/#{foo}.json")
.then (response) ->
res.status response.status
if response.status == 200
then res.end JSON.stringify transformResponse response.body
else res.end response.text
@pyykkis
pyykkis / james.js
Created July 2, 2013 10:21
How james.js error handling should be done?
// james-coffee/index.js
var james = require('james'),
coffee = require('coffee-script');
coffee.createStream = function() {
return james.createTransformation(function(content, callback) {
// Process the file content and call the callback with the result.
try {
res = coffee.compile(content);