Skip to content

Instantly share code, notes, and snippets.

View ygweric's full-sized avatar
💭
I may be slow to respond.

Eric ygweric

💭
I may be slow to respond.
  • Auckland, New Zealand
View GitHub Profile
@ygweric
ygweric / util.m
Last active November 16, 2015 03:24
数字转中文大写 obj-c
+ (NSString*)numberToChineseUppercase:(double)num{
int iLen,iNum,iAddZero=0;
NSMutableString *szChMoney = [[NSMutableString alloc] init];
NSArray *hzUnit = @[@"分",@"角",@"元",@"拾",@"佰",@"仟",@"万",@"拾",@"佰",@"仟",@"万",@"亿",@"拾",@"佰",@"仟",@"万",@"拾",@"佰",@"仟"];
NSArray *hzNum = @[@"零",@"壹",@"贰",@"叁",@"肆",@"伍",@"陆",@"柒",@"捌",@"玖"];
NSString *szNum = [NSString stringWithFormat:@"%18.0f",num*100];
szNum = [szNum stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
iLen =(int) szNum.length;
@ygweric
ygweric / Main.java
Last active December 10, 2015 10:21
convert model of MTLModel(ObjC) to ObjectMapper(Swift)
package com.dogkk;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ygweric
ygweric / Snippet.txt
Last active January 10, 2016 04:27
ObjC code snippet
## UI Code Snippet
#### UILabel
```
{
UILabel* lb =[[UILabel alloc]initWithFrame:CGRectZero];
lb.autoresizingMask=UIViewAutoresizingFlexibleWidth;
@ygweric
ygweric / Swizzle
Created November 28, 2016 22:11
Swizzle for class method and instance method with Swift
func swizzleClassMethod(cls: AnyClass, oldSelector: Selector, newSelector: Selector) {
let oldMethod = class_getClassMethod(cls, oldSelector)
let newMethod = class_getClassMethod(cls, newSelector)
method_exchangeImplementations(oldMethod, newMethod)
// following code not work
// if(class_addMethod(cls, oldSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) {
// class_replaceMethod(cls, newSelector, method_getImplementation(oldMethod), method_getTypeEncoding(oldMethod))
// } else {
import UIKit
func isExactClass<T>(obj: Any, _ _: T.Type) -> Bool{
return type(of: obj) == T.self
}
class Dog {
@ygweric
ygweric / command.txt
Created September 23, 2017 00:30
Git commands list
GIT COMMAND
//edit the last commit
git commit --amend -m "New commit message"
#Remove information on branches that were deleted on origin
git fetch --prune
# to create a new branch and switch to it in one step
$ git checkout -b <branch-name>
@ygweric
ygweric / Jenkins+fastlane troubleshooting
Last active October 1, 2017 23:47
Jenkins+fastlane troubleshooting on iOS
Jenkin + fastlane draft
brew services start jenkins-lts
brew services restart jenkins-lts
PATH=$PATH:/usr/local/bin/
# ENV["FASTLANE_PASSWORD"] = "123123123"
cert
@ygweric
ygweric / launcher.json
Last active January 26, 2018 03:16
Config VSCode to debug with jest
{
"name": "Jest Tests",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"type": "node",
"request": "launch",
"args": [
"-i"
],
}
@ygweric
ygweric / gist:422cee5dbd7e79dd6fa94da561e8ae50
Last active January 29, 2018 02:24
JavaScript 'this' and '=>' arrow function
const Adder = new function() {
this.sum = 0;
this.add = function(numbers) {
numbers.forEach(function(n) {
this.sum +=n;
});
};
}
Adder.add([1, 2, 3]);
{
"python.pythonPath": "~/.virtualenvs/djangosite/bin/python",
"python.linting.pep8Enabled": true,
"python.linting.pep8Args": [
"--ignore=E501"
],
"python.linting.pylintPath": "~/.virtualenvs/djangosite/bin/pylint",
"python.linting.pylintArgs": [
"--load-plugins",
"pylint_django"