Skip to content

Instantly share code, notes, and snippets.

@elleryq
elleryq / command.py
Created February 5, 2016 07:50
Wrap shell command as python function
# -*- encoding: utf-8 -*-
import subprocess
class command(object):
def __init__(self, cmd):
self._cmd = cmd
def __call__(self, *args, **kwargs):
cmd = [self._cmd]
@elleryq
elleryq / ec2_create_again_result.txt
Created January 22, 2016 07:19
Ansible EC2 module result
# exact_count: 1
# nothing changed, instances will be in tagged_instances
TASK [debug] *******************************************************************
ok: [127.0.0.1] => {
"ec_aa": {
"changed": false,
"instance_ids": null,
"instances": [],
"tagged_instances": [
{
@elleryq
elleryq / changepassword.sh.j2
Last active June 13, 2023 13:24
Create Django super user in ansible
#!/usr/bin/expect
set timeout -1;
spawn {{django_dir}}/venv/bin/python manage.py changepassword {{admin_user}};
expect {
"Password:" { exp_send "{{admin_pass}}\r" ; exp_continue }
"Password (again):" { exp_send "{{admin_pass}}\r" ; exp_continue }
eof
}
@elleryq
elleryq / install_swift-2.2.sh
Last active December 4, 2015 05:41
Ubuntu Swift-2.2 installer
#!/bin/bash
TARBALL="swift-2.2.tar.gz"
TARBALL_SIG="swift-2.2.tar.gz.sig"
SWIFT_TARBALL_URL="https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz"
SWIFT_TARBALL_SIG_URL="https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz.sig"
DESTDIR="/opt/swift-2.2"
if [ ! -e "$TARBALL" ]; then
wget "$SWIFT_TARBALL_URL" -O "$TARBALL"
@elleryq
elleryq / pedantically_commented_playbook.yml
Created November 24, 2015 02:20 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@elleryq
elleryq / playbook.yml
Created November 12, 2015 06:51
Testing ansible playbook include functionality.
---
- name: Provision servers
hosts: 127.0.0.1
connection: local
tasks:
- name: add host
add_host: hostname=127.0.0.1 groupname=xmpp
- include: playbook2.yml passed_to_me='Hello, John'
#!/usr/bin/env python
# Need python-libvirt
from __future__ import print_function, unicode_literals
import sys
import libvirt
from xml.etree import ElementTree
from subprocess import check_output
import re
@elleryq
elleryq / taaze_gift.csv
Created October 22, 2015 05:25
http://www.taaze.tw/gift_index.html 抓出來的所有書名與網址
We can't make this file beautiful and searchable because it's too large.
"繞繞繞繞口令","http://www.taaze.tw/gift_sing.html?pid=81300014968"
"要活就要動!","http://www.taaze.tw/gift_sing.html?pid=81300014969"
"上海攻略-上海最値得","http://www.taaze.tw/gift_sing.html?pid=81300014971"
"中國現代作家選集8:","http://www.taaze.tw/gift_sing.html?pid=81300014973"
"會計學新論解答(全一","http://www.taaze.tw/gift_sing.html?pid=81300014977"
"屍鬼湖","http://www.taaze.tw/gift_sing.html?pid=81300014978"
"有效處理壓力的第一本","http://www.taaze.tw/gift_sing.html?pid=81300014873"
"鬼靈精一族","http://www.taaze.tw/gift_sing.html?pid=81300014874"
"我要擺脫煩惱","http://www.taaze.tw/gift_sing.html?pid=81300014875"
"詠春拳高級格鬥訓練","http://www.taaze.tw/gift_sing.html?pid=81300014876"
@elleryq
elleryq / remove_docker_exited_container.sh
Created October 14, 2015 02:51
docker - remove container which status is exited
#!/bin/sh
# Refer https://docs.docker.com/reference/commandline/ps/ to get more usage about filter(-f).
docker ps -f "status=exited" -q | xargs docker rm
@elleryq
elleryq / docker-compose.yml
Last active April 11, 2018 15:06
docker + node-exporter + prometheus + promdash
# Need to do the following steps:
# 1. create /var/prometheus first.
# 2. run: docker-compose run promdash ./bin/rake db:migrate
nodeexporter:
image: prom/node-exporter
ports:
- "9100:9100"
prometheus:
image: prom/prometheus