Skip to content

Instantly share code, notes, and snippets.

View llllllllll's full-sized avatar

Joe Jevnik llllllllll

View GitHub Profile
"""Example
.. code-block:: python
In [1]: a = Expensive(1, b=2)
In [2]: type(a)
Out[2]: __main__.LazyProxy
In [3]: a.method(3)
@llllllllll
llllllllll / alist.cc
Created December 23, 2016 02:20
association list for types in C++
#include <type_traits>
#include <utility>
namespace association_list {
template<typename... Ps>
struct alist {};
namespace dispatch {
template<typename A, typename K>
struct lookup {};
$ ./ts < ts.c
2016-12-13 14:52:33-0500 #include <stdlib.h>
2016-12-13 14:52:33-0500 #include <stdio.h>
2016-12-13 14:52:33-0500 #include <time.h>
2016-12-13 14:52:33-0500
2016-12-13 14:52:33-0500 int main(void) {
2016-12-13 14:52:33-0500 char c;
2016-12-13 14:52:33-0500 time_t t;
2016-12-13 14:52:33-0500 struct tm *tm;
2016-12-13 14:52:33-0500 char buf[BUFSIZ];
@llllllllll
llllllllll / hook.py
Last active March 23, 2016 22:11
Inject a function call into an existing function (like a breakpoint)
from codetransformer import CodeTransformer, pattern
from codetransformer.patterns import matchany, var, option
from codetransformer.instructions import (
CALL_FUNCTION,
LOAD_CONST,
NOP,
POP_TOP,
POP_JUMP_IF_FALSE,
)
from codetransformer.utils.instance import instance
#pragma once
#include <array>
#include <tuple>
#include <Python.h>
#include "utils.h"
namespace pyutils {

Keybase proof

I hereby claim:

  • I am llllllllll on github.
  • I am llllllllll (https://keybase.io/llllllllll) on keybase.
  • I have a public key ASC131rrl_GjKcDya5zfqv148745F886J8bS7ysaNnPJCAo

To claim this, I am signing this object:

@llllllllll
llllllllll / b.py
Last active December 14, 2015 23:15
"""
Example
-------
In [1]: from b import _t
In [2]: _t[1 ::]
File "<string>", line unknown
SyntaxError: type assertions must use 'a :: b' syntax
@llllllllll
llllllllll / a.py
Created December 14, 2015 22:41
quick nse with lazy
'''
Examples
--------
In [1]: a
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-60b725f10c9c> in <module>()
----> 1 a
#include <stdio.h>
typedef int (*t)(int);
t f(int a) {
int g(int b) {
return a + b;
}
return g;
}
from itertools import chain
from types import FunctionType, BuiltinMethodType, BuiltinFunctionType
from codetransformer import Code, CodeTransformer
from codetransformer.instructions import (
CALL_FUNCTION,
DELETE_DEREF,
DELETE_GLOBAL,
DELETE_NAME,
JUMP_ABSOLUTE,