Skip to content

Instantly share code, notes, and snippets.

View honood's full-sized avatar
👋

HoNooD honood

👋
View GitHub Profile
@honood
honood / UIColor+Hex.h
Created July 29, 2012 10:39 — forked from ohsc/UIColor+Hex.h
Enable hex value with UIColor
//
// UIColor+Hex.h
//
//
// Created by 超 沈 on 11-12-31.
// Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@honood
honood / ExtractTTFInfoFromTTC.c
Created October 8, 2012 10:24
获取TTC中所有的TTF字体的信息源码
//
// 原文: http://my.csdn.net/sxjiake/code/detail/13833
//
// 感谢 sxjiake
//
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <locale.h>
@honood
honood / printViewHierarchy.m
Created November 28, 2012 16:22
打印以给定视图为根的视图树中所有子视图
void printViewsInViewHierarchyWithRootView(UIView *rootView)
{
NSCAssert(nil != rootView, @"rootView is nil!");
static NSInteger indentationLevel = -1;
++indentationLevel;
NSMutableString *indentation = [NSMutableString stringWithCapacity:(NSUInteger)indentationLevel];
NSInteger indentationLevelCopy = indentationLevel;
#import <libkern/OSAtomic.h>
#import <dispatch/dispatch.h>
#import <objc/runtime.h>
@implementation MySingleton
+ (void) load
{
// check for weak-linked libdispatch symbols
if ( dispatch_queue_create != 0 )
@honood
honood / HD.txt
Created June 17, 2013 13:57 — forked from lexrus/HD.txt
http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1
@honood
honood / validate_ID_number.m
Last active December 20, 2015 16:19
校验指定中华人民共和国居民身份证号的合法性
#import <Foundation/Foundation.h>
/**
* 根据第 18 位校验指定中华人民共和国居民号码的合法性。
*
* @param IDNumber 待校验的身份证号码。
*
* @return YES 表示合法,NO 表示非法。
*/
BOOL validateIDNumber(NSString *IDNumber)
@honood
honood / reverse_link_list.c
Last active January 1, 2016 23:29
反转单链表 (Reverse A Link List)
@honood
honood / find_infection_point_using_binary_search.c
Created January 2, 2014 13:13
有一个数组,它的元素先上升后下降,请用二分法找出拐点元素的下标。 There is an array whose elements first ascend and then descend. Please find the index of the inflection point element using binary search.
#include <stdio.h>
/**
* 有一个数组,它的元素先上升后下降,请用二分法找出拐点元素的下标。
*
* There is an array whose elements first ascend and then
* descend. Please find the index of the inflection point
* element using binary search.
*/
This file has been truncated, but you can view the full file.
__SSTOKENSTRING = "@generated SignedSource<<dbe928e1275c495c1922c1bf063ffb70>>";
! function(e) {
function t(e) {
function t() {
var t = Array.prototype.map.call(arguments, function(e) {
if (null == e) return null === e ? "null" : "undefined";
if ("string" == typeof e) return '"' + e + '"';
try {
return JSON.stringify(e)
} catch (t) {
@honood
honood / StringSize.swift
Last active September 20, 2015 08:41 — forked from plumhead/StringSize.swift
String extension to find the layout size of a String with specified attributes.
extension String {
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect {
let storage = NSTextStorage(string: self)
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height))
let layout = NSLayoutManager()
layout.addTextContainer(container)
storage.addLayoutManager(layout)
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length))
container.lineFragmentPadding = 0.0
let _ = layout.glyphRangeForTextContainer(container)