Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Seo simonseo

  • Abu Dhabi/Seoul
View GitHub Profile
@simonseo
simonseo / ec2-host-from-tag-to-env-vars.sh
Created Apr 15, 2020 — forked from marcellodesales/ec2-host-from-tag-to-env-vars.sh
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
View ec2-host-from-tag-to-env-vars.sh
######
# Author: Marcello de Sales (marcello.desales@gmail.com)
# Description: Create Create Environment Variables in EC2 Hosts from EC2 Host Tags
#
### Requirements:
# * Install jq library (sudo apt-get install -y jq)
# * Install the EC2 Instance Metadata Query Tool (http://aws.amazon.com/code/1825)
#
### Installation:
# * Add the Policy EC2:DescribeTags to a User
View decorators.py
# examples from https://realpython.com/primer-on-python-decorators/
import time
import functools
import random
######### Common decorators #########
def timer(func):
"""Print the runtime of the decorated function"""
@functools.wraps(func)
def wrapper_timer(*args, **kwargs):
@simonseo
simonseo / fastcampus_scraper.py
Created Mar 18, 2020
패스트캠퍼스 강좌를 다운로드 받기 위한 스크레이퍼
View fastcampus_scraper.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @File Name: scrapper.py
# @Created: 2020-03-18 02:57:12 Simon Myunggun Seo (simon.seo@nyu.edu)
# @Updated: 2020-03-18 17:08:14 Simon Seo (simon.seo@nyu.edu)
import sys, time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
@simonseo
simonseo / remove_ensure_ascii.py
Created Feb 13, 2019
Converts UTF-8 characters that were encoded in ASCII compatible '\uXXXX' format to non-ASCII characters
View remove_ensure_ascii.py
import json, codecs
input_filename = "message.json"
output_filename = "message_new.json"
with codecs.open(input_filename, 'r', encoding='utf-8') as infile:
with codecs.open(output_filename, 'w', encoding='utf-8') as outfile:
json.dump(json.load(infile), outfile, ensure_ascii=False)
@simonseo
simonseo / fix_latin1_utf8_mojibake.py
Created Feb 13, 2019
Fixes UTF-8 files that are wrongly encoded into Latin-1
View fix_latin1_utf8_mojibake.py
import json, codecs, re
from functools import partial
input_filename = "message.json"
output_filename = "message_new.json"
fix_mojibake_escapes = partial(
re.compile(rb'\\u00([\da-f]{2})').sub,
lambda m: bytes.fromhex(m.group(1).decode()))
@simonseo
simonseo / createM3U.py
Created Apr 3, 2018
Creates .m3u from all mp3 files in the current directory
View createM3U.py
# createM3U.py
# Creates .m3u from current directory
# Dependencies: mutagen
# Usage: put this script in a folder that has mp3 files. run in console like so:
# $ python3 createM3U.py
# or
# $ python3 createM3U.py <path to mp3s>
from mutagen.id3 import ID3
from mutagen.mp3 import MP3