This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sequel' | |
require 'logger' | |
DB = Sequel.postgres('steve', :host => 'localhost') | |
DB.loggers << Logger.new($stdout) | |
# DB.run 'CREATE TABLE cars (id SERIAL PRIMARY KEY, asdf TEXT NOT NULL) WITHOUT OIDS;' | |
class Car < Sequel::Model | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyApp | |
class APIError < Exception; end | |
class Web < Sinatra::Base | |
def self.api(&block) | |
# some crazy stuff to wrap any get/put/delete/post/patch | |
# requests into a block with automatic error handling, and | |
# pass on all other requests to the sinatra base class. | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# execute a command using an installed ruby/gemset | |
rvm::exec { 'start-myapp': | |
local => 'apache', | |
ruby_version => '1.9.3-p394', | |
gemset_name => 'myapp', | |
user => 'apache', | |
group => 'apache', | |
binary => 'thin', | |
arguments => ['start', '-p', '9292', '-P', '/var/run/myapp.pid'], | |
creates => '/var/run/myapp.pid', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\version "2.16.2" | |
\header { | |
title = "Wedding March" | |
composer = "Felix Mendelssohn" | |
} | |
dfnat = \markup \concat \vcenter { F \natural D \natural } | |
dfshp = \markup \concat \vcenter { F \sharp D \sharp } | |
cshp = \markup \concat \vcenter { C \sharp } | |
cfswp = \markup \concat \vcenter { C \natural F \sharp } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
del_data AS ( | |
DELETE | |
FROM data | |
WHERE EXISTS ( | |
SELECT id | |
FROM alert | |
WHERE timestamp <= EXTRACT(EPOCH FROM (NOW() - '1 year'::interval))::integer AND | |
data.id = alert.id | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH params AS (SELECT '192.168.1.1' AS ip, | |
'2012-12-31' AS min_date) | |
SELECT a.id, | |
a.server_id, | |
a.rule_id, | |
('1970-01-01'::timestamp + (a.timestamp::text || ' seconds')::interval) AS timestamp, | |
a.location_id, | |
integer_to_inet(a.src_ip) AS src_ip, | |
integer_to_inet(a.dst_ip) AS dst_ip, | |
CASE WHEN a.src_port = 0 THEN NULL ELSE a.src_port END AS src_port, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git status | |
# On branch master | |
# Your branch is behind 'origin/master' by 19 commits, and can be fast-forwarded. | |
# | |
nothing to commit (working directory clean) | |
$ git pull origin master | |
[output snipped] | |
$ git status | |
# On branch master | |
# Your branch is ahead of 'origin/master' by 1 commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.14; | |
my $empty_list = sub { | |
shift->(undef, undef, 1); | |
}; | |
my $prepend = sub { | |
my $el = shift; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var addCell = function($row, inner, addAs) { | |
var $cell = $(document.createElement('td')) | |
{ | |
html: function() { $cell.html (inner) }, | |
text: function() { $cell.text (inner) }, | |
child: function() { $cell.append(inner) } | |
}[addAs ? addAs : 'text']() | |
$row.append($cell) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
# some example values to test | |
our (%STUFF) = ( # just doin' a hash, like a boss. | |
SOME_KEY => 'some_value', | |
SOME_OTHER_KEY => 'some_other_value', | |
); |