This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.8 | |
import sys | |
import re | |
def extract(s): | |
return [int(x) for x in re.findall(r'-?\d+', s)] | |
from z3 import Bool, Int, If, Not, Solver, And |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Fixer for six.iterkeys() -> .keys(), and similarly for iteritems and itervalues.""" | |
from lib2to3 import fixer_util, fixer_base | |
from lib2to3 import pytree | |
from lib2to3.fixes import fix_dict | |
from lib2to3.fixer_util import Call, Name | |
import libpostmodernize | |
class FixDict(fix_dict.FixDict): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signature UNLAMBDA_REPR = | |
sig | |
type F | |
val ap : F * F -> F | |
val ul_I : F | |
val ul_K : F | |
val ul_S : F | |
val ul_V : F | |
val ul_Dot : char -> F | |
val ul_C : F |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... don't do this | |
import sys | |
from types import ModuleType | |
def callme(): | |
print("lol I'm a module") | |
class CallableModule(ModuleType): | |
def __call__(self, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initial state: # | |
..... => . | |
....# => . | |
#.... => . | |
#...# => . | |
...#. => # | |
...## => # | |
#..#. => # | |
#..## => # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from types import MethodType | |
class strict_staticmethod: | |
def __init__(self, f): | |
self.f = f | |
def __get__(self, obj, type=None): | |
if obj is not None: | |
raise AttributeError("strict_staticmethod can't be accessed through obj") | |
return self.f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import cast | |
class Tree: | |
def accept(self, v: 'TreeVisitor') -> object: | |
pass | |
class Leaf(Tree): | |
def accept(self, v: 'TreeVisitor') -> object: | |
return v.visit_leaf(self) | |
class Node(Tree): | |
def __init__(self, value: int, left: Tree, right: Tree) -> None: | |
self.value = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LIST_H | |
#define LIST_H | |
#include <stddef.h> | |
/** | |
* @brief A list traversal field that can be embedded in objects. | |
*/ | |
typedef struct list_node { | |
struct list_node *next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LIST_H | |
#define LIST_H | |
#include <stddef.h> | |
/** | |
* @brief A list traversal field that can be embedded in objects. | |
*/ | |
typedef struct list_node { | |
/////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file variable_queue.h | |
* | |
* @brief Generalized queue module for data collection | |
* | |
* @author Michael Sullivan ([email protected]) | |
**/ | |
#include <stddef.h> | |
#include <stdlib.h> |