Skip to content

Instantly share code, notes, and snippets.

View jdoliner's full-sized avatar
💭
🐘

Joe Doliner jdoliner

💭
🐘
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#define mask(c) (1 << ('z' - c))
#define all (1 << (('z' - 'a') + 2)) - 1//bitmap when all the characters have been seen
int contains(char *haystack, char *needle) {
int seen = 0; //bitmap of characters we have been seen
class foo {
public:
foo(int) {}
foo(const foo&) {}
};
int main () {
foo b(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(1))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
}
@jdoliner
jdoliner / foo
Created October 7, 2011 16:01
foo
foo foo foo
@jdoliner
jdoliner / gist:1279629
Created October 11, 2011 22:17
Forever alone
class forever_alone {
friend class forever_alone;
};
int main() { }
Compiled under g++:
g++ forever_alone.cc -o forever_alone
forever_alone.cc:2: warning: class ‘forever_alone’ is implicitly friends with itself
@jdoliner
jdoliner / gist:1288379
Created October 14, 2011 21:18
json_spirit Object example
inline
std::string GetVillageOwnerJson(Player p, const std::vector<std::string> &properties)
{
json_spirit::Object root;
//std::vector< json_spirit::Pair > root;
BOOST_FOREACH(std::string f, properties)
{
if(IsValidPlayerProperty(f))
{
@jdoliner
jdoliner / gist:4227629
Created December 6, 2012 19:39
ReQL Golf
r.table(Build.__tablename__).get(build_id).update({'result': r['result'] + line}).run()
@jdoliner
jdoliner / gist:4229024
Created December 6, 2012 22:20
Clearer version
r.table(Build.__tablename__).get(build_id).update(lambda row: {'result': row['result'] + line}).run()
Exception in thread "main" java.io.FileNotFoundException: Could not locate leiningen/core/user__init.class or leiningen/core/user.clj on classpath: (protobuf.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:5441)
at clojure.lang.Compiler.eval(Compiler.java:5416)
at clojure.lang.Compiler.load(Compiler.java:5858)
at clojure.lang.RT.loadResourceScript(RT.java:340)
at clojure.lang.RT.loadResourceScript(RT.java:331)
at clojure.lang.RT.load(RT.java:409)
at clojure.lang.RT.load(RT.java:381)
at clojure.core$load$fn__4519.invoke(core.clj:4915)
at clojure.core$load.doInvoke(core.clj:4914)
r.table("table_name").filter(function(score) {
return score("scoreboard")("teamPlayerParticipantsStats")("externalizedData").type_of() == "ARRAY"
}
def sub_tasks(val, depth):
if depth > max_depth:
return r.branch(val["tasks"] == 0, [val["priority"]], r.error("depth exceeded"))
else:
return [val["priority"]] + val["tasks"].concat_map(lambda x: sub_tasks(x, depth + 1))
r.table("tasks").concat_map(lambda x: sub_tasks(x, 0)).reduce(lambda x,y, x + y).run()