Skip to content

Instantly share code, notes, and snippets.

View lacti's full-sized avatar

Jaeyoung, Choi lacti

View GitHub Profile
@lacti
lacti / cat-envrc.sh
Last active July 18, 2019 11:03
Upload envrc to AWS SSM
#!/bin/bash
NAME="$(basename "${PWD}")"
echo "${NAME}"
aws --profile ${AWS_PROFILE} \
ssm get-parameter \
--name "${NAME}" \
--with-decryption \
| jq -r ".Parameter.Value"
@lacti
lacti / package.json
Created July 18, 2019 06:11
Use Amazon Polly
{
"name": "english-interview",
"version": "1.0.0",
"description": "",
"main": "tts.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
@lacti
lacti / benchmark-set-get.sh
Created June 27, 2019 08:03
Benchmark Simple KV-store
# Redis SET OP
time cat oplist-set | nc -q0 localhost 6379 | grep OK | tqdm --total $(cat oplist-set | wc -l) > /dev/null
# Redis GET OP
time cat oplist-get | nc -q0 localhost 6379 | grep -v '\$' | tqdm --total $(cat oplist-get | wc -l) > /dev/null
# Redis SET+GET OP
time cat oplist | nc -q0 localhost 6379 | grep -v '\$' | tqdm --total $(cat oplist | wc -l) > /dev/null
# SET OP
@lacti
lacti / event.Records.Sns.Message.json
Last active February 12, 2019 02:35
serverless.yml for S3 > SNS > Lambda
{
"Records": [
{
"eventVersion": "2.1",
"eventSource": "aws:s3",
"awsRegion": "<region>",
"eventTime": "<timestamp:ISO8601>",
"eventName": "<s3EventName>",
"userIdentity": {
"principalId": "AWS:<principalId>"
#include <type_traits>
template <int _EVal>
struct get_type;
enum types {
CHAR,
INT,
};
const uuid4 = require('uuid/v4');
const { middleware } = require('serverless-simple-middleware');
const handler = middleware.build([
process.env.NODE_ENV === 'development'
? middleware.setup({
config: 'http://local-config-storage/aws-config.json',
mapper: (aws, env) => ({
[env.USER_TABLE]: () => aws.setupDynamoDb(env.MY_TABLE, 'UserId'),
}),
#!/bin/bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"
sudo apt update --fix-missing
sudo apt install -y docker-ce
sudo apt install -f
sudo apt install -y docker-ce
@lacti
lacti / build_tensorflow.sh
Last active April 18, 2018 07:07
Build tensorflow 1.7 from source with python 3.6.4 on pyenv.
#!/bin/bash
export LC_ALL=en_US.UTF-8
# Install Python 3.6.4
sudo apt update && sudo apt install -y apt-utils bash git curl gcc g++ build-essential automake autoconf libbz2-dev libreadline-dev libsqlite3-dev zlib1g-dev libssl-dev
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
echo 'export PATH="~/.pyenv/bin:$PATH"; eval "$(pyenv init -)"; eval "$(pyenv virtualenv-init -)"' > ~/.bashrc
source ~/.bashrc
pyenv install 3.6.4
from PIL import Image
def process(file):
try:
image = Image.open(file)
if image.mode == 'RGBA':
bg = Image.new('RGBA', image.size)
bg.paste(image, (0, 0), image)
bg.save(file + '_processed.png', "PNG")
@lacti
lacti / Echo100.cs
Last active January 17, 2018 17:05
using System;
using System.Net;
using System.Net.Sockets;
namespace chat100_sharp
{
class Session
{
public Session(Socket socket)
{