Skip to content

Instantly share code, notes, and snippets.

View eerien's full-sized avatar

Changhwan Song eerien

View GitHub Profile
@eerien
eerien / paginator.py
Created March 1, 2015 15:27
Paginator for infinite scroll on Django.
class Paginator(object):
def __init__(self, object_list, per_page=10, latest_id=None, latest_id_field='id', order_by='desc'):
assert type(latest_id_field) == str
self.object_list = object_list
self.per_page = per_page
self.latest_id = latest_id
self.latest_id_field = latest_id_field
self.order_by = order_by
@eerien
eerien / keybase.md
Created February 25, 2015 01:05
keybase.md

Keybase proof

I hereby claim:

  • I am eerien on github.
  • I am eerien (https://keybase.io/eerien) on keybase.
  • I have a public key whose fingerprint is F6EA 0D1C 16A6 6B58 E47A E59B A439 6D42 EFAD 7DCF

To claim this, I am signing this object:

@eerien
eerien / zabbix_api.py
Created January 8, 2015 02:48
Zabbix API class for Python
import requests
import json
class ZabbixAPI():
ZBX_COMMON_HEADERS = {'Content-Type': 'application/json-rpc'}
def __init__(self, url, username, password):
self.url = url
self._login(username, password)
@eerien
eerien / shaco.py
Last active January 4, 2022 18:23
Zabbix screen reporting script by using Selenium. It send email includes screenshot of pre-defined Zabbix screen. You can use this for periodical statistics report with Cron.
#!/usr/bin/python
#-*- coding: utf-8 -*-
# Install
# apt-get install xvfb python-imaging (firefox or chromium-chromedriver)
# pip install selenium pyvirtualdisplay boto
import sys
import os
import socket
@eerien
eerien / mysql_status.sh
Created September 2, 2014 03:43
A script to get any status variable value
#!/bin/bash
echo "show global status where Variable_name='$4';" | mysql -h$1 -u$2 -p$3 -N | awk '{print $2}'
@eerien
eerien / mysql_ping.sh
Created September 2, 2014 03:42
MySQL Ping script
#!/bin/bash
mysqladmin -h$1 -u$2 -p$3 ping | grep -c alive
@eerien
eerien / aws-autoscaling-set-desired-capacity.sh
Created September 2, 2014 03:42
AWS (Amazon Web Services) AutoScaling: set-desired-capacity script
#!/bin/bash
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
/usr/local/bin/aws autoscaling set-desired-capacity --region "$1" --auto-scaling-group-name "$2" --desired-capacity "$3" --no-honor-cooldown
@eerien
eerien / cloudwatch.sh
Last active August 29, 2015 14:05
Zabbix externalscript for CloudWatch on AWS (Amazon Web Services). It returns latest statistic value.
#!/bin/bash
# $1: Region
# $2: Namespace
# $3: Dimensions
# $4: Metric Name
# $5: Start Time (before n min)
# $6: Period (min)
# $7: Statistics (SampleCount, Average, Sum, Minimum, Maximum)
# $8: Output value when the result is null
@eerien
eerien / aws_rss_feeds.xml
Last active March 6, 2020 06:57
AWS RSS Feeds OPML includes AWS Status, AWS Forum Announcements, AWS Blogs, AWS Partners, AWS News, AWS Release Notes and AWS Security Bulletins
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>AWS RSS Feeds</title>
</head>
<body>
<outline title="AWS Status" text="AWS Status">
<outline text="Amazon Mobile Analytics (N. Virginia) Service Status" title="Amazon Mobile Analytics (N. Virginia) Service Status" type="rss" xmlUrl="http://status.aws.amazon.com/rss/analytics-us-east-1.rss" htmlUrl="http://status.aws.amazon.com/" rssfr-favicon="http://status.aws.amazon.com/favicon.ico"/>
<outline text="Amazon AppStream (N. Virginia) Service Status" title="Amazon AppStream (N. Virginia) Service Status" type="rss" xmlUrl="http://status.aws.amazon.com/rss/appstream-us-east-1.rss" htmlUrl="http://status.aws.amazon.com/" rssfr-favicon="http://status.aws.amazon.com/favicon.ico"/>
<outline text="Auto Scaling (Tokyo) Service Status" title="Auto Scaling (Tokyo) Service Status" type="rss" xmlUrl="http://status.aws.amazon.com/rss/autoscaling-ap-northeast-1.rss" htmlUrl="http://status.a
@eerien
eerien / aws_region.sh
Created January 28, 2014 07:10
Code snippet to recognize or determine region placed itself by using 169.254.169.254 on AWS.
AZ=`curl http://169.254.169.254/2012-01-12/meta-data/placement/availability-zone 2> /dev/null`
if [[ $AZ =~ 'us-east-1' ]]; then # N. Virginia
elif [[ $AZ =~ 'us-west-2' ]]; then # Oregon
elif [[ $AZ =~ 'us-west-1' ]]; then # N. California
elif [[ $AZ =~ 'eu-west-1' ]]; then # Ireland
elif [[ $AZ =~ 'ap-southeast-1' ]]; then # Singapore
elif [[ $AZ =~ 'ap-northeast-1' ]]; then # Tokyo
elif [[ $AZ =~ 'ap-southeast-2' ]]; then # Sydney
elif [[ $AZ =~ 'sa-east-1' ]]; then # Sao Paulo
else # Others