Skip to content

Instantly share code, notes, and snippets.

Kevin Secretan Jach

Block or report user

Report or block Jach

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 radio-contact.lisp
; union-find.lisp
;; A generic solution for connected components. "I have some number of graphs. Is this element connected to
;; this other element? Or are the graphs/sets each element belongs to disjoint?"
;;
;; A 'backwards' tree with pointers from a node to its parent, which lets you union two separate trees together by
;; just taking the shorter one's root and pointing it at the taller one's (or vice versa, but this way preserves log
;; behavior).
;; The path compression optimization (not done here) seems to just be an extra pass in find(), after you have the result,
;; to re-parent each item along the path to the found root parent so that any future finds() of any of those items
View union_find.lisp
;; A generic solution for connected components. "I have some number of graphs. Is this element connected to
;; this other element? Or are the graphs/sets each element belongs to disjoint?"
;;
;; a 'backwards' tree with pointers from a node to its parent, which lets you union two separate trees together by
;; just taking the shorter one's root and pointing it at the taller one's (or vice versa, but this way preserves log
;; behavior). The path compression optimization seems to just be an extra pass in find(), after you have the result,
;; to re-parent each item along the path to the found root parent so that any future finds() of any of those items
;; will only have one lookup to reach the component root.
(defclass union-find ()
@Jach
Jach / unicode_extract.lisp
Last active Jan 15, 2019
extract letter unicodes for js regexes
View unicode_extract.lisp
#|
This file is in the public domain.
I grabbed the data from ucd.all.flat.zip at ftp://ftp.unicode.org/Public/11.0.0/ucdxml/
and use this script to create a UnicodeLetters.txt file
containing a series of unicode chars suitable for using in JavaScript regular expressions
where you want \p{L}.
Note that IE does not support the 'u' flag, you'll need to restrict yourself to the subset of
letters in the BMP (below 0x10000) and use this script to print out a simple "\uABCD" instead of "\\u{ABCDE}".
Also note that reading in the file seems to stress SBCL's default settings, run with
--dynamic-space-size 10000
@Jach
Jach / undef-warning.lisp
Created Aug 11, 2018
Track undefined function warnings in SBCL
View undef-warning.lisp
; put this in my .sbclrc file.
; useful idea I had, rebind defun to keep track
; of functions that have been referenced but not yet
; defined. Loosely inspired by Utopian.
(setf (macro-function 'cl-defun) (macro-function 'defun))
(defparameter *undefined-functions* nil)
(handler-bind
((warning
(lambda (w)
(declare (ignorable w))
@Jach
Jach / reverse-string.lisp
Last active Nov 8, 2017
How to write Lisp like C...
View reverse-string.lisp
(defun reverse-string-c (string string-length)
(prog ((pos 0) (half (truncate (/ string-length 2))))
START (if (= pos half)
(return string))
(let ((swap-pos (- string-length pos 1)))
(rotatef (schar string pos) (schar string swap-pos)))
(incf pos)
(go START)))
(defun reverse-string (string)
@Jach
Jach / roswell-0.0.6.63.ebuild
Last active Jun 3, 2016
quick and dirty ebuild for roswell, installed under local dev-lisp/roswell/
View roswell-0.0.6.63.ebuild
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit eutils autotools
DESCRIPTION="Common Lisp environment setup utility"
HOMEPAGE="https://github.com/roswell/roswell"
View sevseg.cljs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; calc.cljs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(ns sevseg.calc)
(defn calc
"Expects a 4-item vector of booleans
representing a big-endian binary number.
Returns a 7-item map with keys prefix + num
corresponding to which segments of the display
@Jach
Jach / show_retweets.py
Created Sep 25, 2014
Print out all the retweets you made. Download your twitter data backup, go into the data/js/tweets folder and run this script.
View show_retweets.py
import json
import glob
files = glob.glob('*.js')
data = {}
for f in files:
file = open(f)
_ = file.readline()
data[f] = json.loads(file.read())
@Jach
Jach / .vimrc
Last active Aug 29, 2015
My master .vimrc. It needs to be cleaned up, but meh.
View .vimrc
nnoremap <F2> :set invpaste paste?<CR>
imap <F2> <C-O><F2>
set pastetoggle=<F2>
set incsearch
set ignorecase
set smartcase
set scrolloff=2
set wildmode=longest,list
set showcmd
@Jach
Jach / gist:6b82fb57bf0bc13937be
Last active Aug 29, 2015
REPL commands using clj-webdriver to get my tweets
View gist:6b82fb57bf0bc13937be
; See revision version 1 for non-phantomJS version, setup phantomJS here: http://blog.zolotko.me/2012/12/clojure-selenium-webdriver-and-phantomjs.html
(use 'clj-webdriver.taxi)
(import 'org.openqa.selenium.phantomjs.PhantomJSDriver
'org.openqa.selenium.remote.DesiredCapabilities)
(use '[clj-webdriver.driver :only [init-driver]])
; skip this section until 'lawl' comment
(use '[clj-webdriver.core :only [execute-script*]])
You can’t perform that action at this time.