Skip to content

Instantly share code, notes, and snippets.

View Version2beta's full-sized avatar

Rob Martin Version2beta

View GitHub Profile
@Version2beta
Version2beta / gist:9533942
Created March 13, 2014 18:24
Sequel issue
Sequel.migration do
change do
create_table :reports do
primary_key :id
column :name, String, null: false
column :product, String, null: false
column :category, String
column :topics, 'varchar[]'
column :expired_at, Time
@Version2beta
Version2beta / gist:6d47df57712ebdb575db
Created May 21, 2014 17:22
lua setmetatable issue
local env = os.getenv('DNMENV') or 'dev'
local configs = {
dev = {
db = {
address = "127.0.0.1",
port = 6379,
db = 0,
testdb = 15,
timeout = 1000,
keepalive = { 2000, 1 }
> -- collected from #lua user q66
> foo = newproxy(true)
> getmetatable(foo).__gc = function() print("o hai!") end
> foo = nil
> collectgarbage()
o hai!
> foo = {}
> foo.__my_gc_thingy = newproxy(true)
> getmetatable(foo.__my_gc_thingy).__gc = function() print("collectin' a table") end
> foo = nil
@Version2beta
Version2beta / gist:49ba5def7f3119aa6394
Created September 5, 2014 16:53
erlang shell options
# Copyright (c) 2014, M Robert Martin <rob@version2beta.com>
# This file is contributed to erlang.mk and subject to the terms of the ISC License.
.PHONY: shell
# Configuration.
SHELL_PATH ?= -pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin
SHELL_OPTS ?=
( This is a simplified version of the card game War written in Puppy. )
( Simple version of War: )
( Two values on top of the stack represent dealt cards for the left and the )
( right players. Figure out which is bigger, and send the cards to that )
( player. In case of a tie, play again to determine the winner. )
( Puppy is an unimplemented point-free, concatentative, stack-based language )
( with quotations. )
@Version2beta
Version2beta / gist:3895882
Created October 15, 2012 22:05
A non-functional Tako route.
app.route('/')
.html(function (req, resp) {
db.get('home', function(err, body) {
if (err) return resp.error(err)
console.log(templates.home(body));
})
.pipe(templates.home())
.pipe(resp);
})
.methods('GET')
@Version2beta
Version2beta / getIdTest.php
Created December 23, 2012 23:19
Testing an oddity in MODX Revolution's get('id') method.
<?php
// Get the children
error_log(print_r($modx->resource->get('id'), 1)); // prints 1
$children = $modx->resource->getMany('Children'); // returns children of 1
if ($children) {
// Parse children
$retVal = '<ul>';
foreach ($children as $child) {
$retVal .= '<li>Resource ' . $child->get('id') . ', child of resource ' . $child->get('parent') . '</li>';
@Version2beta
Version2beta / gist:5040063
Created February 26, 2013 16:54
Bash script dies about a minute into the second sql file.
# execute 'DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade'
include_recipe "postgresql"
include_recipe "postgresql::server"
include_recipe "postgresql::ruby"
include_recipe "database"
databases_file = "pgdatabases.tar.bz"
cookbook_file "/var/lib/postgresql/#{databases_file}" do
source databases_file
@Version2beta
Version2beta / gist:5986071
Created July 12, 2013 17:11
Problems with Vagrant 1.2.3 and Chef 11.4.4 on a Precise64-based box.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.omnibus.chef_version = :latest
config.vm.box = "itvdev"
config.vm.network :private_network, ip: "10.42.42.2"
# config.vm.network :public_network
@Version2beta
Version2beta / gist:6001107
Created July 15, 2013 15:58
Vagrant file and configuration cookbook for Vagrant + Chef, generating multiple unhappy errors
-> cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.omnibus.chef_version = :latest
config.vm.box = "itvdev"
config.vm.network :private_network, ip: "10.42.42.2"
# config.vm.network :public_network