Skip to content

Instantly share code, notes, and snippets.

Avatar
🌀

柳东原 · Dongyuan Liu xhacker

🌀
View GitHub Profile
View UIFontCascadeList.m
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 Feb 15, 2017
Convert image to a 2x image
View retinalize.sh
retinalize() { convert -density 144 -units pixelsperinch "$1" "$1" }
@xhacker
xhacker / style.css
Last active Feb 4, 2017
Better style for Stash
View style.css
body,
textarea {
font-family: -apple-system !important;
-webkit-font-smoothing: subpixel-antialiased !important;
}
pre,
code,
.line-number,
.blame,
@xhacker
xhacker / UIAppearance+Swift.m
Created Sep 6, 2015
appearanceWhenContainedIn: for Swift
View UIAppearance+Swift.m
#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 Aug 29, 2015
This script migrates Inboard beta library to Inboard App Store version library.
View migrate.py
#!/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 Dec 9, 2014
Update Git repos in directory
View update-git-repos.sh
find . ! -path . -maxdepth 1 -type d -exec sh -c '(cd {} && pwd && git pull)' ';'
@xhacker
xhacker / emoji.plist
Last active Apr 1, 2021
/System/Library/LinguisticData/RequiredAssets_zh.bundle/AssetData/emoji.plist in OS X 10.11 Copyright (C) Apple Inc.
View emoji.plist
<?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>
View recursive_dp_fibonacci.py
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 Nov 7, 2014
Clone only the history of a repo into a new repo
View git_history_cloner.py
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,