Skip to content

Instantly share code, notes, and snippets.

View hostmaster's full-sized avatar
🏠
Working from home

Igor Khomyakov hostmaster

🏠
Working from home
  • Russia, Saint Petersburg
View GitHub Profile
$ curl --silent --user $SIP_USER:$SIP_PASS "https://customer.voipexchange.ru/cgi-bin/Exchange.dll/MTK?oper=3&uid=$ACCOUNT_ID" \
| gzip -dc - | awk -F 'Balance' '$2!~/^$/ { gsub(/[^0-9.]/, "", $2); print $2 }'
@hostmaster
hostmaster / sipnet_id.sh
Created February 20, 2012 12:06
sipnet account id
$ ACCOUNT_ID=$(curl --silent --user $SIP_USER:$SIP_PASS "https://customer.voipexchange.ru/cgi-bin/Exchange.dll/MTK" \
| gzip -dc - | awk '/uid=/ { gsub(/[^0-9.]/, "", $2); print $2 }')
@hostmaster
hostmaster / gajim.bat
Created February 20, 2012 12:13
Portable Gajim
@echo off
@start gajim.exe -p portable -c ../DataDir
@hostmaster
hostmaster / nginx.conf
Created March 7, 2012 11:19
nginx post-action
location ^~ /attachments/download_zip/ {
proxy_pass http://mongrel;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_Forwarded_Proto $scheme;
proxy_read_timeout 120;
proxy_connect_timeout 120;
post_action @notify_zip
@hostmaster
hostmaster / addsite.sh
Created April 5, 2012 08:26
Ubuntu 10.04 (nginx + php5-fpm): Install MODX 2.2 including user, virtual host, database
#!/bin/bash
# MySQL root password
ROOTPASS="password"
TIMEZONE="Europe/Moscow"
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
SFTPPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
##############
@hostmaster
hostmaster / ideal ops.md
Created May 29, 2012 08:49 — forked from bhenerey/ideal ops.md
ideal ops checklist

In a perfect world, where things are done well, not just quickly, I would expect to find the following when joining the company:

Documentation

  • Accurate / up-to-date systems architecture diagram

  • Accurate / up-to-date network diagram

  • Out-of-hours support plan

  • Incident management plan

@hostmaster
hostmaster / gist:2965042
Created June 21, 2012 10:32
wipe GPT header signature on last LBA to suppress (s)fdisk GPT warning
# wipe GPT header signature
disk_kb_count=$(sfdisk -s ${disk} 2>/dev/null)
dd if=/dev/zero of=${disk} bs=1024 seek=$(($disk_kb_count - 1)) count=1
# curl -v http://2sms.ru/mms631
> GET http://2sms.ru/mms631 HTTP/1.1
> User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 2sms.ru
> Accept: */*
> Proxy-Connection: Keep-Alive
>
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Moved Temporarily
< Server: nginx
root@workstation:~# env TZ="EDT" date Fri Aug 24 15:50:51 EDT 2012
root@workstation:~# tail -n 2 /var/log/syslog
Aug 24 15:50:19 workstation stunnel: LOG5[16133:3073502016]:
Aug 24 15:50:19 workstation stunnel: LOG5[16133:3073502016]:
root@workstation:~# date Fri Aug 24 19:51:17 MSK 2012
@hostmaster
hostmaster / gist:3714556
Created September 13, 2012 14:10
busybox awk is not fully compatible with GNU awk
# busybox AWK implementation is not fully compatible with GNU AWK
# GNU awk
$ echo 3000592982016 | awk '{ printf "%d\n", $1/1024 }'
2930266584
# busybox awk
$ echo 3000592982016 | awk '{ printf "%d\n", $1/1024 }'
-2147483648
# The workaround is obvious use printf "%,0f" instead