Skip to content

Instantly share code, notes, and snippets.

@Lapin0t
Lapin0t / mongodb_match.py
Last active July 9, 2018 10:44
mongoDB-style json querying in python
from functools import reduce
import re
_TYPES = {'string': str, 'int': int, 'object': dict, 'array': list,
'bool': bool, 'null': type(None)}
_OPS = {'$eq': lambda s, d: s == d,
'$gt': lambda s, d: d > s,
'$gte': lambda s, d: d >= s,
@Lapin0t
Lapin0t / mcculloch.py
Created August 24, 2016 15:34
An implementation of McCulloch's machine from Smullyan's book "What Is the Name of This Book?"
from re import match as _m
calcule=(lambda n,machine='machi'
'ne-1': ( lambda m:(lambda
f:(lambda x: x(x))(lambda
x:f(lambda v: (x(x ))(v))))(
lambda f:lambda x:(lambda r:r
.group(1) if r else m[1][x[
0]](f(x[1:])) )(_m(m[0],x)
))(n) if _m( r'[{}]*{}'.
format( ''. join(m[1])
(lambda x: lambda y: y)(__import__('sys').setrecursionlimit(2**31-1))((lambda
z: (lambda s: (lambda h: (lambda j: (lambda o: (lambda d: (lambda t: (lambda
e: (lambda g: (lambda k: (lambda l: (lambda m: (lambda n: (lambda q: (lambda
r: (lambda l: (lambda v: (lambda a: (lambda p: print(a(e(p)), a(g(p)))))(lambda
x: e(x)(lambda x: x+1)(g(x)(lambda x: x-1)(0)))(v(lambda x: lambda y: (lambda
w: v(lambda p: lambda a: v((lambda u: u(u))(lambda u: (lambda f: lambda i:
lambda e: lambda g: (q(w)(i))(lambda x: j)(h)(lambda _: k(e)(g))(lambda _: v(
lambda j: lambda k: (lambda a: lambda b: lambda c: (o(d(r(a))(t(d(r(b))(r(c))
)))(t(o(r(a))(o(r(b))(r(c))))))(lambda _: f(s(i))(j)(k))(lambda _: f(s(i))(e)
(g)))(m(n(m(p)(x))(m(k)(y)))(n(m(a)(y))(m(j)(x))))(m(n(m(e)(x))(m(k)(y)))(n(m
from math import ceil as ceil_, floor as floor_, log
from matplotlib import pyplot as plt
import numpy as np
ceil = lambda n: int(ceil_(n))
floor = lambda n: int(floor_(n))
immeuble = lambda i: lambda j: j >= i
def etage_fatal(k, n, fatal):
@Lapin0t
Lapin0t / keybase.md
Last active December 15, 2016 17:17

Keybase proof

I hereby claim:

  • I am lapin0t on github.
  • I am lapinot (https://keybase.io/lapinot) on keybase.
  • I have a public key ASBhhz1PHZ0acYsVcWteheVp7jFraGZafgc3dgsz0t2uOwo

To claim this, I am signing this object:

@Lapin0t
Lapin0t / acm_12205.py
Created January 31, 2017 16:15
Some fun with ACM exercice 12205
(lambda r,e:e(r(r('(λip·(λr,e,it,t,f·e((λc·e(print(sum(1 for(a,b)in c if x+y>a '
'and a+b>x))for(x,y)in(f()for _ in r(m))))([t(f())[2:]for _ in r(n)])for(n,m)in'
' it.takewhile(λx·x!=(0,0),(t(f())for _ in it.repeat(None)))))(range,λi·ip("fun'
'ctools").reduce(λx,y·None,i),ip("itertools"),tuple,λ·map(int,input().split()))'
')(__import__)','λ','lambda '),'·',':')))(str.replace,eval)
@Lapin0t
Lapin0t / whipper.txt
Last active August 18, 2017 19:11
whipper CLI mockup
related ideas:
- the code should only query a config which would has been populated by
command-line args or by some config file
- sync the config and the CLI so that everything can be set from CLI or in
config file with somewhat the same names
---
$ whipper --help
module simple where
open import Agda.Builtin.Size public
_∘_ : {i j k} {A : Set i} {B : A Set j} {C : {x} B x Set k}
(f : {x} (y : B x) C y) (g : (x : A) B x) (x : A) C (g x)
f ∘ g = λ x f (g x)
data _≡_ {i} {X : Set i} (x : X) : {Y : Set i} Y Set where
refl : x ≡ x
@Lapin0t
Lapin0t / taches.js
Created August 18, 2021 13:04
v0000
// ==UserScript==
// @name New script - youtube.com
// @namespace Violentmonkey Scripts
// @match https://www.youtube.com/
// @grant GM_notification
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// @version 1.0
// @author -
module tele where
open import Function.Bundles
open import Level hiding (lift; zero; suc)
open import Data.Product
open import Data.Product.Properties using (Σ-≡,≡↔≡)
open import Data.Unit
open import Data.Nat hiding (_⊔_)
open import Data.Fin hiding (lift)