Skip to content

Instantly share code, notes, and snippets.

View timonus's full-sized avatar

Tim Johnsen timonus

View GitHub Profile
@alexcabrera
alexcabrera / hack-ia_writer.markdown
Created June 25, 2011 19:50
Easily style HTML output from iA Writer
  1. Right-click on iA Writer.app in your Applications folder, select "Show Package Contents"
  2. Open up Resources/English.lproj/htmlTemplate.html in your favorite text editor
  3. Add a link to a CSS file in your home directory (and anything else you might want). I put mine in ~/Library/Application Support/iA Writer/themes/policus/css/styles.css and decided to load a couple of web fonts from Google. See hacked-htmlTemplate.html later this gist.
  4. Save, exit
  5. Create the CSS file, override default Writer styles

Now when you export to HTML from inside of Writer, your HTML file will be styled according to your your overrides. Want to share your pretty docs? Print to PDF.

Next steps: Link to a locally-hosted jQuery and write a little JS app for switching themes in browser.

@steipete
steipete / UIImage+PSPDFKitAdditions.m
Created August 13, 2011 20:52
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
@evanlong
evanlong / LWHangDetector.h
Last active November 17, 2016 16:06
Simple Hang Detection
/**
Copyright (C) 2011 Evan Long
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
@jordansissel
jordansissel / data.md
Created July 3, 2012 23:36
Compression on large JSON file

The Data

Compression

  • Original: 708MB
  • xz -3: 70MB, 5:41.02 (2.07 mb/sec - 10:1 ratio)
  • bzip2 -3: 74MB, 4:39.11 (2.53 mb/sec - 9.5:1 ratio)
  • gzip -3: 103MB: 0:15.15 (46.73 mb/sec - 6.87:1 ratio)
  • lzop -3: 146MB, 0:06.53 (108.42 mb/sec - 4.85:1 ratio)
@evanlong
evanlong / .osx
Created July 29, 2012 00:14
OS X for Hackers
# ~/.osx — http://mths.be/osx
###############################################################################
# General UI/UX #
###############################################################################
# Set computer name (as done via System Preferences → Sharing)
scutil --set ComputerName "MathBook Pro"
scutil --set HostName "MathBook Pro"
scutil --set LocalHostName "MathBook-Pro"
@daFish
daFish / itunes.countries.js
Last active March 15, 2024 14:21
List of Apple iTunes Store Country codes in Javascript.
var countries = {
ae: 'United Arab Emirates',
ag: 'Antigua and Barbuda',
ai: 'Anguilla',
al: 'Albania',
am: 'Armenia',
ao: 'Angola',
ar: 'Argentina',
at: 'Austria',
au: 'Australia',
@aras-p
aras-p / preprocessor_fun.h
Last active April 28, 2024 15:25
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
Note that like all analogies, this is not a perfect one. I find it helps me think about it though. Also, don't try to draw conclusions about performance from this analogy :)
-[NSUserDefaults setObject:forKey:] is like...
<edit file to add key and value>
git add file
git commit
dispatch_after(some time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[NSUserDefaults standardUserDefaults] synchronize]
});
@steipete
steipete / Macros.h
Last active January 6, 2024 07:24
Declare on your main init that all other init methods should call. It's a nice additional semantic warning. Works with Xcode 5.1 and above. Not tested with earlier variants, but should just be ignored. A reference to this macro shortly appeared in https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObj…
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
@raphaelschaad
raphaelschaad / RSPlayPauseButton.h
Last active July 25, 2016 21:44
Edit: this Gist has now a proper repo and even a CocoaPod: https://github.com/raphaelschaad/RSPlayPauseButton
//
// RSPlayPauseButton.h
//
// Created by Raphael Schaad on 2014-03-22.
// This is free and unencumbered software released into the public domain.
//
#import <UIKit/UIKit.h>