Skip to content

Instantly share code, notes, and snippets.

View raine's full-sized avatar

Raine Virta raine

View GitHub Profile
const assertRejectedWith = (p, fn) =>
Promise.all([
assert.isRejected(p),
p.catch(fn)
]);
const assertRejectedWithMsg = (p, str) =>
assertRejectedWith(p, err => assert.deepEqual(err.message, str))
it('throws if body can\'t be found for the email type', () => {
function! AgSearchAndReplaceCursor()
let search = expand('<cword>')
execute "Ag! " . search
call feedkeys(':QFdo %s/' . search . "//gc")
call feedkeys("\<Left>\<Left>\<Left>")
endfunction
nmap <space>ac :silent Ag<CR> " word on cursor
nmap <space>ag :silent Ag! ""<Left>
nmap <space>as :silent AgFromSearch<CR>
const { pickBy } = require('ramda');
const obj = {
a: 1,
b: 2,
A: 3,
B: 4
};
// ---
@raine
raine / doug.ls
Last active September 30, 2015 18:20
require! ramda: {pipe, map}
ssps =
* target: 'summarize(stats.incoming.ssp_traffic.aaa, "1hr", "sum")'
* target: 'summarize(stats.incoming.ssp_traffic.bbb, "1hr", "sum")'
* target: 'summarize(stats.incoming.ssp_traffic.ccc, "1hr", "sum")'
ssp-traffic-name-regex = /ssp_traffic.([^,]+),/
# :: [Object] -> [String]
@raine
raine / -
Created September 28, 2015 17:50
~ ❯❯❯ replem minimatch
Installed into REPL context:
- minimatch@3.0.0 as minimatch
> minimatch("src/foo.txt", "src/**/*")
true
@raine
raine / index.js
Last active October 6, 2015 17:36
const lineLens = lens(split('\n'), join('\n'));
const mapLines = curry((fn, str) =>
over(lineLens, map(fn), str));
const adjustLine = curry((fn, n, str) =>
over(lineLens, adjust(fn, n), str))
mapLines(toUpper, 'foo\nbar') // => 'FOO\nBAR'
adjustLine(toUpper, 0, 'foo\nbar') // => 'FOO\nbar"
@raine
raine / -
Created September 27, 2015 13:32
~ ❯❯❯ curl -s -k -H "Accept: application/json" https://brackets-registry.aboutweb.com/ | R '.registry' 'find (.metadata.name is "jade-preprocessors")' -o table
┌───────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ metadata.name │ jade-preprocessors │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ metadata.title │ Jade (Preprocessor Fork) │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ metadata.description │ Add first class sup
#!/usr/bin/env bash
cat $1 | R -rR --slurp \
'unlines' \
'to-lower' \
'match /\w+/g' \
'lodash.uniq' \
'sort-by length' \
'reverse' \
'take 10'
@raine
raine / -
Created September 26, 2015 10:43
~ ❯❯❯ cat <<EOF | jade -O '{ nick: "chargen_" }'
script(type='text/javascript').
window.nick = !{JSON.stringify(nick)};
EOF
<script type="text/javascript">window.nick = "chargen_";</script>%
~ ❯❯❯ cat <<EOF | jade -O '{ nick: null }'
script(type='text/javascript').
window.nick = !{JSON.stringify(nick)};
EOF
const { curry, anyPass, toPairs, map, flip, propSatisfies, apply, memoize } = require('ramda');
const strContains = curry((needle, haystack) => haystack.indexOf(needle) >= 0);
const objSpecToPreds = memoize((spec) =>
map(apply(flip(propSatisfies)), toPairs(spec)))
const whereAny = curry((spec, obj) =>
anyPass(objSpecToPreds(spec), obj)
);