Skip to content

Instantly share code, notes, and snippets.

@Mortal
Mortal / gist:2896014
Created June 8, 2012 14:53
17-byte items in TPIE
00200f00 00 00 00 0b 4f cf 01 00 00 00 00 46 e2 b5 ba bf |....O......F....|
00200f10 7f 00 00 00 0c 4f cf 01 00 00 00 00 46 e2 b5 ba |.....O......F...|
00200f20 bf 7f 00 00 00 0d 4f cf 01 00 00 00 00 46 e2 b5 |......O......F..|
00200f30 ba bf 7f 00 00 00 0e 4f cf 01 00 00 00 00 46 e2 |.......O......F.|
00200f40 b5 ba bf 7f 00 00 00 0f 4f cf 01 00 00 00 00 46 |........O......F|
00200f50 e2 b5 ba bf 7f 00 00 00 10 4f cf 01 00 00 00 00 |.........O......|
00200f60 46 e2 b5 ba bf 7f 00 00 00 11 4f cf 01 00 00 00 |F.........O.....|
00200f70 00 46 e2 b5 ba bf 7f 00 00 00 12 4f cf 01 00 00 |.F.........O....|
00200f80 00 00 46 e2 b5 ba bf 7f 00 00 00 13 4f cf 01 00 |..F.........O...|
00200f90 00 00 00 46 e2 b5 ba bf 7f 00 00 00 14 4f cf 01 |...F.........O..|
set nocompatible modeline cindent cino+=(0 lbr ruler
set termencoding=utf8 encoding=utf8 t_Co=256
set mouse=a
set go-=egmrLtT go+=c
colo slate
set bg=dark
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
inoremap jk 
@Mortal
Mortal / gist:3806348
Created September 30, 2012 09:43
Gauss elimination with XOR
void gauss(vector<size_t> & nums) {
for (size_t bit = 63; bit--;) {
size_t findmask = 1ull << bit;
size_t maxmask = 2*findmask-1;
// search for number with given highest bit,
// i.e. a number with `findmask` not greater than `maxmask`
size_t j = 0;
while (j < nums.size()) {
if (nums[j] & findmask && nums[j] <= maxmask) break;
++j;
@Mortal
Mortal / gist:3859530
Created October 9, 2012 15:28
java.lang.Object
(Types.Class
{ Types.class_final = false;
Types.class_abstract = false;
Types.class_name = "Object";
Types.class_extends = (CanonicalName.make "java.lang.Object");
Types.class_implements = [];
Types.class_members = [
(methd_final "wait" (Types.Base Ast.Void) [] [
(CanonicalName.make "java.lang.InterruptedException")
]);
@Mortal
Mortal / gist:3859748
Created October 9, 2012 16:04
Time to dOvs test
On commit 9969f79 (dump_typename branch off master)
[rav@gonzales:~/dOvs/project]$ time ./runtests -1 -p WNEH tests
real 1m10.840s
user 0m57.973s
sys 0m13.219s
On commit 70ee0a9 (master branch)
real 1m24.931s
user 1m9.739s
sys 0m15.526s
@Mortal
Mortal / auth.wsgi
Created February 17, 2013 15:58
Django password protection with Apache basic protection
import os, sys
here = lambda * x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x)
sys.path.append(here('venv/lib/python2.6/site-packages'))
sys.path.append(here('web'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'mftutor.settings'
from django.contrib.auth.models import User
from django import db
@Mortal
Mortal / enumclass_state.patch
Created February 21, 2013 09:25
Patch required to change worker_state to class enum, and the resulting parallel.h file. See also https://github.com/thomasmoelhave/tpie/issues/52
diff --git a/tpie/pipelining/parallel.h b/tpie/pipelining/parallel.h
index b3735a4..716c434 100644
--- a/tpie/pipelining/parallel.h
+++ b/tpie/pipelining/parallel.h
@@ -125,22 +125,24 @@ struct options {
///////////////////////////////////////////////////////////////////////////////
/// \brief States of the parallel worker state machine.
///////////////////////////////////////////////////////////////////////////////
-enum worker_state {
+struct worker_state {
std::vector<double> loMem(m_nodes.size());
std::vector<double> hiMem(m_nodes.size());
std::vector<double> prio(m_nodes.size());
for (size_t i = 0; i < m_nodes.size(); ++i) {
loMem[i] = static_cast<double>(m_nodes[i]->get_minimum_memory()) / m;
prio[i] = m_nodes[i]->get_memory_fraction() / fraction;
memory_size_type hi = m_nodes[i]->get_maximum_memory();
if (hi == 0)
hiMem[i] = 1.0;
void phase::assign_memory(memory_size_type m) const {
{
dfs_traversal<phase::node_graph> dfs(*itemFlowGraph);
dfs.dfs();
std::vector<node *> order = dfs.toposort();
for (size_t i = 0; i < order.size(); ++i) {
if (order[i]->get_state() != node::STATE_FRESH) {
throw call_order_exception(
"Tried to call prepare on an none fresh node");
}
@Mortal
Mortal / madsfoek.py
Last active December 14, 2015 20:48
import logging
from lamson.routing import route, route_like, stateless
from config.settings import relay
from config import settings
from lamson import view, mail
recipients = {
'red': frozenset(['foo@bar.com', 'baz@example.com']),
'chefred': frozenset(['christina@gottsche.com']),
}