Skip to content

Instantly share code, notes, and snippets.

View caquino's full-sized avatar

Cassiano Aquino caquino

View GitHub Profile
@caquino
caquino / keybase.md
Last active August 29, 2015 13:58
keybase.md

Keybase proof

I hereby claim:

  • I am caquino on github.
  • I am syshero (https://keybase.io/syshero) on keybase.
  • I have a public key whose fingerprint is FE91 CF58 70A1 2338 65F9 D677 72C0 DDA3 5A33 4A06

To claim this, I am signing this object:

server {
listen 80;
resolver 4.2.2.2;
location /folder1 {
proxy_pass http://server1.domain.com:80;
}
location /folder2 {
proxy_pass http://server2.domain.com:80;
}
map $request_uri $backend_server {
default 'serverdefault.domain.com:80';
/folder1 'server1.domain.com:80';
/folder2 'server2.domain.com:80';
/folder3 'server3.domain.com:80';
}
server {
listen 80;
resolver 4.2.2.2;
@caquino
caquino / google_tts.sh
Created October 26, 2012 19:01
Google TTS
#!/usr/bin/env bash
MESSAGE=${*}
LANGUAGE=pt
TTSURL="http://translate.google.com/translate_tts"
USERAGENT="Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20111114 Ubuntu/9.10 (karmic) Firefox/8.0.1"
curl  -s -G \
       --user-agent "${USERAGENT}" \
       --data-urlencode "tl=${LANGUAGE}" \
       --data-urlencode "q=${PREFIXMESSAGE} ${MESSAGE}" \
       --header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
@caquino
caquino / nginx-config-example
Last active December 16, 2015 20:29
NGINX cache purge using cache_proxy_bypass
location / {
add_header X-Cached $upstream_cache_status;
....
proxy_cache_bypass $http_cache_purge;
....
proxy_pass ... ;
}
@caquino
caquino / 0-byte-cache
Created May 3, 2013 01:26
Do not cache 0-byte files on NGINX
map $upstream_http_content_length $flag_cache_empty {
default 0;
0 1;
}
server {
....
location / {
...
proxy_no_cache $flag_cache_empty;
virtual_server 192.168.0.10 1433 {
delay_loop 5
lb_algo lc
lb_kind DR
protocol TCP
real_server 192.168.1.10 1433 {
weight 1
MISC_CHECK {
misc_path /path/to/check_mssql_mirror.py
#!/usr/bin/env bash
WEBSERVERS="apache1.domain.com apache2.domain.com apache3.domain.com apache4.domain.com"
for server in ${WEBSERVERS};do
wget -q -O - ${server}/server-status | grep 'HTTP' | \
while IFS=$'\n' read; do
if [[ ${REPLY} =~ (GET|POST|HEAD)\ (.+?)\ HTTP ]]; then
echo ${BASH_REMATCH[2]}
fi | grep -v server-status
done
done | sort | uniq -c | sort -rk1 | head -20
Get-NetAdapter -Physical | where {$_.status -eq "UP"}
New-NetLbFoTeam -Name 'TEAM' -TeamMembers 'Ethernet 8','Ethernet 4' -TeamingMode SwitchIndependent