Skip to content

Instantly share code, notes, and snippets.

/* Outputs gem filenames from spec files.
* Full set of public gems:
* https://rubygems.org/specs.4.8
* + https://rubygems.org/prerelease_specs.4.8
*/
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyObject;
import org.jruby.runtime.marshal.UnmarshalStream;
#!/usr/bin/env ruby
require 'json'
VERBOSE = (ARGV.include? '-v')
rules = JSON::parse(File.read('/etc/oomsaver.json')).collect do |re, score|
[Regexp.new(re), score]
end
> lein deploy
No credentials found for releases
See `lein help deploy` for how to configure credentials.
Username: pcarrier
java.lang.NullPointerException
at leiningen.deploy$add_auth_interactively.invoke(deploy.clj:49)
at leiningen.deploy$repo_for.invoke(deploy.clj:60)
at leiningen.deploy$deploy.invoke(deploy.clj:156)
at leiningen.deploy$deploy.invoke(deploy.clj:146)
at clojure.lang.Var.invoke(Var.java:415)
# Setup
sudo ipvsadm -C
sudo ipvsadm -R <<EOF
-A -t 169.254.254.1:80
-a -t 169.254.254.1:80 -r 173.194.41.131:80 -m
EOF
# Add a host
sudo ipvsadm -R <<EOF
-a -t 169.254.254.1:80 -r 173.194.41.132:80 -m
bash-3.2$ cat foo.json
{
"a":"hello world",
"b":"bar"
}
bash-3.2$ eval $(ruby -rshellwords -rjson -e 'JSON::load(STDIN).each {|k,v| puts "export #{Shellwords.shellescape(k)}=#{Shellwords.shellescape(v)}"}' < foo.json)
@pcarrier
pcarrier / fixdns.sh
Created May 14, 2013 14:16
Tired of changing the search domains under OSX?
#!/bin/sh
networksetup -listallnetworkservices | while read s; do sudo networksetup -setsearchdomains "$s" {foo,bar}.example.com; done
package com.airbnb.tins.api
import io.netty.handler.codec.{LengthFieldPrepender, LengthFieldBasedFrameDecoder}
import io.netty.channel._
import org.xbill.DNS.{Record, Section, Flags, Message}
import java.net.{InetSocketAddress, SocketAddress}
import io.netty.handler.logging.{LoggingHandler, LogLevel}
import io.netty.handler.codec.bytes.ByteArrayEncoder
import io.netty.bootstrap.ServerBootstrap
import io.netty.channel.nio.NioEventLoopGroup
#!/bin/sh
set -e
log() {
str="alpbs: $1\n"
shift
printf "$str" "$@" >&2
}
require 'benchmark'
def direct
end
def simple
direct
end
def stupid
destroy_instance.rb:
#!/usr/bin/env ruby
EventBusWorker.new do |e|
msg = e.publish 'destroy_instance', {:id => ARGV[1]}
e.wait_for 'aws_destroyed', {:req => msg}
e.wait_for 'scout_removed', {:req => msg}
end
aws_destroyed.rb: