Skip to content

Instantly share code, notes, and snippets.

@karnauskas
karnauskas / gist.rb
Created November 27, 2012 15:41 — forked from mbj/gist.rb
Poor mans RA with dm-1
class Foo
property :id, Seriaal
property :name, STring
has n, :bar
# Enumerate bar with name
#
# @return [self]
# if block given
#
#!/usr/bin/env ruby
# quick and dirty thin init script
#
# path for thin
thin = "/home/someuser/.rvm/gems/ruby-1.8.7-p72@global/bin/thin"
config = "config/config.ru"
# which dir to run from
path = "/srv/thisapp"
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "debian-wheezy"
boxes = {
:puppet => {
:hostname => "puppet.dhoppe.lan",
:ip => "192.168.56.10",
@karnauskas
karnauskas / tmuxrc
Created September 3, 2013 13:13 — forked from eculver/tmuxrc
# command prefix (like screen)
set -g prefix C-a
bind C-a send-prefix
# basic settings
set-window-option -g mode-keys vi # vi key
set-option -g status-keys vi
set-window-option -g utf8 on # utf8 support
set-window-option -g mode-mouse off # disable mouse
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto
<opml version="1.1">
<head>
<title>NewsBlur Feeds</title>
<dateCreated>2013-05-08 14:38:06.132359</dateCreated>
<dateModified>2013-05-08 14:38:06.132359</dateModified>
</head>
<body>
<outline text="CS : Ruby" title="CS : Ruby">
<outline htmlUrl="http://afreshcup.com/home/" text="A Fresh Cup" title="A Fresh Cup" type="rss" version="RSS" xmlUrl="http://afreshcup.com/home/rss.xml"/>
<outline htmlUrl="http://ruby.awsblog.com/blog/feed/recentPosts.rss" text="AWS Ruby Blog" title="AWS Ruby Blog" type="rss" version="RSS" xmlUrl="http://ruby.awsblog.com/blog/feed/recentPosts.rss"/>
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.define 'shortbus' do |c|
c.vm.box = "opscode-centos-5.5"
c.vm.box_url = "http://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-5.5.box"
c.vm.network :hostonly, "192.168.93.93"
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
cat sample_rails.log | ruby rails_multiline_log_splitter.rb > output
# ["Started GET \"/\" for 98.113.86.74 at Tue Sep 06 09:44:35 -0400 2011","Processing by LinksController#index as HTML","Completed 401 Unauthorized in 0ms"]
# ["Started GET \"/\" for 98.113.86.74 at Tue Sep 06 09:44:36 -0400 2011","Processing by LinksController#index as HTML","Rendered links/index.html.erb within layouts/main (227.1ms)","Completed 200 OK in 339ms (Views: 228.3ms | ActiveRecord: 21.0ms)"]
# ["Started GET \"/links/11\" for 98.113.86.74 at Tue Sep 06 09:44:52 -0400 2011","Processing by LinksController#show as HTML","Parameters: {\"id\"=>\"11\"}","Rendered links/show.html.erb within layouts/main (190.2ms)","Completed 200 OK in 194ms (Views: 191.1ms | ActiveRecord: 1.2ms)"]
# ["Started GET \"/links/search?utf8=%E2%9C%93&q=ruby+on+rails&commit=Search\" for 98.113.86.74 at Tue Sep 06 09:45:12 -0400 2011","Processing by LinksController#search as HTML","Parameters: {\"commit\"=>\"Search\", \"utf8\"=>\"✓\", \"q\"=>\"ruby on rails\"}"
def dotify(hash, k = [])
return {k.join('.') => hash} unless hash.is_a?(Hash)
hash.inject({}){ |h, v| h.merge! dotify(v[-1], k + [v[0]]) }
end
describe "dotify" do
let(:hash) { { foo: { bar: { baz: true } } } }
it "converts hash to dot notated keys" do
expect(dotify(hash)).to eq("foo.bar.baz" => true)