Skip to content

Instantly share code, notes, and snippets.

test_compare.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <gt(xsimd::batch<int, xsimd::fma5>, xsimd::batch<int, xsimd::fma5>)>:
0: c5 fd 66 c1 vpcmpgtd ymm0,ymm0,ymm1
4: c3 ret
5: 66 66 2e 0f 1f 84 00 data16 nop WORD PTR cs:[rax+rax*1+0x0]
@tomjnixon
tomjnixon / decode.py
Last active November 26, 2018 09:30
scarf decode
import numpy as np
im_str = """
11111101 11111101 11111101
11111101 10001100 11000100
10110100 11011000 10101000
11101010 11111101 11000100
10111100 11100100 10111110
11111101 11000101 10110000
10101000 10111000 10101100
@tomjnixon
tomjnixon / .gitignore
Last active December 29, 2017 16:35
AOC 2017 solutions
private.py
*.pyc
.cache
@tomjnixon
tomjnixon / README.md
Created October 7, 2017 17:32
get a list of user-installed packages given an OPKG status file/output from an OpenWRT/LEDE device

This is not intended to be run on-device, but it might be usefull as part of a backup/upgrade process.

Packages are listed that:

  • are not depended on by any other package
  • were not installed within 5 minutes of the kernel (which can't be upgraded without building a new image)

Obviously this is a quick hack, YMMV.

Usage

cons = lambda a, b: lambda x: a if x else b
Y = lambda f: (lambda x: f(lambda y: x(x)(y)))(lambda x: f(lambda y: x(x)(y)))
pretty = lambda l: "(" + Y(lambda f: lambda l: cons(lambda: str(l(1)) + cons(" ", "")(l(0)) + f(l(0)), lambda: ")")(l)())(l)
reverse = Y(lambda f: lambda k: lambda l: cons(lambda: f(cons(l(1), k))(l(0)), lambda: k)(l)())(None)
assert pretty(cons(1, cons(2, cons(3, None)))) == "(1 2 3)"
assert pretty(reverse(cons(1, cons(2, cons(3, None))))) == "(3 2 1)"
template <typename T>
struct Foo {
T *x;
Foo(T *x) : x(x) {}
// operator Foo<const T> () const { return Foo<const T>(x); }
};
template <typename T>
@tomjnixon
tomjnixon / bench_parse.rb
Last active December 31, 2015 17:49
Benchmark for SPARQL results parsing.
require 'sparql/client'
require 'benchmark'
def generate(n)
parts = []
parts << '<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="a"/>
<variable name="b"/>
@tomjnixon
tomjnixon / gist:6451920
Created September 5, 2013 15:41
crappy bot
class Tomninator < RTanque::Bot::Brain
NAME = 'tomninator'
include RTanque::Bot::BrainHelper
def initialize(*args)
super *args
@scan_state = "scan"
@direction = 0
end
@tomjnixon
tomjnixon / SConstruct
Created March 9, 2013 17:20
Arduino controller for radio controlled sockets based on SC5272; mane are made by Lloyotron.
env = Environment(tools=["default", "arduino"])
env.ConfigureBoard("atmega328")
core = env.ArduinoCore()
sketch = env.Sketch("test", ["test.cpp", core])
env.Upload(sketch)
@tomjnixon
tomjnixon / async_utils.py
Created December 28, 2012 01:32
A module to make writing tests that deal with asynchronous things easier.
import unittest
# A module to make writing tests that deal with asynchronous things easier.
def async(f):
"""Decorator to use on any test case that uses assertCalled or
assertNotCalled."""
def g(self):
# run_after is a list of functions to run after the test case. We clear it
# before and after running the test case so that AsyncTestCase can see that