Skip to content

Instantly share code, notes, and snippets.

@nuthatch
nuthatch / iOS 7 dynamic font mappings
Last active January 9, 2023 13:55
What is UIFontTextStyleHeadline *really*? Dump out preferredFontForTextStyle for UIFontTextStyleHeadline, UIFontTextStyleSubheadline, UIFontTextStyleBody, UIFontTextStyleFootnote, UIFontTextStyleCaption1, UIFontTextStyleCaption2 to examine the font name, weight, and point size.
+ (void)describePreferredFonts
{
static NSArray *textStyles;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
textStyles = @[UIFontTextStyleHeadline,
UIFontTextStyleSubheadline,
UIFontTextStyleBody,
UIFontTextStyleFootnote,
UIFontTextStyleCaption1,
@johnkary
johnkary / vagrant-sync.sh
Last active December 18, 2015 10:19
Keep VM directory in sync instead of using VirtualBox shared folders or NFS. Ensure the remote directory exists and is chown vagrant:vagrant
#!/bin/sh
while true ; do
# gem install vagrant-sync
# vagrant sync --from ~/Sites/project --to /project
rsync -arq --delete ~/Sites/project vagrant@33.33.33.10:/
sleep 1
done
@sturadnidge
sturadnidge / tmux-1.8-on-CentOS-6.x.txt
Last active May 10, 2021 18:31
Install tmux 1.8 on CentOS 6.x minimal (64bit)
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@amakhmudov
amakhmudov / starting html-strict.html
Created October 4, 2012 19:06
HTML: Starting Strict Template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title></title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="css/normalize.css" type="text/css" />
<link rel="stylesheet" href="css/main.css" type="text/css" />
@spoletto
spoletto / gist:3725118
Created September 14, 2012 21:47
iOS 6 Autorotation Swizzling
@implementation AppDelegate
void SwapMethodImplementations(Class cls, SEL left_sel, SEL right_sel) {
Method leftMethod = class_getInstanceMethod(cls, left_sel);
Method rightMethod = class_getInstanceMethod(cls, right_sel);
method_exchangeImplementations(leftMethod, rightMethod);
}
+ (void)initialize {
if (self == [AppDelegate class]) {
#ifdef __IPHONE_6_0
@FiloSottile
FiloSottile / rasterize.js
Created May 12, 2012 15:38
PhantomJS rasterize.js with "Retina" output
var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 2 || phantom.args.length > 3) {
console.log('Usage: rasterize.js URL filename');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 1280, height: 1024 };