Skip to content

Instantly share code, notes, and snippets.

View eldritchideen's full-sized avatar

Steven Cook eldritchideen

  • Amazon Web Services
  • Australia
View GitHub Profile
@eldritchideen
eldritchideen / gist:336fc3b823d2d0b89a13
Last active August 29, 2015 14:05
Getting points out of a DXF file
import dxfgrabber
dxf = dxfgrabber.readfile('surface0.dxf')
all_surface_entities = [entity for entity in dxf.entities if entity.layer == '0']
all_progress_line_entities = [entity for entity in dxf.entities if entity.layer == 'Progress Line']
f = open('surface_points.csv', 'w')
# List of Point objects
for p in all_surface_entities:
@eldritchideen
eldritchideen / gist:89b9ba06457b568f0d1a
Last active June 25, 2023 01:04
Very simple actor implementation with core.async
(ns scratch.core
(:require [clojure.core.async :as async :refer [go-loop <! chan <!! >! >!!]])
(:gen-class))
(defn make-actor
"Creates actor of specific name" [name]
(let [in (chan 10)]
(go-loop [[msg-type sender msg-body :as data] (<! in)]
(when data
(println (str "Actor " name " got message " msg-type
@eldritchideen
eldritchideen / gist:b8edcea93ced80b03f53
Created January 31, 2015 00:33
Moving Average in Clojure
(defn average [coll]
(/ (reduce + coll)
(count coll)))
(defn ma [period coll]
(lazy-cat (repeat (dec period) nil)
(map average (partition period 1 coll))))
from zipline.algorithm import TradingAlgorithm
from zipline.transforms import MovingAverage
from zipline.utils.factory import load_from_yahoo
from zipline.finance.slippage import FixedSlippage
from zipline.finance.commission import PerShare
from datetime import datetime
import matplotlib.pyplot as plt
class DualMovingAverage(TradingAlgorithm):

Sample Project

Starting from:

lein new foo
cd foo

Say I have a random JAR file that is not available in any repository:

touch README.md

@eldritchideen
eldritchideen / gist:87d33626bd85ebefbf24
Last active August 29, 2015 14:23
Get current list of shares making new highs
defmodule Stocks do
def get_new_highs do
HTTPoison.start
resp = HTTPoison.get!("http://www.smh.com.au/business/markets/52-week-highs?page=-1",[], [proxy: "http://proxy.cat.com:80"])
data = Floki.find(resp.body, "#content section table tbody tr th a")
Enum.map(data, fn({_,_,[code]}) -> code end)
end
end
function Vector(x,y) {
this.x = x
this.y = y
}
Vector.prototype.plus = function(other) {
return new Vector(this.x + other.x, this.y + other.y)
};
Vector.prototype.minus = function(other) {
return new Vector(this.x - other.x, this.y - other.y)
};
@eldritchideen
eldritchideen / osx-mongodb-rlimits-fix.md
Last active September 7, 2015 10:11 — forked from tamitutor/osx-mongodb-rlimits-fix.md
Fix Mongodb "soft rlimits" Warning On Mac OS X (Yosemite)

If you are seeing Mongo soft rlimits warnings in your logs, or a WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 when you login to mongo shell via mongo from the commandline, or any mysterious/unexplained mongo connection errors... follow this how-to exactly and it will resolve the issue for you.

(Source of this how to found at basho/basho_docs#1402)

First file: sudo vi /Library/LaunchDaemons/limit.maxfiles.plist

...containing:

@eldritchideen
eldritchideen / get-all-ords.js
Last active October 25, 2015 06:20
Scrape list of stocks making up the All Ordinaries index.
const request = require('request'),
cheerio = require('cheerio'),
fs = require('fs');
request('http://www.marketindex.com.au/all-ordinaries', function (error, response, body) {
if (!error && response.statusCode === 200) {
let stocks = [];
let $ = cheerio.load(body);
$('#asx_sp_table > tbody > tr > td:nth-child(2)').each((i,elem) => {
stocks[i] = elem.children[0].data;
@eldritchideen
eldritchideen / golang_job_queue.md
Created March 27, 2016 07:21 — forked from harlow/golang_job_queue.md
Job queues in Golang