Skip to content

Instantly share code, notes, and snippets.

View songzhou21's full-sized avatar
🎯
Focusing

Song Zhou songzhou21

🎯
Focusing
View GitHub Profile
@songzhou21
songzhou21 / pod_using_swift_version.rb
Last active August 31, 2018 09:35
pod using swift version
swift_targets_map = {
"Charts" => "4.1"
}
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
version = swift_targets_map[target.name]
if version
puts "#{target} using Swift #{version}"
//
// PlusOne.m
// test
//
// Created by Song Zhou on 08/05/2017.
// Copyright © 2017 Song Zhou. All rights reserved.
//
#import "PlusOne.h"
@songzhou21
songzhou21 / jekyll-import.php
Created February 15, 2017 05:24 — forked from tylerhall/jekyll-import.php
Import a Jekyll posts directory into WordPress
<?PHP
require '/path/to/markdown-extra.php';
$db = mysql_connect('localhost', 'root', 'password') or die(mysql_error());
mysql_select_db('tylerio', $db) or die(mysql_error());
$files = scandir('posts');
array_shift($files); // .
array_shift($files); // ..
@songzhou21
songzhou21 / image_format.swift
Created October 19, 2016 04:43
image_format
private let pngHeader: [UInt8] = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]
private let jpgHeaderSOI: [UInt8] = [0xFF, 0xD8]
private let jpgHeaderIF: [UInt8] = [0xFF]
private let gifHeader: [UInt8] = [0x47, 0x49, 0x46]
// MARK: - Image format
enum ImageFormat {
case Unknown, PNG, JPEG, GIF
}
@songzhou21
songzhou21 / NSString(md5).m
Last active January 29, 2018 14:10
NSString(md5)
#import <CommonCrypto/CommonCrypto.h>
@interface NSString (md5)
- (NSString *)md5;
@end
@implementation NSString (md5)
- (NSString *)md5
@songzhou21
songzhou21 / update_build_number.sh
Last active August 1, 2016 07:13
update build number for Xcode project with SVN
#!/bin/bash
# before commit, run this script will set build number to recent SVN revision number
# run this script in project directory
echo "Update build number"
echo "get revision number from SVN..."
svn_info=$(svn info -r 'HEAD')
if [[ $? != 0 ]]; then
exit $?
fi
@songzhou21
songzhou21 / CLLocation+Sino.h
Created July 16, 2016 10:57 — forked from zvving/CLLocation+Sino.h
火星坐标系转换扩展。Earth(国外 WGS84), mars(国内 GCJ-02), bearPaw(百度 BD-09) 坐标系间相互转换
//
// CLLocation+Sino.h
//
// Created by i0xbean@gmail.com on 13-4-26.
// 火星坐标系转换扩展
//
// earth(国外 WGS84), mars(国内 GCJ-02), bearPaw(百度 BD-09) 坐标系间相互转换
// 未包含 mars2earth. 需要这个可参考 http://xcodev.com/131.html
#import <CoreLocation/CoreLocation.h>
@songzhou21
songzhou21 / UIView+ExtendTouchRect.m
Created July 12, 2016 06:27 — forked from KittenYang/UIView+ExtendTouchRect.m
一行代码实现点击区域的扩大
void Swizzle(Class c, SEL orig, SEL new) {
Method origMethod = class_getInstanceMethod(c, orig);
Method newMethod = class_getInstanceMethod(c, new);
if (class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))){
class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
method_exchangeImplementations(origMethod, newMethod);
}
}
@songzhou21
songzhou21 / UIGestureRecognizer+Block.m
Created July 5, 2016 01:10 — forked from KittenYang/UIGestureRecognizer+Block.m
使用 Block 创建 UIGestureRecognizer
static const int target_key;
@implementation UIGestureRecognizer (Block)
+(instancetype)nvm_gestureRecognizerWithActionBlock:(NVMGestureBlock)block {
return [[self alloc]initWithActionBlock:block];
}
- (instancetype)initWithActionBlock:(NVMGestureBlock)block {
self = [self init];
[self addActionBlock:block];
@songzhou21
songzhou21 / introrx.md
Created May 3, 2016 08:38 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing