Skip to content

Instantly share code, notes, and snippets.

@gruis
gruis / afp.conf
Created March 11, 2016 04:48 — forked from dinigo/afp.conf
Install netatalk (afp) in Ubuntu with service announcing and provide a Time Machine share. Users must belong to `timemachine` group to be allowed to use it.
[TimeMachine]
path = /store/time-machine
time machine = yes
valid users = @timemachine
@gruis
gruis / dirtycop
Last active April 17, 2019 05:24 — forked from skanev/rubocop.rb
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#
require 'rubygems'
require 'eventmachine'
children = []
Signal.trap('SIGINT') do
EventMachine.next_tick { EventMachine.stop_event_loop }
end
Signal.trap('EXIT') do
require 'rubygems'
require 'eventmachine'
children = []
Signal.trap('SIGINT') do
EventMachine.next_tick { EventMachine.stop_event_loop }
end
Signal.trap('EXIT') do
@gruis
gruis / gist:1840492
Created February 16, 2012 01:06 — forked from pwim/gist:1188099
Trying different encodings under Ruby 1.9
escaped = CGI.unescape(query)
return escaped if escaped.valid_encoding?
%w[EUC-JP Shift_JIS].each do |encoding|
s = escaped.force_encoding(encoding)
return s.encode("UTF-8") if s.valid_encoding?
end
escaped
@gruis
gruis / popen3.rb
Created November 2, 2011 11:32 — forked from tokland/external-command.rb
Capture stderr data on EventMachine.popen
#!/usr/bin/env ruby -wW1
require 'eventmachine'
module EventMachine
# @see http://eventmachine.rubyforge.org/EventMachine.html#M000491
def self.popen3(cmd, handler=nil, *args)
klass = klass_from_handler(Connection, handler, *args)
w = Shellwords::shellwords(cmd)
w.unshift(w.first) if w.first