Skip to content

Instantly share code, notes, and snippets.

View badboy99tw's full-sized avatar
🏠
Working from home

Chìnkhun Lîm badboy99tw

🏠
Working from home
  • Taiwan
View GitHub Profile
@badboy99tw
badboy99tw / updateDir.js
Created April 26, 2019 04:41
Update doc to list files in specific folder
function onOpen() {
var ui = DocumentApp.getUi();
ui.createMenu('工具')
.addItem('更新文件索引', 'updateHomePage')
.addToUi();
}
function updateHeader(body, title) {
body.insertParagraph(0, title)
@badboy99tw
badboy99tw / lazy_operator.py
Created October 10, 2017 21:02
Example of Lazy Operator
class LazyProperty:
def __init__(self, method):
self.method = method
self.method_name = method.__name__
print('function overriden: {}'.format(self.method))
print('function\'s name: {}'.format(self.method_name))
def __get__(self, obj, cls):
if not obj:
@badboy99tw
badboy99tw / tagging_s3_objects.py
Created July 10, 2017 10:47
Tagging S3 objects by prefix and suffix
#!/usr/bin/env python
import boto3
import click
def tagging(bucket_name, key, tag_set):
client = boto3.client('s3')
res = client.put_object_tagging(
Bucket=bucket_name,
Key=key,
@badboy99tw
badboy99tw / remove_lambda_versions.py
Last active April 24, 2017 18:07
Tool to remove lambda versions which have no alias pointing to it
#!/usr/bin/env python3
# local
import sys
# third-party
import boto3
from botocore.exceptions import ClientError
#!/usr/bin/env python
from influxdb import InfluxDBClient
'''
Repo: https://github.com/influxdata/influxdb-python
'''
def write(json_body):
client = InfluxDBClient(HOST, port=PORT, username=USERNAME, password=PASSWORD, database=DATABASE)
client.create_database(DATABASE)
#/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import os
import click
@click.command()
@click.option('-s', '--source')
@badboy99tw
badboy99tw / service.js
Created May 28, 2016 19:21
Nodejs server with pid management for upstart.
var npid = require('npid');
// node service.js -p /var/run/service.pid
var pid = npid.create(process.argv[3])
var pid = npid.create('./example.pid');
pid.removeOnExit();
function exit() {
process.exit(0);
}
@badboy99tw
badboy99tw / bootstrap_for_encoding_server.sh
Last active December 28, 2015 02:56 — forked from drakeguan/bootstrap_for_encoding_server.sh
Bash script to install latest version of ffmpeg, x264 and libvpx on Ubuntu 14.04 server
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 14.04
# Copyright @ 2014 Shuen-Huei (Drake) Guan <drake.guan@gmail.com>
# References:
# * https://gist.github.com/xdamman/e4f713c8cd1a389a5917
# * https://blog.dlasley.net/2013/05/install-ffmpeg-from-source/
# * http://fermat-little-theorem-blog.logdown.com/posts/203069-solved-when-building-gpac-suffer-usr-local-lib-libswscalea-error-adding-symbols-bad-value
@badboy99tw
badboy99tw / run_cmds.py
Created July 23, 2015 03:18
Tool to run commands parallelly from command list file with specific number of processes and pause time between each commands.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import parmap
import path
import shlex
import subprocess
import sys
import time
@badboy99tw
badboy99tw / example_google_spreadsheets
Created November 25, 2014 03:55
example_google_spreadsheets
#!/usr/bin/env python
import json
import urllib2
def get_data_from_google_spreadsheet(url):
data_json = urllib2.urlopen(url)
data_dict = json.load(data_json)