Skip to content

Instantly share code, notes, and snippets.

Thomas Parslow almost

Block or report user

Report or block almost

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 regexcompiler.hs
-- 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
@almost
almost / regexs.txt
Last active Aug 29, 2015
The Regular Expressions from the Regular Expression Crossword
View regexs.txt
.*SE.*UE.*
.*LR.*RL.*
.*OXR.*
([^EMC]|EM)*
(HHX|[^HX])*
.*PRR.*DDC.*
.*
[AM]*CM(RC)*R?
([^MC]|MM|CC)*
(E|CR|MN)*
View gist:8753831
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
View gist:b9bcbe16ef588b873bee
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)
View genstream.js
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);
View golf.js
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(' ')
}
View gist:285b634c863d749cd20c
play=p=function (s) {
return s.replace(/\b./g, p.call.bind(s.toUpperCase))
}
@almost
almost / StoreWatchMixin.js
Last active Aug 29, 2015
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...
View StoreWatchMixin.js
"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);
View gist:428711
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
You can’t perform that action at this time.