Starting from:
lein new foo
cd foo
Say I have a random JAR file that is not available in any repository:
touch README.md
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: |
(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 |
(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): |
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) | |
}; |
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:
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; |
A running example of the code from:
Small refactorings made to original code: