Skip to content

Instantly share code, notes, and snippets.

Avatar

Miles Rout milesrout

View GitHub Profile
@milesrout
milesrout / union.c
Last active Aug 22, 2020
Object system A or B?
View union.c
enum object_type { INT, CSTR };
struct object {
int type;
union {
int intvalue;
const char *cstrvalue;
};
};
int
object_equal(struct object *l, struct object *r)
View gist:aa6f8f807e622b55c30e3a9151e7d8b2
File "./beetle.py", line 157, in process_phases
return pipeline.execute()
File "./beetle.py", line 238, in execute
result = getattr(self, phase.lower())(result)
File "./beetle.py", line 259, in imports
ast = self.import_handler.process(ast, **kwds)
File "/home/miles/programming/beetle/importer.py", line 52, in process
return self.expand(ast)
File "/home/miles/programming/beetle/importer.py", line 74, in imexpand_ImportStatement
modules.append(self.handler.load_module(name.name, ast.pos))
View chess.txt
r n . . k b n r
a . q . a a . a
B a . . . . . .
. . a . A . a .
. . A . . A . .
. . . . . . . .
A A . . . . A A
R N B Q K . N R
Choose a move: Bb5
View mergesort.cpp
template <typename, typename> struct is_less_than;
template <int X, int Y> struct is_less_than<Int<X>, Int<Y>> : std::bool_constant<(X < Y)> {};
template <typename A, typename B> static constexpr bool is_less_than_v = is_less_than<A, B>::value;
template <typename, typename, typename=void> struct do_merge;
template <typename As, typename Bs> using merge = typename do_merge<As, Bs>::type;
// Need this because specialisations are chosen by specificity and
// ties are broken not by order but by compiler error.
template <>
@milesrout
milesrout / list-focused-fftabs.py
Last active Nov 29, 2019 — forked from tmonjalo/list-fftabs.py
List currently focused Firefox tabs
View list-focused-fftabs.py
#! /usr/bin/env python3
"""
List all Firefox tabs with title and URL
Supported input: json or jsonlz4 recovery files
Default output: title (URL)
Output format can be specified as argument
"""
View better.c
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
double sx, double sy, double *sub_x, double *sub_y) {
// Do stuff
}
View mcts.py
"""Investigating and implementing MCTS without the complications of the MTG simulator."""
from collections import Counter
from copy import deepcopy
import math
import random
import cProfile
compose = lambda f: lambda g: lambda *args, **kwds: f(g(*args, **kwds))
View unknown.asm
; %n - fp register n
; @n - int register n
; $n - lit int n
initial f32 top, left, bottom, right, 16.0f;
final f32 result[256];
ld %0,$0 ; %0 = top
ld %1,$1 ; %1 = left
ld %2,$2 ; %2 = bottom
View actuallygood.agda
data _⊔_is_ : Set where
m≥⊔nism : {m n : ℕ}
n ≤ m
---------
m ⊔ n is m
m≤⊔nisn : {m n : ℕ}
m ≤ n
---------
m ⊔ n is n
View meme.agda
data : Set where
zero :
suc :
{-# BUILTIN NATURAL ℕ #-}
data _≤_ : Set where
z≤n : {n : ℕ}
-------
zero ≤ n