Skip to content

Instantly share code, notes, and snippets.

View lianghai's full-sized avatar

梁海 Liang Hai lianghai

View GitHub Profile
@Jaykul
Jaykul / Adding Fonts Without Elevation.md
Last active November 20, 2023 20:55
Temporary Font Install?

Did you know you can install fonts without elevation?

The catch is that they're only available for the duration of your session. They are, however, available in all apps across the system.

Someone asked about how to do it on Facebook this week, and at first, I just pointed them at the install script for PowerLineFonts which loops through all the fonts in a folder and install them.

I've used this more than a few times to install some fonts, including the PowerLine ones, which are great:

$sa = New-Object -ComObject Shell.Application
@jjgod
jjgod / fallback.m
Last active August 29, 2015 14:04
Test Core Text fallback line height.
// Compile with: clang fallback.m -framework CoreGraphics -framework CoreText -framework Foundation -o fallback
// Run with: ./fallback "Fallback Font Family" "Text to Typeset"
#import <ApplicationServices/ApplicationServices.h>
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
{
if (argc != 3)
return 0;
@jjgod
jjgod / sbix.patch
Created April 28, 2013 20:10
ttx fonttool patch to dump sbix table from Apple Color Emoji, according to http://typophile.com/node/96671#comment-524375 and http://kanji-database.sourceforge.net/fonts/opentype.html
commit 7f2ef9213b3a179d4b39fd921c6affb3d1553053
Author: Jiang Jiang <jiangj@opera.com>
Date: Sun Apr 28 18:17:50 2013 +0200
Add decompilation tool for sbix table used in Apple Color Emoji
diff --git a/Lib/fontTools/ttLib/tables/_s_b_i_x.py b/Lib/fontTools/ttLib/tables/_s_b_i_x.py
new file mode 100644
index 0000000..e126440
--- /dev/null
@MaskRay
MaskRay / gist:4134245
Created November 23, 2012 06:32
Flesch Reading Ease Score of several programming books
% xargs -i sh -c 'echo -n "{} @ "; pdftotext "{}" - 2>/dev/null | ruby -e "require \"lingua\"; p Lingua::EN::Readability.new(STDIN.read).flesch"' < /tmp/books | sort -t@ -k2n
scheme/sicp.pdf @ 42.013863374063305
smalltalk/Joy of Smalltalk.pdf @ 47.861949781603954
falcon/Falcon Survival Guide.pdf @ 52.899363840845155
ruby/The Rails 3 Way.pdf @ 55.05629641057524
c/The C Programming Language.pdf @ 55.17174939358114
python/Learning Python.pdf @ 56.67476157760058
c++/C++ Primer.pdf @ 57.237840064930595
ruby/The Ruby Programming Language.pdf @ 57.75836947304364
haskell/Real World Haskell.pdf @ 58.23158652909788
@marcedwards
marcedwards / high-dpi-media.css
Last active November 19, 2023 12:56
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@neolee
neolee / TeXIt.tex
Created May 3, 2012 10:46
XeLaTeX Sample
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
% 以上设定默认使用 XeLaTeX 编译,并指定 Unicode 编码,供 TeXShop 自动识别
% XeLaTeX 示例
\documentclass[12pt]{article}
% XeTeX 配合 fontspec 可以非常方便的设置字体
@jjgod
jjgod / cascadelist.m
Created April 19, 2012 08:32
Use cascade list attribute to customize font fallback in Core Text
#import <ApplicationServices/ApplicationServices.h>
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
{
if (argc != 2)
return 0;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
CFStringRef name = (CFStringRef) [NSString stringWithUTF8String: argv[1]];
@gnap
gnap / tagshow
Created April 7, 2012 15:18
Tagging TV Show files of mp4 format in given dir(s) for iTunes import
#!/usr/bin/env python
'''
File: tagshow.py
Author: George Ang <gnap.an@gmail.com>
Description:
'''
import os
import sys
import json
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@disinfeqt
disinfeqt / image_replacer.js
Created March 13, 2012 09:11
Image Replacer on Apple.com
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",