Skip to content

Instantly share code, notes, and snippets.


jakehao haojianzong

View GitHub Profile
haojianzong / gist:f93b635e521a1aa2344b07c8782b2df6
Created May 30, 2021
Convert iOS version string into number - Swift
View gist:f93b635e521a1aa2344b07c8782b2df6
// Why do you want a numeric version? Because number format is easier to use than string.
// For example, you may want to write a NSPredicate for Core Data fetch for different version:
// NSPredicate(format: "clientVersionNumber < %@", "2070500") // 2.7.5
// This gist assume the version digit is limitted to 4.
public static var versionString: String {
return (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "1.0"
// Only support 4 digits, invalid string will return 0, longer digits will be dropped
haojianzong / LayoutUtility.swift
Last active Apr 9, 2022
A missing Auto Layout helper for UIKit
View LayoutUtility.swift
import Foundation
import UIKit
// A small utility for NSLayoutDimension shortcuts
public protocol PinObject {
var topAnchor: NSLayoutYAxisAnchor { get }
var bottomAnchor: NSLayoutYAxisAnchor { get }
var leadingAnchor: NSLayoutXAxisAnchor { get }
var trailingAnchor: NSLayoutXAxisAnchor { get }
haojianzong / file_sizes_group_by_type
Created Mar 31, 2016
Bash sum file sizes in folder group by file type
View file_sizes_group_by_type
types=($(find . -type f -name '*.*' | sed 's|.*\.||' | sort -u))
for type in ${types[@]}; do
sum=$(find . -type f -name "*.$type" -exec du -ch {} + | grep total$)
echo "$type : $sum"
View svn-moves-with-synx.txt
# This script move files from an old directory into a new dirctory
# using the file hierarchy from a reference directory, while preserving svn
# log history.
# The purpose is to organize files in one place and do 'svn mv' after
# you have finished organizing. In this way you don't need to worry about other
# developers commiting files while you are moving files around.
haojianzong /
Last active Aug 29, 2015 — forked from dergachev/
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF


To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

haojianzong / gist:35619027a1e60754cf99
Created May 17, 2015
A Category to Set LocalizedString for Xib Files in User Define Runtime Attributes
View gist:35619027a1e60754cf99
// UIView+JZLocalizedIB.m
// Created by haojianzong on 12/5/17.
// A Category to Set LocalizedString for Xib Files in User Define Runtime Attributes
#import <UIKit/UIKit.h>
#import "JZLocaleUtils.h"
haojianzong / JZBrief
Created Jan 19, 2015
NSString routine that generates a fix length brief
View JZBrief
static NSInteger mYStringlength = 60;
- (NSString *)brief:(NSString *)text
NSRange stringRange = {0, MIN([text length], mYStringlength)};
stringRange = [text rangeOfComposedCharacterSequencesForRange:stringRange];
NSString *shortBrief = [text substringWithRange:stringRange];
NSString *firstLine =[[self.text componentsSeparatedByString: @"\n"] objectAtIndex:0];
View gist:c7ab2b71a4f955b1bbdb
// this function will active menu using href match
// Author:
function auto_active_menu() {¬
var url = window.location.href;¬
// Work for relative and absolute hrefs¬
$('.menu a').filter(function() {
return this.href == url;¬
View StickyHeaderFlowLayout.h
// StickyHeaderFlowLayout.h
// Wombat
// Created by Todd Laney on 1/9/13.
// Copyright (c) 2013 ToddLa. All rights reserved.
// Modified from THANKS!