Skip to content

Instantly share code, notes, and snippets.

View xhacker's full-sized avatar
🌀

柳东原 · Dongyuan Liu xhacker

🌀
View GitHub Profile
NSArray *cascadeList = @[[UIFontDescriptor fontDescriptorWithName:@"Helvetica" size:20.0],
[UIFontDescriptor fontDescriptorWithName:@"PingFangTC-Regular" size:20.0]];
CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes((CFDictionaryRef) @{(id)kCTFontCascadeListAttribute: cascadeList});
UIFont *font = (__bridge_transfer UIFont *) CTFontCreateWithFontDescriptor(descriptor, 20, NULL);
CFRelease(descriptor);
self.label.font = font;
self.label.text = @"Helvetica fallback 到 PingFangTC-Regular 汉体书写信息技术标准相容档案下载使用界面简单支援服务升级资讯专业制作创意空间快速无线上网";
@xhacker
xhacker / retinalize.sh
Created February 15, 2017 09:23
Convert image to a 2x image
retinalize() { convert -density 144 -units pixelsperinch "$1" "$1" }
@xhacker
xhacker / style.css
Last active February 4, 2017 15:17
Better style for Stash
body,
textarea {
font-family: -apple-system !important;
-webkit-font-smoothing: subpixel-antialiased !important;
}
pre,
code,
.line-number,
.blame,
/*
Copyright (C) 2015 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
The application delegate class used to manage this sample.
*/
import UIKit
@xhacker
xhacker / UIAppearance+Swift.m
Created September 6, 2015 14:49
appearanceWhenContainedIn: for Swift
#import "UIAppearance+Swift.h"
@implementation UIView (UIViewAppearance_Swift)
+ (instancetype)swift_appearanceWhenContainedIn:(NSArray *)containerClasses
{
NSUInteger count = containerClasses.count;
NSAssert(count <= 10, @"The count of containers greater than 10 is not supported.");
return [self appearanceWhenContainedIn:
@xhacker
xhacker / migrate.py
Last active August 29, 2015 14:13
This script migrates Inboard beta library to Inboard App Store version library.
#!/usr/bin/env python
"""This script migrates Inboard beta library to Inboard App Store version
library."""
import sqlite3
import os
from os.path import expanduser
import subprocess
import shutil
@xhacker
xhacker / update-git-repos.sh
Created December 9, 2014 08:21
Update Git repos in directory
find . ! -path . -maxdepth 1 -type d -exec sh -c '(cd {} && pwd && git pull)' ';'
@xhacker
xhacker / emoji.plist
Last active October 26, 2023 15:59
/System/Library/LinguisticData/RequiredAssets_zh.bundle/AssetData/emoji.plist in OS X 10.11 Copyright (C) Apple Inc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>0</key>
<dict>
<key>emoji</key>
<array>
<string>0⃣️</string>
</array>
from timeit import timeit
setup = """
results = [0 for _ in xrange(100)]
results[1] = 1
results[2] = 1
def fib(n):
if results[n]:
return results[n]
@xhacker
xhacker / git_history_cloner.py
Created November 7, 2014 21:09
Clone only the history of a repo into a new repo
import pygit2
from pygit2 import GIT_SORT_TOPOLOGICAL, GIT_SORT_REVERSE
repo = pygit2.Repository("/path/to/the/repo")
hist_repo = pygit2.Repository("/path/to/the/repo/for/the/history")
parents = []
for commit in repo.walk(repo.head.target,
GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE):
print "[Duplicating] " + commit.message,