Skip to content

Instantly share code, notes, and snippets.

@cybertk
cybertk / largest
Last active Jun 1, 2017
List directories sorted by size, find largest directories
View largest
#!/usr/bin/env bash
# List directories sorted by size, find largest directories
# Author: Quanlong <kyan.ql.he@gmail.com>
# Version: v20170601
#
# Upgrade with curl -o https://gist.githubusercontent.com/cybertk/4b02531350c09235f3e2d00fdbb3bbcd/raw/36ebae4da87ea7fe504ba58c32c81060c62e6b8d/largest
list_dir_by_size() {
declare dir="$1"
@cybertk
cybertk / SimpleHTTPServerWithUpload.py
Created May 16, 2017 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
View SimpleHTTPServerWithUpload.py
#!/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 Jun 20, 2016 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

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 / avi2mp4.sh
Created Feb 29, 2016
Convert avi to mp4
View avi2mp4.sh
#!/bin/sh
O=mp4s
videos=$(find ./videos -iname "*.avi")
for f in $videos; do
o="$O/$(basename ${f%%.avi}).mp4"
if [[ ! -f "$o" ]]; then
cmd="HandBrakeCLI -i "$f" -o "$O/$(basename ${f%%.avi}).mp4""
@cybertk
cybertk / stuns
Created Feb 22, 2016 — forked from yetithefoot/stuns
STUN+TURN servers list
View stuns
{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 / macs-on-active-directory.md
Created Nov 25, 2015 — forked from bzerangue/macs-on-active-directory.md
Binding and Unbinding to Active Directory from Mac OS via Command Line
View macs-on-active-directory.md

Binding and Unbinding to Active Directory from Mac OS via Command Line

  • Open the Terminal Application
  • Type in sudo -i and type in your Mac Administrator account password. sudo gives you root level or administrator level privileges.

To View current Active Directory Settings

dsconfigad -show

To Unbind a Computer from an Active Directory Domain

@cybertk
cybertk / UITextFieldTextDidChangeNotification.swift
Created Sep 5, 2015
Observe UITextFieldTextDidChangeNotification
View UITextFieldTextDidChangeNotification.swift
NSNotificationCenter.defaultCenter().addObserverForName(UITextFieldTextDidChangeNotification, object: textField, queue: nil, usingBlock: { note in
print("UITextFieldTextDidChangeNotification")
})
@cybertk
cybertk / UITableView+ClearSelections.swift
Created Aug 20, 2015
Clear all selections of UITableView
View UITableView+ClearSelections.swift
//
// UITableView+ClearSelections.swift
// Cybertk
//
// Created by Quanlong He on 8/20/15.
// Copyright © 2015 Quanlong He. All rights reserved.
//
import Foundation
@cybertk
cybertk / jumpToAppStore.swift
Last active Aug 29, 2015
Jump to App's main page in App Store
View jumpToAppStore.swift
// 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 / UInt32+IPv4String.swift
Created Aug 17, 2015
Convert IP address to dot syntax from unsigned integer in iOS
View UInt32+IPv4String.swift
//
// UInt32+IPv4String.swift
// Cybertk
//
// Created by Quanlong He on 8/14/15.
// Copyright © 2015 Quanlong He. All rights reserved.
//
import Foundation