Skip to content

Instantly share code, notes, and snippets.

View banjun's full-sized avatar

banjun banjun

View GitHub Profile
@banjun
banjun / gist:47404
Created January 15, 2009 13:31
extract mp3 from swf
static unsigned int readUInt(unsigned char *p, unsigned int offset, unsigned int bytes)
{
unsigned int result = 0;
int i;
for (i = 0; i < bytes; ++i){
result += p[offset + i] << ((bytes - i - 1) * 8);
}
return result;
}
static unsigned int readUIntLE(unsigned char *p, unsigned int offset, unsigned int bytes)
ほむ
ほむほむ ほむほむ ほむ ほむほむほむ ほむ
ほむ ほむほむほむほむ ほむほむ ほむ ほむほむほむ ほむ ほむほむほむほむ ほむ ほむほむほむほむほむ ほむ ほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむ ほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむほむ ほむほむほむ ほむ ほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむほむほむ ほむほむ ほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむ ほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむほむ ほむ ほむほむほむほむほむ ほむほむ ほむほむほむほむほむほむほむほむほむ ほむほむほむ ほむほむほむほむほむほむほむほむほむ ほむほむほむほむ ほむほむほむほむほむほむ ほむほむほむほむほむ ほむほむほむほむほむほむほむほむほむほむ ほむほむほむほむほむほむ ほむほむほむほむほむほむほむ ほむほむほむほむほむほむほむ ほむほむほむほむほむ ほむほむほむほむほむほむほむほむ ほむほむほむ
@banjun
banjun / gist:5310157
Last active December 15, 2015 19:19
[iOS][iPhone] basic ifconfig view for Master-Detail project template
#import "BJMasterViewController.h"
#import "BJDetailViewController.h"
#include <ifaddrs.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
{
"name": "AppGroup",
"version": "1.0.0",
"summary": "Injected podspec used by CocoaPods-AppGroup plugin.",
"description": "This is intended to be used as an injected podspec template \n used by the [CocoaPods-ApGroup plugin](https://github.com/mzp/cocoapods-app_group).\n\n It should *not* be referenced outside of that context. \n",
"homepage": "https://github.com/mzp/cocoapods-app_group",
"license": {
"type": "MIT",
"text": "MIT LICENSE Found in the repo"
},
// causes crash of swift-3.0-preview-1-SNAPSHOT-2016-05-31-a-osx and 2016-06-06
// /Library/Developer/Toolchains/swift-3.0-preview-1-SNAPSHOT-2016-05-31-a.xctoolchain/usr/bin/swift swift3-preview1-crash-example1.swift
// /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a.xctoolchain/usr/bin/swift swift3-preview1-crash-example1.swift
// removing any of Equatable or type constraints will make it
protocol P1 {
associatedtype A1: Equatable
}
class C1<T: Equatable> {
@banjun
banjun / ViewController.swift
Last active September 26, 2016 01:23
UIFeedbackGenerators
import UIKit
import NorthLayout
import Ikemen
class ViewController: UIViewController {
override func loadView() {
super.loadView()
func button(_ title: String, _ action: Selector) -> UIButton {
@banjun
banjun / RunScriptBuildPhaseToGenerateDynamicallyLinkedExecutable.sh
Created November 22, 2016 06:26
Generate Swift CLI executable from Xcode target, with CocoaPods Frameworks and Swift stdlibs, without statically linked with the stdlibs
FRAMEWORK_ARG=$(for f in $(echo "${FRAMEWORK_SEARCH_PATHS}"); do echo -n "-F$f "; done)
RUNPATH_ARG=$(for p in $(echo $LD_RUNPATH_SEARCH_PATHS); do echo -n "-Xlinker -rpath -Xlinker $p "; done)
LD="${DT_TOOLCHAIN_DIR}/usr/bin/clang -arch ${arch} -isysroot ${SDKROOT} -L${CONFIGURATION_BUILD_DIR} ${FRAMEWORK_ARG} -filelist ${LINK_FILE_LIST_normal_x86_64} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} ${RUNPATH_ARG} -fobjc-link-runtime -L${DT_TOOLCHAIN_DIR}/usr/lib/swift/macosx -lc++ -framework Foundation -Xlinker -add_ast_path -Xlinker ${OBJECT_FILE_DIR_normal}/${arch}/${EXECUTABLE_NAME}.swiftmodule -Xlinker -dependency_info -Xlinker ${LD_DEPENDENCY_INFO_FILE} -o ${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME}"
echo "$LD"
zsh -c "$LD"
mkdir -p "${CONFIGURATION_BUILD_DIR}/Frameworks"
for f in ${CONFIGURATION_BUILD_DIR}/*/*.framework; do
cp -r "$f" "${CONFIGURATION_BUILD_DIR}/Frameworks/"
done
@banjun
banjun / ViewController.swift
Created December 28, 2016 07:33
App Transport Security (ATS) connection test & report
import Eureka
import SVProgressHUD
import BrightFutures
class ViewController: FormViewController {
init() {
super.init(style: .grouped)
}
required init?(coder aDecoder: NSCoder) {
@banjun
banjun / APFS.swift
Created January 25, 2017 01:05
Is your device using Apple File System (APFS)?
// the original code by apple and its license
// https://developer.apple.com/library/prerelease/content/samplecode/APFSCloning/Listings/clonefile_main_c.html#//apple_ref/doc/uid/TP40017341-clonefile_main_c-DontLinkElementID_5
NSLog("%@", "\(ProcessInfo().operatingSystemVersion)")
/* Initailize state */
let s = copyfile_state_alloc();
let srcPath = NSHomeDirectory() + "/tmp/test.txt"
let copyPath = NSHomeDirectory() + "/tmp/test-copy.txt"
@banjun
banjun / main.swift
Created February 14, 2017 07:36
add Touch Bar support for CLI without .app bundle nor Info.plist
class AppDelegate: NSResponder, NSTouchBarDelegate, NSApplicationDelegate {
@available(OSX 10.12.2, *)
lazy var touchbar: NSTouchBar = {
let tb = NSTouchBar()
tb.delegate = self
tb.defaultItemIdentifiers = [NSTouchBarItemIdentifier(rawValue: "test")]
return tb
}()