Skip to content

Instantly share code, notes, and snippets.

@cybertk
cybertk / mocha_runtime_tests.coffee
Created Sep 11, 2014
Create mocha test/suite at runtime
View mocha_runtime_tests.coffee
require('chai').should()
Mocha = require 'mocha'
Test = Mocha.Test
Suite = Mocha.Suite
mocha = new Mocha
suite = Suite.create mocha.suite, 'I am a dynamic suite'
suite.addTest new Test 'I am a dynamic test', ->
true.should.equal true
@cybertk
cybertk / generate_xcassets.py
Created Jul 22, 2014
Generate xcassets from file system
View generate_xcassets.py
#!/usr/bin/env python
import shutil
import os
import glob
import json
import sys
def CreateXcassets(name):
# Cleanup siliently first.
@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 / 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
@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")
})
View resign-ipa.py
#!/usr/bin/env python
# Copyright (c) 2013 Quanlong He. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
resign-ipa.py -- Resign the ipa with new certificate and mobileprovision.
"""
"""
@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 / generate_localized_strings.py
Created Jul 22, 2014
Generate Localizable.strings from code and stroyboards
View generate_localized_strings.py
#!/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 / 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.
"""