Skip to content

Instantly share code, notes, and snippets.

View willard1218's full-sized avatar

Willard, Lin willard1218

View GitHub Profile
@willard1218
willard1218 / ViewController.m
Last active April 21, 2017 02:21
Scrollable stackView
//
// ViewController.m
// stackVIewtest
//
//
#import "ViewController.h"
@interface ViewController ()
@property UILabel *titleLabel;
@willard1218
willard1218 / UITableView+Helper.h
Last active April 22, 2017 07:08
Simplify register/dequeue TableViewCell
#import <UIKit/UIKit.h>
@interface UITableView (Helper)
- (void)registerClass:(_Nonnull Class)cellClass;
- (void)registerClassList:(NSArray <Class> *_Nonnull)cellClassList;
- (__kindof UITableViewCell *_Nonnull)dequeueReusableCellWithClass:(_Nonnull Class)cellClass forIndexPath:(NSIndexPath *_Nonnull)indexPath;
@end
@willard1218
willard1218 / en.json
Created April 26, 2017 03:05
MCLocalization resource for en
{
"greeting": "Hello!",
"message": "Tap on the buttons below to switch languages",
"glory": "Glory Glory, %name%!",
"mustache": "mustache",
"lovely-mustache": "What a wonderful {{mustache}} you have!"
}
@willard1218
willard1218 / string.json
Created April 26, 2017 03:44
MCLocalization resource
{
"en": {
"greeting": "Hello!",
"message": "Tap on the buttons below to switch languages",
"glory": "Glory Glory, %name%!",
"mustache": "mustache",
"lovely-mustache": "What a wonderful {{mustache}} you have!"
},
"ru": {
"greeting": "Привет!",
{
"dev" : {
"translation" : {
"key" : "value dev"
}
},
"en" : {
"translation" : {
"key" : "value en"
}
@willard1218
willard1218 / tedInfos.json
Created May 3, 2017 21:45
Ted Article list
[{"id": 1, "title": "Al Gore On Averting Climate Crisis", "url": "http://www.ted.com/talks/al_gore_on_averting_climate_crisis"},
{"id": 10, "title": "Dean Ornish On The World S Killer Diet", "url": "http://www.ted.com/talks/dean_ornish_on_the_world_s_killer_diet"},
{"id": 1000, "title": "Gero Miesenboeck", "url": "http://www.ted.com/talks/gero_miesenboeck"},
{"id": 1001, "title": "Andrew Bird S One Man Orchestra Of The Imagination", "url": "http://www.ted.com/talks/andrew_bird_s_one_man_orchestra_of_the_imagination"},
{"id": 1002, "title": "Emily Pilloton Teaching Design For Change", "url": "http://www.ted.com/talks/emily_pilloton_teaching_design_for_change"},
{"id": 1003, "title": "Stefan Wolff The Path To Ending Ethnic Conflicts", "url": "http://www.ted.com/talks/stefan_wolff_the_path_to_ending_ethnic_conflicts"},
{"id": 1004, "title": "Aaron Huey", "url": "http://www.ted.com/talks/aaron_huey"},
{"id": 1005, "title": "Auret Van Heerden Making Global Labor Fair", "url": "http://www.ted.com/talks/auret_van_he
@willard1218
willard1218 / ViewController.m
Created May 9, 2017 00:19
ScrollView constraint issue
//
// ViewController.m
// scrollveiwtes
//
// Created by willard on 2017/5/9.
// Copyright © 2017年 willard. All rights reserved.
//
#import "ViewController.h"
@willard1218
willard1218 / pop.swift
Last active October 9, 2017 15:58
Rewrite code in functional programming
// source : https://github.com/TerryCK/Protocol-Oriented-Programming
extension Collection where Iterator.Element == Int {
func countOddEven() -> (odd: Int, even: Int) {
return self.reduce((0, 0)) { (tuple, number) -> (odd: Int, even: Int) in
return (number % 2 == 0) ?
(tuple.0, tuple.1 + 1) :
(tuple.0 + 1,tuple.1)
}
//
// ViewController.m
// GifEncoderTest
//
// Created by willard on 2017/10/18.
// Copyright © 2017年 willard. All rights reserved.
//
#import "ViewController.h"
#import <Photos/Photos.h>
@willard1218
willard1218 / server.js
Created October 25, 2017 04:00
web socket
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(data) {
console.log("reveice : " + data)