Skip to content

Instantly share code, notes, and snippets.

View caquino's full-sized avatar

Cassiano Aquino caquino

View GitHub Profile
@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;
@caquino
caquino / map-nginx-cookie
Last active July 17, 2016 03:41
Avoid NGINX caching based on cookies
@caquino
caquino / index-cached.shtml
Last active December 31, 2020 17:24
Poors Main ESI
Cached: <!--# echo var="date_local" -->
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
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%A IN (%*) DO (
PSEXEC.EXE \\%%A %windir%\system32\inetsrv\appcmd list requests > %TMP%\output-%%A.log 2>&1
)
FOR %%A IN (%*) DO (
TYPE %TMP%\output-%%A.log | FIND "REQUEST" >> %TMP%\output.log
DEL %TMP%\output-%%A.log
)
FOR /F "tokens=2,3 delims==:" %%A IN (%TMP%\output.log) DO ECHO %%A | SORT >> %TMP%\outputs.log
Get-NetAdapter -Physical | where {$_.status -eq "UP"}
New-NetLbFoTeam -Name 'TEAM' -TeamMembers 'Ethernet 8','Ethernet 4' -TeamingMode SwitchIndependent