start new:
tmux
start new with session name:
tmux new -s myname
#!/bin/sh | |
echo "installing fonts at $PWD to ~/.fonts/" | |
mkdir -p ~/.fonts/adobe-fonts/source-code-pro | |
git clone https://github.com/adobe-fonts/source-code-pro.git ~/.fonts/adobe-fonts/source-code-pro | |
# find ~/.fonts/ -iname '*.ttf' -exec echo \{\} \; | |
fc-cache -f -v ~/.fonts/adobe-fonts/source-code-pro | |
echo "finished installing" |
# from hyphen/dash to camelCase | |
rename 's/-(\w)/\U$1/g' list-of-files | |
# from camelCase to hyphen/dash | |
sed -e 's/\([A-Z]\)/-\L\1/g' -e 's/^-//' <<< "MyDirectoryFileLine" |
#!/bin/bash | |
# Paste contents of Xorg clipboard to a file from the command line | |
filename=$@ | |
pasteinfo="clipboard contents" | |
# Display usage if no parameters given | |
if [[ -z "$@" ]]; then | |
echo " ${0##*/} <filename> - paste contents of context-menu clipboard to file" | |
exit |
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
SASSC = sass --style compact | |
COMPSDIR = resources/assets/components | |
SASSDIR = resources/assets/css | |
JSDIR = resources/assets/js | |
DISTDIR = web/dist | |
CSSDIR = $(DISTDIR)/css | |
SASSINC = $(SASSDIR) \ | |
$(COMPSDIR)/asimov/src/scss \ | |
$(COMPSDIR)/asimov-contests/src/scss \ | |
$(COMPSDIR)/asimovicons/src/scss |
// Partially apply arguments to a function. Useful for binding | |
// specific data to an event handler. | |
// Example: | |
// | |
// var add = function (x,y) { return x + y } | |
// var add5 = add.papp(5) | |
// add5(7) //=> 11 | |
// | |
Function.prototype.papp = function () { | |
var slice = Array.prototype.slice |
Wish you had some immutability in Javascript? Now you can!
var t = {a: 1, b: 2}.immutable();
console.log(t.a, t.b);
try {
t.a = 3; // -> Uncaught Error: a is immutable and cannot be modified.
} catch (e) {
console.log(e);
}
var t2 = t.copy({a: 3});