Skip to content

Instantly share code, notes, and snippets.

@refi64
refi64 / Jamroot
Created February 12, 2015 20:49
AsmJit build system with Boost.Build
import option ;
import package ;
import regex ;
local embed = [ option.get embed : 0 ] ;
local xprops = ;
if embed in 1 true yes {
xprops = "<link>static" ;
@refi64
refi64 / c++-string-bench.cpp
Created March 6, 2015 22:22
C++ string implode benchmark
/*
This is a simple benchmark of the C++ string implode algorithms as stated at
http://stackoverflow.com/questions/5689003/
how-to-implode-a-vector-of-strings-into-a-string-the-elegant-way.
This uses Celero.
Results on my machine, compiling with Clang SVN and -O3:
[==========]
[ CELERO ]
@refi64
refi64 / ln
Last active August 29, 2015 14:20
Hy line number solver
#!/bin/sh
if [ -z "$1" ] || [ -z "$2" ]; then
echo "usage: $0 <file> <line>"
exit 1
fi
line=`expr $2 - \( $2 / 256 \* 256 \) + \( $(wc -l < $1) / 256 \* 256 \)`
echo "$line: `sed ${line}q\;d $1 | sed 's/^[ \t]*//;s/[ \t]*$//'`"
@refi64
refi64 / felix.flx
Last active August 29, 2015 14:21
Felix entry for "Four MLs (and a Python)"
fun add_to(totals: list[float])(values: list[float]) =>
if values.len != 1.size then let n = totals.len in match n with
| 0uz => values
| $(values.len) => (add of (float^2)).map $ totals.zip2 values
// this ugliness is because of a bug in Felix that generates invalid C++ code
// see https://github.com/felix-lang/felix/issues/71
| _ => #(fun () = { raise "Inconsistent-length rows"; return #list[float]; })
endmatch else totals;
fun add_line_to(totals: list[float])(line: string) =>
@refi64
refi64 / haskell.hs
Created May 14, 2015 21:35
Haskell version of "Four MLs (and a Python)"
import Control.Applicative
import System.Environment
import Data.List.Split
import Data.List
-- the ":: [Float]" prevents the type inferencer from going haywire
addTo [] v = v :: [Float]
addTo t v
| length t == length v = zipWith (+) t v
| otherwise = error "Inconsistent-length rows"
def fuzzyfinder(p, l):
return map(lambda t: t[0], sorted(filter(lambda t: all(map(lambda x: x != -1, t[1])), map(lambda s: (s,map(s.find, p)), l)), key=lambda t: t[1]))
@refi64
refi64 / word.k
Created March 8, 2016 21:44
Surrounds the input words with quotes and puts them (comma-seperated) into 84-column lines
w:0:"/dev/stdin"
`0:(" ",)'{y:"'",y,"', ";:[80<(#y)+#*|x;x,,y;:[#x;(-1_ x),,(*|x),y;,y]]}/(,()),{:[(*|x)~(#*|x)#y;(-1_ x),(,y),(-1#x);x,,y]}/(,()),?w@<w
import re
def myfunc(s):
m = re.match(r'^(.+?)\1+$', s)
return len(s)/len(m.groups()[0])
print(myfunc('abccbaabccba'))
print(myfunc('abcabcabcabc'))
@refi64
refi64 / flashinst.sh
Last active October 29, 2018 18:50
Install Flash on Chromium OS
# INSTRUCTIONS:
# Enter the terminal (Ctrl-Alt-F2, username is "chronos" and password is either blank or "password" for ArnoldTheBat's builds) and run:
#
# curl -L https://goo.gl/BBV79Q | sudo bash
#
# to install. You'll likely have to re-enter the password "password".
# Attempts to grab the latest Flash version straight from Adobe's website.
# Should be a bit more bullet-proof than some of the other flash installer scripts.
@refi64
refi64 / config.rst
Last active April 23, 2023 14:24
Configuring evdev RPCS3 joysticks

Configuring evdev RPCS3 joysticks

The evdev joystick code in RPCS3 is primarily designed to use XBox controllers by default. For other controllers, you'll probably need to make a few changes.

The config file

Configuration is stored in $HOME/.config/rpcs3/config_linuxjoystick.yml. The easiest way to test your joystick is with the PS3 Game Pad Test homebrew.