Skip to content

Instantly share code, notes, and snippets.

Avatar

rasputnik rasputnik

View GitHub Profile
View gist:125874
production:
adapter: jdbc
username: me
password: sssh
driver: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@dbhost:1521:dbname
# run with 'jruby -S sequel -e production database.yml
@rasputnik
rasputnik / ImageSizer
Created Oct 12, 2009
Rack Middleware to tell you dimensions of an image
View ImageSizer
# JRuby version of ImageScience (other image toolkits are available)
require 'image_voodoo'
class ImageSizer
def initialize(app, mime_types=%w[image/jpeg image/png image/gif])
@app = app
@mime_types = mime_types
end
def call(env)
View counter.js
module.exports = function counterSetup(logcheckpoint) {
var hitcount = 0;
var logcheckpoint = logcheckpoint || 1000;
return function hitCount(req, res, next) {
hitcount++;
if (hitcount % logcheckpoint == 0 ) {
console.log(hitcount + " hits");
}
next();
View argh can't do case statements
class mongodb::repo {
yumrepo { "10gen repository":
enabled => 1,
descr => "10gen repository",
baseurl => case $architecture {
i686: {"http://downloads.mongodb.org/distros/centos/5.4/os/x86_64/"}
default: { "baseurl=http://downloads.mongodb.org/distros/centos/5.4/os/i386/"}
},
gpgcheck => 0
}
View gist:703220
cron { "logshipping.cronjob":
command => $logshippingscript,
require => File[$logshippingscript],
hour => 15,
minute => 01,
user => "apache"
}
file { $logshippingscript :
owner => apache,
@rasputnik
rasputnik / gist:978645
Created May 18, 2011
jruby -S gem install arel on 1.6.1
View gist:978645
[sisred@buckaroo graylog2-web-interface]$ jruby -S gem install arel
System.java:-2:in `arraycopy': java.lang.ArrayIndexOutOfBoundsException
from DefaultResolver.java:111:in `makeTime'
from DefaultResolver.java:277:in `create'
from DefaultResolver.java:317:in `handleScalar'
from DefaultResolver.java:435:in `orgHandler'
from DefaultResolver.java:455:in `node_import'
from DefaultResolver$s$1$0$node_import.gen:65535:in `call'
from CachingCallSite.java:137:in `call'
from RubyLoadHandler.java:40:in `handle'
@rasputnik
rasputnik / gist:1048575
Created Jun 27, 2011
logstash not parsing syslog?
View gist:1048575
[root@topcat logstash]# java -jar logstash-1.0.12-monolithic.jar agent -f logstash-simple.cnf
{:args=>["agent", "-f", "logstash-simple.cnf"]}
W, [2011-06-27T10:36:21.439000 #27280] WARN -- runner.class: Input #<LogStash::Inputs::Syslog:0x12297d7> shutting down
2011-06-27T09:36:21.991000Z syslog://10.1.2.3: <30>ntpd[3355]: synchronized to 1.2.3.4, stratum 2
2011-06-27T09:36:22.631000Z syslog://10.2.32.2: <14>ncpd: cmd=0, len=14, data: BB BB 00 1C 00 00 00 00 1C 3F 00 00 00 00
...
...
[root@topcat logstash]# cat logstash-simple.cnf
input {
syslog {
@rasputnik
rasputnik / gist:3634727
Created Sep 5, 2012
4clojure #23 : reversing a sequence
View gist:3634727
(defn widdershins [coll]
(letfn [(flip [tocoll fromcoll]
(if (empty? fromcoll)
tocoll
(flip (cons (first fromcoll) tocoll) (rest fromcoll))
)
)]
(flip [] coll)
)
)
@rasputnik
rasputnik / core.clj
Created Dec 11, 2012
this is throwing a stacktrace starting with : "Exception in thread "main" java.lang.IllegalArgumentException: Parameter declaration wrap-json-response should be a vector"
View core.clj
(ns tyrekick.core
(:use ring.adapter.jetty ring.util.response ring.middleware.json)
(:gen-class))
(defn handler
"dead simple to get benchmark reqs/sec"
[request]
(response {:message "hello nasty"}))
(defn app
View 0.9.0pre8 jruby CPU
# run with "jruby --1.9 /path/to/this.rb" and wait 10 minutes
class Thing
def initialize
require 'cabin'
@logger = Cabin::Channel.new
sout = Logger.new(STDOUT)
@logger.level = :debug
You can’t perform that action at this time.