This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExceptionWithACause < StandardError | |
attr_reader :cause | |
def initialize(message = nil, cause = nil) | |
@message = message | |
@cause = cause | |
super(message) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn enum-ordinal [^Enum x] | |
(.ordinal x)) | |
(defn enum-cmp [cmp & xs] | |
(apply cmp (map enum-ordinal xs))) | |
(defmacro defenumop [cmp] | |
`(def ~(symbol (str "enum" cmp)) | |
(partial enum-cmp ~cmp))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import org.apache.thrift.protocol.TBinaryProtocol; | |
import org.apache.thrift.protocol.TProtocol; | |
import org.apache.thrift.transport.TFastFramedTransport; | |
import org.apache.thrift.transport.TIOStreamTransport; | |
import org.apache.thrift.transport.TTransport; | |
import org.newsclub.net.unix.AFUNIXServerSocket; | |
import org.newsclub.net.unix.AFUNIXSocket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURAL LANGUAGE 'plpythonu'; | |
CREATE OR REPLACE FUNCTION gethostbyaddr(address text) | |
RETURNS text | |
LANGUAGE plpythonu | |
AS $$ | |
import socket | |
try: | |
return socket.gethostbyaddr(address)[1][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang rackjure | |
(require net/url) | |
(define js-lisps* | |
(~>> "https://gitorious.org/moritz-stuff/js-lisps/blobs/raw/master/js-lisps.sxml" | |
string->url | |
get-pure-port | |
read)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> Cons<T>(T head, IEnumerable<T> tail) | |
{ | |
yield return head; | |
foreach (var t in tail) yield return t; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "libvirt" | |
def vm_sync_shutdown(name) | |
conn = Libvirt::open("qemu:///system") | |
dom = conn.lookup_domain_by_name(name) | |
# TODO: Use dom.state instead of dom.info.state when it gets available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro throwf [class-name format & args] | |
`(throw (new ~class-name (format ~format ~@args)))) | |
; Before: | |
(throw (IllegalArgumentException. (format "Invalid value: %s" value))) | |
; After: | |
(throwf IllegalArgumentException "Invalid value: %s" value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Follow-File([string] $path) { Get-Content -Path $path -Wait -Tail 10 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def authorizationPlugin: BrokerPlugin = { | |
val dsl = new AuthorizationDSL; import dsl._ | |
val system = Set(User("system")) | |
entry(Queue(">"), r = system, w = system, a = system) | |
entry(Topic(">"), r = system, w = system, a = system) | |
Seq("test").foreach { basename => | |
val client = Set(User(basename + "-client")) |