This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function base64AddPadding(str: string) { | |
return str + Array((4 - str.length % 4) % 4 + 1).join('='); | |
} | |
// should set your encryption, integrity key | |
const e_key = Buffer.from([0x00, ...]); | |
const i_key = Buffer.from([0x00, ...]); | |
// https://developers.google.com/authorized-buyers/rtb/response-guide/decrypt-price | |
// https://github.com/google/openrtb-doubleclick/blob/master/doubleclick-core/src/main/java/com/google/doubleclick/crypto/DoubleClickCrypto.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find which aws instances have consumed connections | |
import boto3 | |
ec2 = boto3.resource('ec2') | |
running_instances = ec2.instances.filter(Filters=[{ | |
'Name': 'instance-state-name', | |
'Values': ['running']}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
abs_min_support = 771 | |
freq_items = [None, {}] | |
# part1 | |
counting = {} | |
with open('categories.txt', 'r') as f: | |
while True: | |
line = f.readline() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------------- | |
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------------- | |
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
/etc/nginx/conf.d/proxy.conf: | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
upstream nodejs { | |
server 127.0.0.1:5000; | |
keepalive 256; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
NewerOlder