Skip to content

Instantly share code, notes, and snippets.

View BrianHicks's full-sized avatar

Brian Hicks BrianHicks

View GitHub Profile
'really simple ORM for RethinkDB objects'
import inflect
import re
import rethinkdb as r
p = inflect.engine()
class DocumentMetaClass(type):
def __new__(meta, classname, bases, attrs):
if '_table' not in attrs:
function Point(x, y) {
this.x = x;
this.y = y;
}
function Vector(degrees, length) {
this.degrees = degrees; // -180 to 180
this.length = length;
this.radians = degrees * Math.PI / 180;
@BrianHicks
BrianHicks / regex.md
Created May 3, 2013 16:58
crazy regex syntax

Basics:

"three numbers" -> "\d{3}"
"an optional dot" -> "\.?"
"a letter and two numbers, three times" -> "(\w\d\d){3}"

So that can come together to form this:

"one to three numbers and an optional dot, four times" -> "(\d{1,3}\.?){4}"
# create the repo
salty-repo:
file.directory:
- name: /opt/git-remote/salty
- require:
- file: git-remote-directory
cmd.run:
- name: "git init /opt/git-remote/salty --bare"
- unless: "test -e /opt/git-remote/salty/HEAD"
git-remote:
root: /opt/git-remote
repos:
- name: salt-repo
hooks:
post-receive: |
#!/bin/bash
echo "-------- pulling to /srv/salt --------"
test -d /srv/salt || mkdir -p /srv/salt
{% set root = salt["pillar.get"]("git-remote:location", "/opt/git-remote") %}
git:
pkg.installed:
- pkgs:
- git-core
git-remote-directory:
file.directory:
- name: {{ root }}
- user: root
@BrianHicks
BrianHicks / ssg.md
Last active December 24, 2015 22:28
SSG concept

Static Site Generation as Discrete Stages

So imagine you have the following file structure:

.
├── _plugins
├── _posts
│   ├── 2013-01-01-test-post.md
│   └── 2013-10-02-blah.md
  • US: 3,719,000 sq. miles ÷ 319,000,000 people = 0.011 mile/person
  • Japan: 145,833 sq. miles ÷ 126,000,000 people = 0.001 mile/person

So:

  • US: 85.7 people/sq. mile
  • Japan: 864 people/sq. mile

Figures from Wolfram Alpha

POST analytics-2013.11.06/_search
{
"query": {"match_all": {}},
"facets": {
"tags": {
"terms": {
"field": "params.tag",
"size": 10
}
}
root@mesos-master-dev:~/marathon# docker attach $(docker run -d -p 8080:8080 mesosphere/marathon --master zk://192.168.1.104:2181/mesos --zk_hosts 192.168.1.104:2181 --hostname 192.168.1.104:2181)
Nov 22, 2013 2:28:55 PM mesosphere.marathon.MarathonModule provideCandidate
INFO: Registering in Zookeeper with hostname:192.168.1.104:2181
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@658: Client environment:zookeeper.version=zookeeper C client 3.3.4
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@662: Client environment:host.name=6985af9a3528
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@669: Client environment:os.name=Linux
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@670: Client environment:os.arch=3.8.0-29-generic
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@671: Client environment:os.version=#42~precise1-Ubuntu SMP Wed Aug 14 16:19:23 UTC 2013
2013-11-22 14:28:55,185:12(0x7fb30aa83700):ZOO_INFO@log_env@679: Client environment:user.name=(nul