Skip to content

Instantly share code, notes, and snippets.

View samgiles's full-sized avatar
🗺️

Sam Giles samgiles

🗺️
View GitHub Profile
@samgiles
samgiles / gist:9711796
Created March 22, 2014 18:17
RPython Error
def _malloc_signed(initial_value):
SIGNEDP = lltype.Array(lltype.Signed)
value = lltype.malloc(SIGNEDP, 1, flavor="raw")
value[0] = initial_value
return value
-----------------------------------------------------------------------------------------------
[translation:info] assert not signature.has_kwarg() # XXX should not happen?
[translation:ERROR] AssertionError
[translation:ERROR] Processing block:
@samgiles
samgiles / gist:9856834
Last active August 29, 2015 13:57
Steps to reproduce JIT memory errors
make wlvlang-jit PYPYPATH=~path/to/pypy
# This should pass
make test_all_jit
# Unfortunately the path to the script needs to be relative! (I should fix that)
bin/wlvlang-jit tests/benchmarks/thread-ring.wl 10 10
# This should cause a segfault or:
#
@samgiles
samgiles / gist:9994055
Last active August 29, 2015 13:58
auto-vectorisation example in GCC
void test_vec(double* restrict a, double* restrict b) {
int i;
double *x = __builtin_assume_aligned(a, 16);
double *y = __builtin_assume_aligned(b, 16);
for(i = 0; i < SIZE; i++) {
x[i] = x[i] + y[i];
}
}
@samgiles
samgiles / gist:11173191
Last active August 29, 2015 14:00
Get the current Python path as a string with correct path separator
import sys
import os
def pythonpath():
# Remove filter if you don't care about cases such as: ':/path::', where members of the path are
# empty. It would be slightly faster to complete this operation if the filter was not run but the size of the
# input is likely to be small
os.pathsep.join(filter(lambda path: len(path) > 0, sys.path))
@samgiles
samgiles / test.occ
Created April 23, 2014 12:27
Simple producer, consumer example [occam-pi]
#include "course.module"
PROC producer(VAL INT start, step, CHAN OF INT c!)
INT count:
SEQ
count := start
WHILE TRUE
SEQ
c ! count
count := count + step
@samgiles
samgiles / gist:11214993
Created April 23, 2014 13:22
Full example of 'channel poisoning' for producer channels using a control channel [occam-pi]
#INCLUDE "course.module"
PROTOCOL CONTROL
CASE
poison
:
PROTOCOL TAGGED.INT
CASE
normal; INT
@samgiles
samgiles / dom_recycler
Created July 17, 2014 15:42
Old DOM Element recycling test
<!DOCTYPE html>
<html>
<head>
<title>DOM Recycler</title>
<style>
/* Styles not relevant to scrolling (just to make the demo look neat and tidy) */
body { font-family: sans-serif; -webkit-text-size-adjust: 100% }
#
var resolvedPolyfills = {};
polyfills.forEach(function(polyfill) {
resolvers.forEach(function(resolver) {
resolver(polyfill).forEach(function(targetPolyfill) {
resolvedPolyfills[targetPolyfill.name] = targetPolyfill
})
})
});
@samgiles
samgiles / npmcleaner
Created August 1, 2014 13:30
Remove all Node modules safely
# Not global:
npm ls -p --depth=0 | awk -F/node_modules/ '{print $2}' | grep -vE '^(npm)$' | xargs npm rm
# Global:
npm ls -gp --depth=0 | awk -F/node_modules/ '{print $2}' | grep -vE '^(npm)$' | xargs npm -g rm
Set up key for github
make sure brew is installed
make sure git is installed with brew
(Sourcetree issues..) Use HTTPS (Auth issues are just too much) Github for Mac
git clone at the command line?
try `sudo gem install ruby` if failed:
rvm install ruby