Skip to content

Instantly share code, notes, and snippets.

View almost's full-sized avatar

Thomas Parslow almost

View GitHub Profile
-- All the letters that can be matched by the regex, we only care
-- about capitals for this problem
allLetters = Set.fromList ['A'..'Z']
compile :: String -> [Instruction Char]
compile xs = (compile' xs) ++ [End]
where compile' [] = []
compile' xs = let (instr, rest) = compilePart xs in
instr ++ compile' rest
S E C U E * *
M L R C R L * *
M M X O X R X * H
H E M H * * H * * H
H H X M I * H H X D C
H P R R M I . * H D D C
S T X * C M I . C R X R G
A M * M M C M R C R C R
H O X M M C C * X R N
E M N M N C R E C R
@almost
almost / regexs.txt
Last active August 29, 2015 13:55
The Regular Expressions from the Regular Expression Crossword
.*SE.*UE.*
.*LR.*RL.*
.*OXR.*
([^EMC]|EM)*
(HHX|[^HX])*
.*PRR.*DDC.*
.*
[AM]*CM(RC)*R?
([^MC]|MM|CC)*
(E|CR|MN)*
item_ids = request.QUERY_PARAMS.get('item_models', '').split(',')
items = ItemModel.objects.filter(id__in=item_ids)
result = dict(
(m.pk, {'lowest_stock': m.get_lowest_stock_for_subbooking(subbooking)})
for m in items}
return Response(result)
var Readable = require('stream').Readable;
var util = require('util');
function Source(options, generator) {
if (typeof options === 'function') {
generator = options;
options = {};
}
this._generator = generator();
Readable.call(this, options);
function play (x) {
x += ''
r = []
for (i = -1; ++i < x.length;)
r.push('zero two three five six seven eight'.split(' ')[x[i]])
return r.join(' ')
}
function play (n) {
return n + 1;
}
play=p=function (s) {
return s.replace(/\b./g, p.call.bind(s.toUpperCase))
}
@almost
almost / StoreWatchMixin.js
Last active August 29, 2015 14:26
A simple mixin for getting state from Flux stores in a React view. An example of how simple it can be. You're probably better off using a full library though...
"use strict";
var shallowEqual = require('shallow-equals');
// Create a mixin for a component that depends on a store(s) for
// state. Component should define getStateFromStores
module.exports = function StoreWatchMixin(...stores) {
return {
componentDidMount () {
stores.forEach((store) => {
store.addListener('change', this.onStoreChange);
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
main = do
xmonad $ defaultConfig {
modMask = mod4Mask -- Rebind Mod to the Windows key