View find_eb_ec2_private_ip.sh
#!/usr/bin/env bash | |
beantalkEnvName="$1" | |
echo "target beanstalk env name: ${beantalkEnvName}" | |
## fetch ec2 list | |
getEc2IpList () { | |
ec2List=$(aws elasticbeanstalk describe-environment-resources --environment-name ${beantalkEnvName} | python -m json.tool | python -c 'import sys, json; li = json.load(sys.stdin)["EnvironmentResources"]["Instances"]; ec2List = [ dat.values() for dat in li ]; flat_list = [item for sublist in ec2List for item in sublist]; strlist = map(str, flat_list); print " ".join(strlist)') |
View add_user.sh
#!/bin/sh | |
# Usage: sh add_user.sh "username" "groupname" | |
# ref: https://openvpn.net/vpn-server-resources/managing-user-and-group-properties-from-command-line/ | |
# create user | |
sudo ./sacli --user $1 --key "type" --value "user_connect" UserPropPut | |
# add created user to specified group | |
sudo ./sacli --user $1 --key "conn_group" --value $2 UserPropPut |
View .vimrc
" Don't try to be vi compatible | |
set nocompatible | |
" Helps force plugins to load correctly when it is turned back on below | |
filetype off | |
" TODO: Load plugins here (pathogen or vundle) | |
" Turn on syntax highlighting | |
syntax on |
View solution.py
import itertools | |
abs_min_support = 771 | |
freq_items = [None, {}] | |
# part1 | |
counting = {} | |
with open('categories.txt', 'r') as f: | |
while True: | |
line = f.readline() |
View .bash_profile
# --------------------------------------------------------------------------- | |
# | |
# Description: This file holds all my BASH configurations and aliases. | |
# Much of this was originally copied from: | |
# http://natelandau.com/my-mac-osx-bash_profile/ | |
# | |
# Sections: | |
# 1. Environment Configuration | |
# 2. Make Terminal Better (remapping defaults and adding functionality) | |
# 3. File and Folder Management |
View .bash_profile
# --------------------------------------------------------------------------- | |
# | |
# Description: This file holds all my BASH configurations and aliases | |
# | |
# Sections: | |
# 1. Environment Configuration | |
# 2. Make Terminal Better (remapping defaults and adding functionality) | |
# 3. File and Folder Management | |
# 4. Searching | |
# 5. Process Management |
View proxy.config
files: | |
/etc/nginx/conf.d/proxy.conf: | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
upstream nodejs { | |
server 127.0.0.1:5000; | |
keepalive 256; | |
} |
View get_utc_iso_format.py
def get_iso_format(): | |
""" | |
this returns utc iso8601 string. for example: '2018-06-19T08:51:56+00:00' | |
""" | |
import datetime | |
return datetime.datetime.now(tz=datetime.timezone.utc).replace(microsecond=0).isoformat() |
View disableBtnDuringAjax.js
/** | |
* disable clicked button before jQuery ajax request and enable after ajax request finished | |
* @param {Function} ajaxFn | |
* ajaxFn should return executed jQuery AJAX function | |
* @returns {Function} | |
* returned function should be placed in event listener of Element | |
* | |
* Usage: | |
* $('#deactivate-btn').click(disableBtnDuringAjax(function(e) { | |
* return $.get('/api/users', function (data) { |
View getQueryParam.js
/** | |
* @param {string} name | |
* @returns {string|null} | |
* getQueryParam('a') returns '1' on page http://domain.com/page.html?a=1&b=2 | |
**/ | |
function getQueryParam(name) { | |
const q = window.location.search.match( | |
new RegExp('[?&]' + name + '=([^&#]*)') | |
); | |
return q && q[1]; |
NewerOlder