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
//#! scalac -classpath js.jar sketch.scala && java -classpath .:/opt/local/share/scala/lib/scala-library.jar:js.jar Main # | |
// http://codeutopia.net/blog/2009/01/02/sandboxing-rhino-in-java/ | |
import java.lang.System | |
import org.mozilla.javascript._ | |
class SandboxNativeJavaObject (scope: Scriptable, javaObject: Object, staticType: Class[_]) | |
extends NativeJavaObject(scope, javaObject, staticType) { | |
override def get (name: String, start: Scriptable):Object = null | |
} |
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
package net.thumbtack.onepm.server; | |
import net.thumbtack.onepm.thrift.FbUser; | |
import net.thumbtack.onepm.thrift.User; | |
import net.thumbtack.onepm.thrift.UserNotFoundException; | |
import org.apache.thrift.TException; | |
import org.apache.thrift.protocol.TBinaryProtocol; | |
import org.apache.thrift.transport.TFramedTransport; | |
import org.apache.thrift.transport.TSocket; | |
import org.apache.thrift.transport.TTransportException; |
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
databaseChangeLog() { | |
changeSet(id: "my first changeset", author: "daniel") { | |
comment('A comment') | |
createTable(tableName: 'my_table') { | |
column(name: 'id', type: 'uuid', defaultValue: 'uuid_generate_v4()') { | |
constraints(primaryKey: true, nullable: false) | |
} | |
column(name: 'name', type: 'character varying(100)') { | |
constraints(nullable: false) | |
} |
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 com.google.gson.*; | |
import com.google.gson.reflect.TypeToken; | |
public class ConversionUtils { | |
// both | |
private static Type typeB = new TypeToken<SpellData>() { }.getType(); | |
private static Gson gson; | |
static { |
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.util.HashMap; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Map.Entry; | |
import org.hyperic.sigar.NetFlags; | |
import org.hyperic.sigar.NetInterfaceConfig; | |
import org.hyperic.sigar.NetInterfaceStat; | |
import org.hyperic.sigar.Sigar; |
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 'net/telnet' | |
cache_dump_limit = 100 | |
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3) | |
slab_ids = [] | |
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c| | |
matches = c.scan(/STAT items:(\d+):/) | |
slab_ids = matches.flatten.uniq | |
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
/** | |
* <b>Fixed Point Combinator is:</b> | |
* Y = λf.(λx.f (x x)) (λx.f (x x)) | |
* | |
* <b>Proof of correctness:</b> | |
* Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y) | |
* = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g) | |
* = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable) | |
* = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function) | |
* = g (Y g) (by second equality) [1] |
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
int bigOrLitteEndian() { | |
short int word = 0x0001; | |
char *byte = (char *) &word; | |
return (byte[0] ? 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
#!/usr/bin/env escript | |
-mode(compile). | |
-compile(export_all). | |
main([]) -> io:format("Usage: ~s URL [Count=1000]~n", [escript:script_name()]); | |
main([URL]) -> main([URL,"100"]); | |
main([URL,C] ) -> manage_workers(URL, [start_worker(URL, N) || N <- lists:seq(1,list_to_integer(C))]), ok. |
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
////////////////////////////////////////////////////////////// | |
// Java version | |
// this is an interface with just one method, apply() from | |
// https://code.google.com/p/guava-libraries/ | |
import com.google.common.base.Function; | |
import junit.framework.TestCase; | |
public class YCFun extends TestCase { |
OlderNewer