Skip to content

Instantly share code, notes, and snippets.

agum onkey agumonkey

  • NONE
  • Dark side of the moon @ ['tkf8-2-1', 'ay21-3', '3263-827']
Block or report user

Report or block agumonkey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View url.py
from urllib.parse import urlparse, urlunparse
"""
url helpers
"""
def isurl(o):
return o.startswith('http://') \
or o.startswith('https://')
View new.py
## based on airbnb proto interview
def rev(s):
return s[::-1]
# a .. b
# (a,b) .. (b,a)
def mir(a,b):
i = a
j = b
@agumonkey
agumonkey / fmt.el
Created Mar 14, 2019
fmt.el - ala python string formatting
View fmt.el
;;; ala python string formatting
;;;
;;; (let ((some "Object") (i 1)) (f "<{some}... [{i}:{i}>")) => "<Object... [1:1]>
;;;
;;; todo: {...} parser
;;; todo: wrapping defmacro
;;; todo: wrapping defun
;;;
;;; state: alpha²
View lem.el
(cl-flet ((fun (x) (1+ x)))
(fun 0))
(let ((fun (lambda (x) (1+ x))))
(fun 0))
(defmacro lem (bs &rest body)
(cl-flet ((fun? (form)
(and (listp form)
(eq (length form) 3)
View progm.el
(defmacro progm (body)
(if (null body)
'()
`(cons ,(car body)
(progm ,(cdr body)))))
(defmacro progb (&rest pair)
(let ((a (car pair))
(b (cadr pair)))
`(cons ,a (cons ,b nil))))
@agumonkey
agumonkey / mp.py
Last active Mar 6, 2019
metaprogramming (inspired by dave beazley)
View mp.py
def dec(*a, **k):
print(a,k)
return a[0] if a else lambda self: self
def debug(f, pre='[debug]', indent='.', inc=1):
depth = 0
def _(*a,**k):
nonlocal indent
nonlocal depth
@agumonkey
agumonkey / cur.py
Created Mar 5, 2019
for when functools.partial is not enough (and you want to reinvent the sauce)
View cur.py
# function:defaults code:argcount code:varnames can be used for precise curry
def vars(fun):
defaults = fun.__defaults__
argcount = fun.__code__.co_argcount
varnames = fun.__code__.co_varnames
return defaults, argcount, varnames
def cu(f):
@agumonkey
agumonkey / kotlin-mode-overlay.el
Last active Mar 6, 2019
kotlin-mode-overlay.el --- Missing bits for kotlin-mode
View kotlin-mode-overlay.el
;;; kotlin-mode-overlay.el --- Missing bits for kotlin -*- lexical-binding: t; -*-
(defvar *kotlin-linter* "ktlint")
(defvar *kotlin-interpreter* "kotlin")
(defvar *kotlin-build-dir* "build")
(defvar *kotlin-main-args* "gest.xml")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN.
(defun kotlin/test ()
@agumonkey
agumonkey / fun.py
Last active Mar 9, 2019
pipes in python
View fun.py
import urllib.request as rq
class ConfusedThreader(Exception):
pass
class Fun:
def __getattr__(self,attribute):
def aux(o):
return getattr(o,attribute)()
return aux
@agumonkey
agumonkey / x.kt
Last active Mar 3, 2019
xml to sax to tree in kotlin
View x.kt
package x
import java.util.Stack
import java.io.File
import javax.xml.parsers.*
import org.xml.sax.*
import org.xml.sax.helpers.*
class Node(val l:String, val q:String, val u:String, val a:Map<String,String>) {
val children:MutableList<Node> = mutableListOf<Node>()
You can’t perform that action at this time.