Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Hacking

Bart Wiegmans bdw

💭
Hacking
View GitHub Profile
@bdw
bdw / ve.py
Created Feb 14, 2014
Really easy virtualenv wrapper
View ve.py
#!/usr/bin/env python
import argparse
import os
import os.path
import sys
import subprocess
import shutil
try:
import virtualenv
View proposal-gsoc-2014.html
<h3>What is your e-mail address and IRC nick?</h3>
<p>bartwiegmans@gmail.com, brrt on freenode</p>
<h3>What is your web page, blog, or microblog?</h3>
<p><a href="https://plus.google.com/u/0/+BartWiegmans/posts">I have a google+ page</a> - although I don't actually post a lot of things there.</p>
@bdw
bdw / compact.py
Created Mar 21, 2014
An algorithm to compact arrays (python). I figured it out but I can't explain why it works.
View compact.py
def compact(a_list):
# strategy - find the first empty and nonempty items
empty, nonempty = 0, 0
while empty < len(a_list) and nonempty < len(a_list):
# ok, so in principle this works really well... why?
# what happens is that nonempty looks for the earliest nonempty
# element and empty looks for the earliest empty element
if a_list[nonempty] is None:
nonempty += 1
@bdw
bdw / broken-re.py
Created Mar 25, 2014
showing python re is subtly broken
View broken-re.py
#!/usr/bin/env python
import re
s = r'"foo \" bar" baz "quix"'
# same regex right?
p_a = r'"(\\"|[^"])*"'
p_b = r'"([^"]|\\")*"'
# no
print(re.match(p_a, s).group(0))
@bdw
bdw / buffer.c
Created Apr 29, 2014
Proposed 'pointer buffer' implementation - pointer buffers are extremely common in moarvm
View buffer.c
#include <stdlib.h>
struct MVMPointerBuffer {
union {
void ** v;
MVMObject **objects;
MVMCollectable **collectables;
MVMSpeshBB **spesh_bbs;
/* some other common pointer types */
} p;
View example.dasc
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
/* note - for windows this is different */
#include <sys/mman.h>
#include "dynasm/dasm_proto.h"
#include "dynasm/dasm_x86.h"
// DynASM directives.
@bdw
bdw / response.md
Created Jun 11, 2014
Mike Palls DynASM response
View response.md

ARM

ARM should be relatively straightforward:

You'll need to move the shifting into parse_gpr() and parse_vr() in dasm_arm.lua. These should use waction() to emit a (new) VREG op for dynamic registers. The VREG op needs to know the shift amounts for merging the register number. Note that FPRs require an extra bit at a different shift position.

@bdw
bdw / getcodeobj.patch
Created Aug 29, 2014
getcodeobj patch
View getcodeobj.patch
diff --git a/src/core/frame.c b/src/core/frame.c
index 7669e39..41673b1 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -843,6 +843,8 @@ void MVM_frame_unwind_to(MVMThreadContext *tc, MVMFrame *frame, MVMuint8 *abs_ad
/* Gets a code object for a frame, lazily deserializing it if needed. */
MVMObject * MVM_frame_get_code_object(MVMThreadContext *tc, MVMCode *code) {
+ if (REPR(code)->ID != MVM_REPR_ID_MVMCode)
+ MVM_exception_throw_adhoc(tc, "getcodeobj needs a code ref");
@bdw
bdw / 122504.patch
Created Aug 31, 2014
fix bug 122504
View 122504.patch
diff --git a/src/vm/moar/ops/perl6_ops.c b/src/vm/moar/ops/perl6_ops.c
index 65eeb27..3599cd5 100644
--- a/src/vm/moar/ops/perl6_ops.c
+++ b/src/vm/moar/ops/perl6_ops.c
@@ -462,8 +462,9 @@ static MVMuint8 s_p6routinereturn[] = {
MVM_operand_obj | MVM_operand_read_reg,
};
static void p6routinereturn(MVMThreadContext *tc, MVMuint8 *cur_op) {
- MVMObject *ret = MVM_frame_find_lexical_by_name_rel_caller(tc, str_return,
- tc->cur_frame)->o;
@bdw
bdw / .gitignore
Last active Aug 29, 2015
Java Multicast Example