Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MJ111
MJ111 / decrypt_price.ts
Last active August 12, 2020 05:36
Google win price decrypter typescript version
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
@MJ111
MJ111 / parse_redis_clients.py
Last active March 20, 2020 09:21
Analyze clients(aws) when redis connection getting exhausted
# 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']}])
@MJ111
MJ111 / find_eb_ec2_private_ip.sh
Created April 9, 2019 02:17
[Get elasticbeanstalk's ec2 private ip list]
#!/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)')
@MJ111
MJ111 / add_user.sh
Last active April 5, 2022 02:42
openvpn cli add user script
#!/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
@MJ111
MJ111 / .vimrc
Created March 7, 2019 14:32 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" 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
@MJ111
MJ111 / solution.py
Created March 3, 2019 06:30
[pattern discovery - apriori] feedback'll be appreciated.
import itertools
abs_min_support = 771
freq_items = [None, {}]
# part1
counting = {}
with open('categories.txt', 'r') as f:
while True:
line = f.readline()
@MJ111
MJ111 / .bash_profile
Created February 28, 2019 00:11 — forked from stephenll/.bash_profile
.bash_profile file on Mac OS X
# ---------------------------------------------------------------------------
#
# 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
@MJ111
MJ111 / .bash_profile
Created February 27, 2019 14:38 — forked from natelandau/.bash_profile
Mac OSX 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
@MJ111
MJ111 / proxy.config
Created January 31, 2019 06:22
[aws eb nginx proxy] #nginx
files:
/etc/nginx/conf.d/proxy.conf:
mode: "000644"
owner: root
group: root
content: |
upstream nodejs {
server 127.0.0.1:5000;
keepalive 256;
}
@MJ111
MJ111 / get_utc_iso_format.py
Created June 19, 2018 09:00
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()