Skip to content

Instantly share code, notes, and snippets.

@curzonj
curzonj / gist:1315957
Created October 26, 2011 10:17
Skeleton of a logstash router
#!/usr/bin/env jruby
require 'rubygems'
require 'logstash'
include Logstash
router = Router.new(ARGV) do
router.inputs(:queue => "queue1").add(
Inputs::Gelfd,
def debug_connection_frames(conn)
frames = conn.instance_variable_get('@frames')
if frames.size > 0
logger.debug("Frames: #{frames.size}")
list = frames.map do |frame|
str = "#{frame.class.name}(#{frame.channel},"
case frame
when AMQ::Protocol::HeaderFrame
str << "total #{frame.body_size})"
when AMQ::Protocol::MethodFrame
<<< POWERSHELL.exe run from CMD.exe >>>
PS C:\Users\targetmig> get-itemproperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14\Setup
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14\Setup
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14
PSChildName : Setup
PSProvider : Microsoft.PowerShell.Core\Registry
Required machine-level settings. : 1
Services : C:\Program Files\Microsoft\Exchange Server\V14
NewestBuild : 10218
diff --git a/gc.c b/gc.c
index 39071e7..06c384a 100644
--- a/gc.c
+++ b/gc.c
@@ -22,8 +22,16 @@
#include <setjmp.h>
#include <sys/types.h>
+#ifdef _WIN32
+#include <string.h>
#!/usr/bin/ruby
# == Usage
#
# This script reads a sorted list of words from standard input:
#
# cat words | ./word_pairs.rb
#
# To benchmark the code and save it's output to a file use:
#
# time (cat words | ./word_pairs.rb > word_matches)
# gem install dm-fluiddb-adapter
require 'dm-core'
require 'memcached'
CACHE = Memcached.new 'localhost:11211', :prefix_key => 'fluiddb-test:'
DataMapper.setup(:default, "fluiddb://test:test@sandbox.fluidinfo.com/test")
class MyModel
include DataMapper::Resource
check process mongrel-5000 with pidfile /usr/local/nextgen/current/tmp/pids/mongrel.5000.pid
start program = "/bin/su -c '/bin/rm -f /usr/local/nextgen/current/tmp/pids/mongrel.5000.pid && /usr/bin/ruby /usr/bin/mongrel_rails start -d -e production -p 5000 -a 127.0.0.1 -P /usr/local/nextgen/current/tmp/pids/mongrel.5000.pid -c /usr/local/nextgen/current' nextgen"
stop program = "/bin/su -c '/usr/bin/ruby /usr/bin/mongrel_rails stop -P /usr/local/nextgen/current/tmp/pids/mongrel.5000.pid && ([ ! -f /usr/local/nextgen/current/tmp/pids/mongrel.5000.pid ] || (kill -9 `/usr/local/nextgen/current/tmp/pids/mongrel.5000.pid` && /bin/rm -f /usr/local/nextgen/current/tmp/pids/mongrel.5000.pid))' nextgen"
if totalmem is greater than 80.0 MB for 5 cycles then restart # eating up memory?
if cpu is greater than 50% for 2 cycles then alert # send an email to admin
if cpu is greater than 80% for 3 cycles then restart # hung process?
if loadavg(5min) greater tha
diff --git a/lib/icalendar/component.rb b/lib/icalendar/component.rb
index a2d7bc3..2fb8f02 100644
--- a/lib/icalendar/component.rb
+++ b/lib/icalendar/component.rb
@@ -427,11 +427,11 @@ module Icalendar
public
def respond_to?(method_name)
- unless method_name.to_s.downcase =~ /x_.*/
+ if method_name.to_s.downcase =~ /x_.*/
for file in *.pdf; do
if [ -f "$file" ]; then
pdfimages -j "$file" image_extraction
fi
done
name = 'date_received'
model = Sample
input_name = 'bob'
plural = model.to_s.pluralize
controller = (Object.const_get("#{plural}Controller") || ApplicationController).new
controller.params = {}
helper = Object.const_get("#{plural}Helper")