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
; Ruby has an awesome feature -- string interpolation. Read about it on the internet. | |
; On the other hand, Clojure only has cumbersome Java string formatting, which can not be | |
; used without pain after you've tried Ruby. | |
; So here's this simple macro that basically allows you to do most things you could do | |
; with Ruby string interpolation in Clojure. | |
(ns eis.stuff | |
(:require [clojure.string])) |
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
Hello, world! | |
Pick a random code below, then go to https://marginalia.bandcamp.com/yum for a free download! | |
aqxn-h5hz | |
8gcv-jrpg | |
x7u6-vs7v | |
hmlt-gda9 | |
jbpt-ul3t | |
9xf3-jjd7 |
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
-- creates a class table which has a "new" method to create object instances. | |
class = function (parentclass, classdef) | |
local cls = { | |
__classdef__ = classdef or {}, | |
__parent__ = parentclass or {}, | |
-- instance constructor | |
new = function(cls, ...) | |
local instance = { | |
super = cls.__parent__.__classdef__, |
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
user_agents = [ | |
(30.7, '''Mozilla/4.0 (compatible; MSIE 5.0; Windows NT;) | |
Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) | |
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0) | |
Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1; .NET CLR 3.0.04506.30) | |
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727) | |
Mozilla/4.0 (compatible; MSIE 5.0b1; Mac_PowerPC) | |
Mozilla/2.0 (compatible; MSIE 4.0; Windows 98) | |
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT) | |
Mozilla/4.0 (compatible; MSIE 5.23; Mac_PowerPC) |
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
(ns people | |
(:use [clojure.string :only (join)] | |
[clojure.pprint :only (pprint simple-dispatch)])) | |
;; we can make maps using the special literal form: | |
{:a 100 | |
:b 200} | |
(class {:a 100 :b 200}) |
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
/** | |
* Gives you an object type compatible with given key type TKey. | |
* | |
* For example, | |
* | |
* type Example = ObjFor<'a'> | |
* | |
* is expanded to | |
* | |
* type Example = { |
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
import { Atom } from '@grammarly/focal' | |
import { createStore } from 'redux' | |
declare global { | |
interface Window { | |
__REDUX_DEVTOOLS_EXTENSION__?: () => undefined | |
} | |
} | |
/** |
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 python | |
if __name__ == '__main__': | |
import sys, random, re | |
roll_re = r'(?P<rolls>\d+)d(?P<die>\d+)((?P<mod>(\+|-)\d+))?' | |
parsed = re.match(roll_re, sys.argv[1].strip()) if len(sys.argv) == 2 else None | |
if parsed is not None: | |
d = parsed.groupdict() | |
rolls, die, mod = int(d['rolls']), int(d['die']), (int(d['mod']) if d['mod'] is not None else 0) |
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 python | |
import sys, os, re | |
from PIL import Image, ImageChops | |
def find(root, pattern): | |
for root, dns, fns in os.walk(root): | |
for fn in fns: | |
if re.match(pattern, fn): | |
yield (root, fn) |
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
(ns fsm | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; Encoding a Finite State Machine and recognizing strings in its language in Clojure core.logic | |
;; We will encode the following FSM: | |
;; | |
;; (ok) --+---b---> (fail) | |
;; ^ | |
NewerOlder