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 / tg2p.st
Created April 2, 2018 04:40 — forked from jdevoo/tg2p.st
Not so Terse Guide to Pharo
"**************************************************************************
* Allowable characters: *
* - a-z *
* - A-Z *
* - 0-9 *
* - .+/\*~<>@%|&? *
* - blank, tab, cr, ff, lf *
* *
* Variables: *
* - variables must be declared before use *
@eldritchideen
eldritchideen / main.go
Created January 30, 2017 01:37
Simple Go Site with Auth
package main
import (
"html/template"
"log"
"net/http"
"net/url"
"time"
)
package main
import (
"fmt"
"math"
"math/rand"
"github.com/gonum/matrix/mat64"
)
@eldritchideen
eldritchideen / main.go
Created December 15, 2016 10:35 — forked from mschoebel/main.go
Snippet: login/logout (Golang)
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
@eldritchideen
eldritchideen / gist:e56a9dc5ad9b9ec9967a54bd5bd2346e
Last active July 11, 2016 19:40 — forked from SegFaultAX/gist:1f8900efb422888eabab
clojure.core/partition and clojure.core/partition-all in Python
def take_while(fn, coll):
"""Yield values from coll until fn is False"""
for e in coll:
if fn(e):
yield e
else:
return
def partition(n, coll, step=None):
return take_while(lambda e: len(e) == n,
@eldritchideen
eldritchideen / readme.md
Last active April 22, 2017 23:41
HTTP Server Micro-Benchmarks

HTTP Server Micro-Benchmarks

Here are the results of testing returning a small text string from a HTTP request implemented in various languages all, tested under the same conditions. The command used to test the server implementations was:

wrk -c 40 -d 60s -t 2 --latency http://localhost:3000

Python3

This test used the new async support in python 3.5.

@eldritchideen
eldritchideen / golang_job_queue.md
Created March 27, 2016 07:21 — forked from harlow/golang_job_queue.md
Job queues in Golang
@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 / 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:

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)
};