Skip to content

Instantly share code, notes, and snippets.

View zqqf16's full-sized avatar
:electron:
Focusing

zqqf16 zqqf16

:electron:
Focusing
View GitHub Profile
@zqqf16
zqqf16 / meta.py
Created December 26, 2013 05:29
A simple code to learn meta class.
#!/usr/bin/env python
class Meta(type):
def __new__(self, name, bases, attrs):
print('Meta: __new__: {} | {} | {} | {}'.format(self, name, bases, attrs))
return super(Meta, self).__new__(self, name, bases, attrs)
def __init__(cls, name, bases, attrs):
print('Meta: __init__: {} | {} | {} | {}'.format(cls, name, bases, attrs))
super(Meta, cls).__init__(name, bases, attrs)
@zqqf16
zqqf16 / ks2apple.py
Last active February 23, 2016 06:01
Convert KSCrash log to Apple format
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import json
import os
from datetime import datetime
from dateutil import parser, tz
def dump_json(obj):
return json.dumps(obj, indent=4,
@zqqf16
zqqf16 / gist:06fa47b4b51fef1008bc
Created March 4, 2016 08:09
PAC rules for Slack
"slack.com",
"slack-imgs.com",
"slack-edge.com",
"slack-msgs.com",
"api.mixpanel.com",
"global.ssl.fastly.net",
"amazonaws.com",
@zqqf16
zqqf16 / list_class.sh
Last active May 13, 2016 00:53
List all objective-c classes in static libraries.
#!/bin/bash
find ./ -name "*.a" | xargs nm -gU | sed -n -e 's/.*_OBJC_CLASS_$_\(.*\)/\1/p'
@zqqf16
zqqf16 / DynamicFunctions.swift
Created August 4, 2016 07:26 — forked from neonichu/DynamicFunctions.swift
Using dlopen / dlsym to call C functions from Swift
import Darwin
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW)
let sym = dlsym(handle, "random")
let functionPointer = UnsafeMutablePointer<() -> CLong>(sym)
let result = functionPointer.memory()
println(result)
- (NSString *)executableUUID {
const struct mach_header *executableHeader = NULL;
for (uint32_t i = 0; i < _dyld_image_count(); i++) {
const struct mach_header *header = _dyld_get_image_header(i);
if (header->filetype == MH_EXECUTE) {
executableHeader = header;
break;
}
}
@zqqf16
zqqf16 / poddiff.py
Last active November 24, 2016 05:26
Diff Podfile.lock
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import re
from distutils.version import LooseVersion
_POD_RE = re.compile(r'\s{1,1}- (.*) \((.*)\)')
def parse_lock_file(lock):
pods = {}
@zqqf16
zqqf16 / check_assets.sh
Created March 28, 2017 07:41
A "post action" script to check Assets.cer in iOS App
#!/bin/bash
# Add this script to your Scheme->Build->Post Actions
ASSETS_PATH=${CODESIGNING_FOLDER_PATH}/Assets.car
xcrun --sdk ${PLATFORM_NAME} assetutil --info ${ASSETS_PATH} | grep -q "DisplayGamut.*P3"
if [ $? -eq 0 ]; then
osascript -e 'tell app "System Events" to display dialog "Some images are in Display P3 gamut, which is not supported in iOS 9.0~9.2"'
# xcrun --sdk ${PLATFORM_NAME} assetutil --info ${ASSETS_PATH} > /tmp/assets.json
#!/bin/bash
DERIVED_DATA=~/Library/Developer/Xcode/DerivedData
# Kill Xcode
echo "💥 Killing Xcode ..."
kill $(ps aux | grep 'Xcode' | awk '{print $2}') 2>/dev/null
# Remove xcuserdata
for f in `ls -t $DERIVED_DATA`; do
@zqqf16
zqqf16 / sandbox.sh
Created June 7, 2018 02:48
Mount iOS app sandbox
#!/bin/bash
TARGET="/Volumes/sandbox.app"
APP_ID="app.bundle.id"
if [ -d $TARGET ]; then
sudo umount $TARGET
fi
sudo mkdir $TARGET