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
@hostmaster
hostmaster / keydeploy.sh
Last active August 29, 2015 13:56
Public key deployment
# Linux
wget -O - https://github.com/hostmaster.keys >>~/.ssh/authorized_keys
---
- hosts: build-servers
remote_user: root
tasks:
- name: read lines
command: tail -n 10 /var/log/messages
register: logfile
- name: print
### signal the start of configuration
- hosts: localhost
tasks:
- irc:
channel={{ irc_channel }} server={{ irc_server }} msg="Preparing to update the servers"
### configure each webserver
- hosts: webservers
#!/usr/bin/env python
from lxml import html
tree = html.fromstring(open("btsync.html").read())
for e in tree.xpath("//li[contains(@class, 'dl-link')]"):
print(e.text_content().encode('utf-8'))
@hostmaster
hostmaster / daemon.conf
Last active August 29, 2015 13:57
ubuntu / FIIO E10 tweaks
# ~/.pulse/daemon.conf
default-sample-format = s24le
default-sample-rate = 44100
alternate-sample-rate = 96000
def human_log(res):
fields = ['cmd', 'command', 'start', 'end', 'delta', 'msg', 'stdout', 'stderr']
for field in fields:
if field in res:
print '\n{0}:\n{1}'.format(field, res[field])
class CallbackModule(object):
def on_any(self, *args, **kwargs):
pass
@hostmaster
hostmaster / init.c
Created April 21, 2014 11:35 — forked from rofl0r/init.c
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
int main()
{
sigset_t set;
int status;
if (getpid() != 1) return 1;
@hostmaster
hostmaster / deploy-github-pub-keys.yml
Last active August 29, 2015 14:01
Use public keys from github accounts for authorized_key file
# github_pub_keys:
# - username1
# - username2
- shell: curl -s "https://github.com/{{ item }}.keys"
with_items: github_pub_keys
register: pub_keys
changed_when: False
tags: keys
@hostmaster
hostmaster / nginx-reload.log
Created June 4, 2014 13:10
start-stop-daemon nginx issue
[root@dev:~]# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.4 LTS
Release: 12.04
Codename: precise
[root@dev:~]# cat /var/run/nginx.pid
23616
[root@dev:~]# pgrep nginx
# Call virtualenvwrapper's "workon" if .venv exists. This is modified from--
# http://justinlilly.com/python/virtualenv_wrapper_helper.html
# which is linked from--
# http://virtualenvwrapper.readthedocs.org/en/latest/tips.html#automatically-run-workon-when-entering-a-directory
check_virtualenv() {
if [ -e .venv ]; then
env=`cat .venv`
if [ "$env" != "${VIRTUAL_ENV##*/}" ]; then
echo "Found .venv in directory. Calling: workon ${env}"
workon $env