Skip to content

Instantly share code, notes, and snippets.

View nathanaschbacher's full-sized avatar

Nathan Aschbacher nathanaschbacher

View GitHub Profile
@nathanaschbacher
nathanaschbacher / sudo_env_output
Created March 13, 2012 20:10
Torquebox 2.x errors trying to daemonize the gem install (sudo jruby -S rake torquebox:upstart:start)
GEM_HOME=/usr/local/rvm/gems/jruby-1.6.7
TERM=xterm-256color
JBOSS_HOME=/usr/local/rvm/gems/jruby-1.6.7@global/gems/torquebox-server-2.0.0.cr1-java/jboss
PATH=/usr/local/rvm/gems/jruby-1.6.7/bin:/usr/local/rvm/gems/jruby-1.6.7@global/bin:/usr/local/rvm/rubies/jruby-1.6.7/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
JRUBY_HOME=/usr/local/rvm/rubies/jruby-1.6.7
LANG=en_US.UTF-8
TORQUEBOX_HOME=/usr/local/rvm/gems/jruby-1.6.7@global/gems/torquebox-server-2.0.0.cr1-java
GEM_PATH=/usr/local/rvm/gems/jruby-1.6.7:/usr/local/rvm/gems/jruby-1.6.7@global
JRUBY_OPTS=--1.9
SHELL=/bin/bash
@nathanaschbacher
nathanaschbacher / expensive_process.js
Created May 7, 2012 19:23
Trying to work with Node.js child_process
module.exports = function(input, args) {
var expensiveResults = // Do some computationally expensive stuff with input and args...
this.emit('results', expensiveResults);
}
@nathanaschbacher
nathanaschbacher / gist:2722971
Created May 18, 2012 03:21
Helping innociv get at his cookies
var cookie_str = "__utmb=7853809.51.10.1337306437; uniquekey=133730899192d4bf232ce84c6";
var uniquekey = cookie_str.split('uniquekey=')[1];
console.log(uniquekey);
@nathanaschbacher
nathanaschbacher / myRole
Created June 8, 2012 19:40
Trying to override defaults in Riak chef cookbook for Riak Control user/pass
override_attributes(
"riak" => {
"control" => {
"enabled" => true,
"userlist" => { "default_user" => ["!merge:user", "!merge:pass", "Pablo", "Turbine2012"]}
}
}
)
@nathanaschbacher
nathanaschbacher / raphs_obj.js
Created September 12, 2012 06:12
Quick type couriering lesson for Raph
var MyClass = function MyClass() {
this.property = 'something';
}
var temp = new MyClass();
console.log(temp instanceof MyClass); // prints 'true'
temp = JSON.parse(JSON.stringify(temp));
@nathanaschbacher
nathanaschbacher / raw_http_res.txt
Created October 9, 2012 22:23
Using the Node.js core HTTP parser for my whims
HTTP/1.1 200 OK
Date: Mon, 19 Jul 2004 16:18:20 GMT
Server: Apache
Last-Modified: Sat, 10 Jul 2004 17:29:19 GMT
ETag: "1d0325-2470-40f0276f"
Accept-Ranges: bytes
Content-Length: 9328
Connection: close
Content-Type: text/html
@nathanaschbacher
nathanaschbacher / replacer_test.js
Created October 26, 2012 02:33
Trying to get a JSON replacer to detect Ctor type...
var Foo = function Foo() {
this.id = 1;
}
var Bar = function Bar(foo) {
this.id = 2;
this.buddies = {};
}
Bar.prototype.toJSON = function() {
@nathanaschbacher
nathanaschbacher / coercion.js
Created November 2, 2012 17:36
Javascript instance to instance coercion
var inspect = require('util').inspect;
var Class1 = function Class1() {
this.frank = "costanza";
this.__defineGetter__('prop', function() {return 5;});
this.__defineGetter__('fromClass1', function() {return 5;});
}
Class1.prototype.heyThere = function() {}
@nathanaschbacher
nathanaschbacher / Versioning, Soft Delete, and Restore.md
Last active December 14, 2015 07:39
One simple example of an implementation for a transaction/audit journal and restoring lost/deleted objects for a known key.

##Driver

Customers often request “versioning” or “restore/undo” functionality, as a means of data recovery from user error (as opposed to recovery from hardware failure or data loss errors, at which Riak already excels). If an object is changed or deleted by the end user, but later needs to be restored, is there a way to either look at a transaction log to undo the damage, or to explicitly restore the object to a previous version?

##Overview

This solution provides one simple example of an implementation for a transaction/audit journal and restoring lost/deleted objects for a known key. A separate global transaction/audit journal could also be built to provide an index to get an object key in the case where you don't know it beforehand, but that use case is outside the scope of this document.

The algorithm used here depends only on Riak's key/value functionality for two reasons. First, to show that a solution to the problem can be simply and efficiently implemented with a key/value pattern. Second, relyin

@nathanaschbacher
nathanaschbacher / result.html
Created August 6, 2017 04:29
Exposing List Bullet Markers in cmark
<h1>Heading</h1>
<ul>
<li>asterisk list 1</li>
<li>asterisk list 2</li>
</ul>
<ul>
<li>hyphen list 1</li>
<li>hyphen list 2</li>
<li>hyphen list 3</li>
</ul>