Skip to content

Instantly share code, notes, and snippets.

View cbandy's full-sized avatar

Chris Bandy cbandy

View GitHub Profile
@cbandy
cbandy / cypherdoc_4.1.sql
Last active August 29, 2015 14:02
Neo4j in PostgreSQL
-- CREATE (n:Actor { name:"Tom Hanks" });
WITH
n AS (
INSERT INTO node (properties) VALUES ('name=>Tom Hanks') RETURNING id
)
INSERT INTO node_label VALUES (n.id, 'Actor');
-- MATCH (actor:Actor { name: "Tom Hanks" })
-- RETURN actor;
WITH
@cbandy
cbandy / sequence.rb
Last active August 29, 2015 13:57
Ruby Sequence
irb(main):001:0> a = Enumerator.new { |output| i = 0; loop { output << i = i.next } }
=> #<Enumerator: #<Enumerator::Generator:0x007f8014012818>:each>
irb(main):002:0> a.next
=> 1
irb(main):003:0> a.next
=> 2
irb(main):004:0> a.next
=> 3
@cbandy
cbandy / alert.js
Last active August 17, 2020 15:22
Kettle Javascript Job Entry
try
{
// Something
}
catch (error)
{
var spoon = Packages.org.pentaho.di.core.gui.SpoonFactory.getInstance();
spoon.messageBox(
error.message, error.name,
true, Packages.org.pentaho.di.core.Const.INFO
@cbandy
cbandy / command.sh
Created March 15, 2013 08:45
Git-bisect a Ruby project while applying a patch in the stash.
# GOOD: cc03053
# BAD: 408174f
git bisect start 408174f cc03053
git bisect run ./test-stash-0.sh
@cbandy
cbandy / block_like_class_new.rb
Last active December 10, 2015 05:48
Virtus::ValueObject and Equalizer. Equalizer instances are immutable. https://github.com/dkubb/equalizer/issues/8
module Virtus::ValueObject
def self.new(super_class = Object, &block)
result = Class.new(super_class)
result.class_exec(&block)
result.include(Equalizer.new(*result.attribute_set.map(&:name)))
end
end
MyClass = Virtus::ValueObject.new do
attribute ...
@cbandy
cbandy / 01.rb
Created May 8, 2012 18:18
What DCI gets us: from Procedure to Context
# Ruby-esque pseudocode
def transfer_money_between_accounts(acct1, acct2, amount)
puts "Source balance is: #{acct1.balance}"
puts "Destination balance is: #{acct2.balance}"
acct1.balance -= amount
acct2.balance += amount
puts "Source balance is now: #{acct1.balance}"
require 'benchmark'
require 'delegate'
class DecorateUser
end
class RunnerDecorator < DelegateClass(DecorateUser)
def initialize(user)
super user
end
#!/bin/sh
MODEM_HOST="Cable Modem"
MODEM_IP="192.168.100.1"
SIGNAL_URL="http://$MODEM_IP/RgSignal.asp"
ZABBIX_SERVER="127.0.0.1"
curl --silent "$SIGNAL_URL" |
sed -n -e '
/Downstream/,/Upstream/ {
@cbandy
cbandy / gist:1360674
Last active September 28, 2015 01:07
git pre-commit hook
#!/bin/sh
# Run tools on files in the index
git diff --cached --name-status \
| awk '$1 != "D" && $1 != "R" { $1 = ""; print }' \
| git checkout-index --stdin --temp \
| while read tmp orig
do
case $orig in
*.php)
diff --git a/classes/kohana/config/database/reader.php b/classes/kohana/config/database/reader.php
index 9366a2a..f9899dd 100644
--- a/classes/kohana/config/database/reader.php
+++ b/classes/kohana/config/database/reader.php
@@ -53,7 +53,7 @@ class Kohana_Config_Database_Reader implements Kohana_Config_Reader
*
* @link http://dev.kohanaframework.org/issues/4316
*/
- if ($group === 'database')
+ if ($group === Database::CONFIG)