npm install iconv-lite
var fs = require('fs');
var iconv = require('iconv-lite');
iconv.decode(fs.readFileSync('file.txt'), 'iso-8859-1');
const cachedReadFile = (function() { | |
const cache = new Map(); | |
return (p) => { | |
if (cache.has(p)) return Promise.resolve(cache.get(p)); | |
else return readFile(p).tap((file) => cache.set(p, file)); | |
} | |
}()); |
#!/usr/bin/env bash | |
# Browse Ramda documentation in Terminal | |
# Requires jq and a tool such as fzf or peco for interactive filtering | |
LATEST="http://raine.github.io/ramda-json-docs/latest.json" | |
DOCS_URL="http://ramdajs.com/docs/" | |
json=$(curl -s $LATEST) | |
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end') |
#!/usr/bin/env bash | |
set -e | |
cmd="$(tmux display -p '#{pane_current_command}')" | |
cmd="$(basename "${cmd,,*}")" | |
tmux resize-pane -Z | |
if [ "${cmd%m}" = "vi" ]; then | |
sleep 0.1 |
git config --global alias.remove-merged-branches '!git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
```sh
# Hello, and welcome to makefile basics. | |
# | |
# You will learn why `make` is so great, and why, despite its "weird" syntax, | |
# it is actually a highly expressive, efficient, and powerful way to build | |
# programs. | |
# | |
# Once you're done here, go to | |
# http://www.gnu.org/software/make/manual/make.html | |
# to learn SOOOO much more. |
This blog post series has moved here.
You might also be interested in the 2016 version.
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.
--EVAL "this script" 1 key_name new_item max_size | |
local key = KEYS[1]; | |
local item, max = unpack(ARGV); | |
redis.call('RPUSH', key, item); | |
redis.call('LTRIM', key, -max, -1); |