This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function toSlug($text) | |
{ | |
$text = preg_replace( | |
['/(à|á|ã|â)/','/(é|è|ẽ|ê)/','/(í|ì|ĩ|î)/','/(ó|ò|õ|ô)/','/(ú|ù|û)/','/ç/','/ /'], | |
['a','e','i','o','u','c','-'], | |
strtolower($text) | |
); | |
$text = preg_replace('/([^a-z0-9-])/','',$text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo dd if=/dev/zero of=/swapspace bs=1M count=4000 | |
sudo mkswap /swapspace | |
sudo swapon /swapspace | |
# To check | |
cat /proc/swaps | |
# Next, add the following line to /etc/fstab to activate the new swap at boot: | |
/swapspace none swap defaults 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def spaceless(&block) | |
contents = capture(&block) | |
# Note that string returned by +capture+ is implicitly HTML-safe, | |
# and this mangling does not introduce unsafe changes, so I'm just | |
# resetting the flag. | |
if Rails.env.production? then | |
contents.strip.gsub(/>\s+</, '><').html_safe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show only ids to an especific id | Possible commands | |
docker ps -a | grep mongo --color | sed -e 's/^\([a-z0-9]*\).*/\1/' # With grep | |
docker ps -a | sed -n /mongo/p | sed -e 's/^\([a-z0-9]*\).*/\1/' | |
docker ps -a | awk '/mongo/ {print $1}' # Using AWK | |
# Download list of m4a from an xml via curl | |
wget -i $(curl http://vip.aersia.net/roster.xml\?296 | sed -e '/location/!d' -e 's/\<location\>\(.*\)\<\/location\>/\1/g' -e 's/^[^a-z]*//g') | |
# Insert with sed | |
sed '/regex/i\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 3697 | |
# Syntax | |
awk '/pattern/ { commands }' textfile | |
## System variables | |
# FS = Field Separator (Define the separator for variables) | |
# NF = Number Fields (Number of fields getted by a field separator) | |
# RS = Record Separator (Record separator is a new line by default "\n") | |
# FILENAME = The name of the file that awk is reading | |
# BEGIN = Run command and change vars before the script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ~/docker | |
chmod 777 ~/docker | |
# Create network to all containers | |
docker network create dockernet | |
# Mongo | |
docker run -v ~/docker/mongo/data:/data/db -p 27017:27017 --name mongodb --network dockernet -d mongo | |
# CouchDB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(global-set-key (kbd "C-x q") 'neotree-toggle) | |
(setq js2-basic-offset 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readlineSync = require('readline-sync'); | |
const printBoard = (board) => { | |
const f = (n) => { | |
const size = n.toString().length; | |
const spaces = 5-size; | |
return ' '.repeat(spaces) + n.toString() + ' '; | |
}; | |
textToPrint = []; |
OlderNewer