Skip to content

Instantly share code, notes, and snippets.

@cybertk
cybertk / unzip.rb
Last active August 29, 2015 14:05
Unzip and handle filename encoding correctly
#!/usr/bin/ruby
# Download from https://gist.github.com/cybertk/ff72d68e592966b11c23#file-unzip-rb
require 'optparse'
require 'zip'
require 'rchardet'
def GuessEncoding(zipfile_name)
enc = {}
@cybertk
cybertk / md_github_issue_link.py
Last active August 29, 2015 14:05
Render github issue with link
@cybertk
cybertk / heroku_remove_apps.rb
Created July 25, 2014 09:52
Remove multiple apps against regex pattern
#!/usr/bin/ruby
require 'optparse'
def RemoveHerokuAppsWithPattern(pattern, confirm)
apps = []
# Find apps to remove
`heroku apps`.lines do |line|
_, app = line.match(/(#{pattern}.*)/).to_a
@cybertk
cybertk / send_sms.py
Created July 22, 2014 16:58
Send sms via Twillio
#!/usr/bin/env python
from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid =
auth_token =
client = TwilioRestClient(account_sid, auth_token)
message = client.sms.messages.create(body="Jenny please?! I love you <3",
@cybertk
cybertk / watermark.py
Created July 22, 2014 16:56
Add a text watermark to give image
#!/usr/bin/env python
import os
import sys
TEXT_ID = 'itunesartwork'
# Provided by sw-dev.herokuapp.com
os.environ.setdefault('CLOUDINARY_URL',
'cloudinary://api_key:secret')
@cybertk
cybertk / generate_samples.py
Created July 22, 2014 16:53
Generate normal distrubution samples with given mu and sigma
#!/usr/bin/env python
import sys
import optparse
import numpy as np
from progress.counter import Counter
def GenerateSamples(mu, sigma, size, delta):
bar = Counter('Calculating: ')
@cybertk
cybertk / heroku.py
Created July 22, 2014 16:49
Auto append --app to heroku bin according to ENV['HEROKU_APP']
#!/usr/bin/env python
#
# A simple wrapper support select app by reading from environment vars and
# auto append the --app to origin heroku bin.
#
# Last-updated: Fri Dec 6 17:19:07 CST 2013 by quanlong.
import sys
import os
import subprocess
@cybertk
cybertk / remove_unused_images.py
Created July 22, 2014 16:45
Remove unused images from Xcode project
#!/usr/bin/env python
# Copyright (c) 2014 Quanlong. All rights reserved.
#
# \author: Quanlong <quanlong.he@gmail.com>
import logging
import subprocess
import re
import optparse
import sys
@cybertk
cybertk / generate_localized_strings.py
Created July 22, 2014 16:42
Generate Localizable.strings from code and stroyboards
#!/usr/bin/env python
# Copyright (c) 2014 Quanlong. All rights reserved.
#
# \author: Quanlong <quanlong.he@gmail.com>
import subprocess
import re
import optparse
import sys
import os
@cybertk
cybertk / generate_xcassets.py
Created July 22, 2014 16:39
Generate xcassets from file system
#!/usr/bin/env python
import shutil
import os
import glob
import json
import sys
def CreateXcassets(name):
# Cleanup siliently first.