Skip to content

Instantly share code, notes, and snippets.

View luosky's full-sized avatar

Luosky luosky

View GitHub Profile
@dhoerl
dhoerl / README.txt
Created January 28, 2012 21:52
UITableViewCells from a NIB - better than Apple's iOS 5 code
Reloading the NIB is expensive. Better to load it once, then instantiate the objects when you need a cell. Note that you can add UIImageViews etc to the nib, even multiple cells, using this method (Apple's "registerNIB" iOS5 allows only one top level object - one UITableViewCell. Bug 10580062 "iOS5 tableView registerNib: overly restrictive"
So my code is below - you read in the NIB once (in +initialize like I did or in viewDidload - whatever. From then on, you instantiate the nib into objects then pick the one you need. This is much more efficient than loading the nib over and over.
@bignerdranch
bignerdranch / BNRTimeBlock.h
Created March 9, 2012 13:51
Timing Utility Post 20120308
CGFloat BNRTimeBlock (void (^block)(void));
@ttscoff
ttscoff / gitlogger.rb
Last active December 26, 2021 16:22
Archive marked git repositories daily commits to Day One and/or text file. Improved by @DivineDominion
#!/usr/bin/env ruby
require 'time'
require 'erb'
require 'cgi'
filename = "~/.gitlogger"
## File format, One per line
# Repo Name:/path/to/base
dayone = false # log to day one? (true or false)
textlog = false # "~/Dropbox/nvALT2.2/GitLogger.md" # set to false to disable
@venj
venj / geocode.m
Created July 5, 2012 05:42
iOS 5 Geocode question.
/*
用iOS 5的GeoCoder API,反向解析经纬度。代码简略如下:
*/
CGFloat lat = 30.0; CGFloat lng = 120.0;
CLGeocoder *coder = [[CLGeocoder alloc] init];
CLLocation *mapLocation = [[CLLocation alloc] initWithLatitude:lat longitude:lng];
[coder reverseGeocodeLocation:mapLocation completionHandler:^(NSArray *placemarks, NSError *error) {
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active June 13, 2024 02:39
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@krzysztofzablocki
krzysztofzablocki / gist:4396302
Last active November 24, 2021 19:17
Set symbol breakpoint on objc_msgSend then setup this debug command to log all methods called in iOS Simulator. If you want to do device debugging change esp+4 register to r0, esp+8 to r1 Found long ago somewhere on stackoverflow.
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) )
@lucifr
lucifr / private.xml
Created February 17, 2013 16:00
My KeyRemap4MacBook private.xml
<?xml version="1.0"?>
<root>
<item>
<name>F19 to F19</name>
<appendix>(F19 to Hyper (ctrl+shift+cmd+opt) + F19 Only, F19)</appendix>
<identifier>private.f192f19</identifier>
<autogen>
--KeyOverlaidModifier--
KeyCode::F19,
KeyCode::COMMAND_L,
@mutewinter
mutewinter / Alfred 3 Workflows.md
Last active November 25, 2020 14:14
A list of Alfred 3 workflows I'm using.
@lexrus
lexrus / gist:5734257
Last active January 6, 2016 08:54
Log all NSNotifications. #import <objc/runtime.h> absolutely! Original: https://coderwall.com/p/7mopeq
#if TARGET_IPHONE_SIMULATOR
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit"
// Log all notifications via tail -f /tmp/msgSends-*
instrumentObjcMessageSends(YES);
#pragma clang diagnostic pop
#endif
@branneman
branneman / better-nodejs-require-paths.md
Last active June 12, 2024 02:40
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions