Skip to content

Instantly share code, notes, and snippets.

Content-Security-Policy: default-src 'self' ajax.googleapis.com XXX.com YYY.com
http://caniuse.com/#feat=contentsecuritypolicy
http://www.w3.org/TR/CSP/
@alex2006hw
alex2006hw / nginx config
Created October 7, 2014 20:39
basic nginx config
#######################################################
### copy from Calomel.org /etc/nginx.conf BEGIN
#######################################################
#
worker_processes 4; # one(1) worker or equal the number of _real_ cpu cores. 4=4 core cpu
worker_priority 15; # renice workers to reduce priority compared to system processes for
# machine health. worst case nginx will get ~25% system resources at nice=15
#worker_rlimit_nofile 1024; # maximum number of open files
events {
@alex2006hw
alex2006hw / nginx config ssl
Created October 7, 2014 20:44
ssl nginx config
#######################################################
### copy from Calomel.org /etc/nginx.conf BEGIN
#######################################################
#
worker_processes 4; # one(1) worker or equal the number of _real_ cpu cores. 4=4 core cpu
worker_priority 15; # renice workers to reduce priority compared to system processes for
# machine health. worst case nginx will get ~25% system resources at nice=15
#worker_rlimit_nofile 1024; # maximum number of open files
@alex2006hw
alex2006hw / nginx config ssl
Created October 7, 2014 20:44
ssl nginx config
#######################################################
### copy from Calomel.org /etc/nginx.conf BEGIN
#######################################################
#
worker_processes 4; # one(1) worker or equal the number of _real_ cpu cores. 4=4 core cpu
worker_priority 15; # renice workers to reduce priority compared to system processes for
# machine health. worst case nginx will get ~25% system resources at nice=15
#worker_rlimit_nofile 1024; # maximum number of open files
@alex2006hw
alex2006hw / Proc table disk stats
Created October 8, 2014 22:34
how to read /proc/diskstats
```
wget http://aspersa.googlecode.com/svn/trunk/rel
wget http://aspersa.googlecode.com/svn/trunk/align
chmod +x rel align
while sleep 1; do grep sdb1 /proc/diskstats; done > stats
```
# CTRL-C after a while
```
echo m m dev reads rd_mrg rd_sectors ms_reading \
@alex2006hw
alex2006hw / enable ssh login
Created October 17, 2014 20:02
Cisco configs
en
conf t
aaa new-model
aaa authentication login default local
aaa authorization exec default local
aaa session-id common
ip ssh version 2
ip domain-name alex2006hw.com
hostname alex2006hw-switch1
crypto key gen rsa gen mod 1024
#!/bin/sh
DEBUG=""
DATE=$(date +%Y-%m-%d)
HOSTNAME=`/bin/hostname`
AMINAME="$DATE-$HOSTNAME-AMI"
AMIDESC="$HOSTNAME backup to AMI on $DATE"
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
test -n "$EC2_INSTANCE_ID" || die 'cannot obtain instance-id'
@alex2006hw
alex2006hw / gist:074581c94e1c755ff650
Created November 11, 2014 00:54
script to partition disk for swap on boot up using /etc/rc.local
# sfdisk -d /dev/xvdb to obtain disk geometry output to use below
#
# Format ephemeral disk into partition for swap on /dev/xvdb2
sfdisk /dev/xvdb <<EOF
unit: sectors
/dev/xvdb1 : start= 2048, size=209715200, Id=83
@alex2006hw
alex2006hw / introrx.md
Last active August 29, 2015 14:20 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname