Skip to content

Instantly share code, notes, and snippets.

@cybertk
cybertk / SimpleHTTPServerWithUpload.py
Created May 16, 2017 02:29 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@cybertk
cybertk / web-servers.md
Created June 20, 2016 05:54 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@cybertk
cybertk / rake-update-version-android-manifest.rb
Last active March 4, 2016 18:46
Update version in AndroidManifest.xml
task :update_build_number do
File.open('AndroidManifest.xml', 'r+') do |f|
manifest = f.read
build = ENV['TRAVIS_BUILD_NUMBER'] || 0
# Update version
manifest = manifest.gsub(
/android:versionCode=".*"/, "android:versionCode=\"#{build}\"")
# Write back
@cybertk
cybertk / stuns
Created February 22, 2016 02:58 — forked from yetithefoot/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},
@cybertk
cybertk / jumpToAppStore.swift
Last active August 29, 2015 14:27
Jump to App's main page in App Store
// See http://stackoverflow.com/questions/3124080/app-store-link-for-rate-review-this-app
func jumpToAppStore(appID: String) {
let url = "itms-apps://itunes.apple.com/app/id\(appID)"
UIApplication.sharedApplication().openURL(NSURL(string: url)!)
}
@cybertk
cybertk / NSData+HexString.swift
Created August 13, 2015 17:03
Print NSData into Hex format
//
// NSData+HexString.swift
// Cybertk
//
// Created by Quanlong He on 8/14/15.
// Copyright © 2015 Quanlong He. All rights reserved.
//
import Foundation
@cybertk
cybertk / gist:9d81d746a4b6600c85ee
Created May 28, 2015 17:06
Update docker registry in boot2docker
boot2docker ssh "echo $'EXTRA_ARGS=\"--registry-mirror=<DOCKER_REGISTRY>\"' | sudo tee -a /var/lib/boot2docker/profile && sudo /etc/init.d/docker restart"
@cybertk
cybertk / git-copy
Last active August 29, 2015 14:17
Copy a remote git repo to another remote destination
#!/bin/sh
#
# Copy a remote git repo to another remote destination
# https://gist.github.com/cybertk/8a61ed9aca71a66cd711
#
# Copyright (C) 2015 Quanlong <kyan.ql.he@gmail.com>
set -e
# Options validation
namespace :apns do
task :verify do
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert server_certificates_bundle_sandbox.pem -key server_certificates_bundle_sandbox.pem
openssl s_client -connect gateway.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem
end
task :p12topem do
openssl pkcs12 -in apns.p12 -out apns.pem -nodes -clcerts
description "Flynn layer 0"
#start on (started libvirt-bin and started networking)
respawn
respawn limit 1000 60
script
IP_ADDR=$(/sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}')
env ETCD_DISCOVERY=https://discovery.etcd.io/e73ebc86a75276ab5954ba7a6447ec94
flynn-host daemon --manifest /etc/flynn/host-manifest.json --external $IP_ADDR --state /tmp/flynn-host-state.json