Skip to content

Instantly share code, notes, and snippets.

View ytyubox's full-sized avatar
😎
TooFastToSlow

Tsungyu Yu ytyubox

😎
TooFastToSlow
View GitHub Profile
@ytyubox
ytyubox / Nibed.swift
Last active June 17, 2019 06:59
A useful protocol when deal with Nib
protocol Nibed {
static func nib() -> UINib
static var id:String {get}
}
extension Nibed where Self: UITableViewCell{
static func nib() -> UINib {
return UINib(nibName: id, bundle: nil)
}
static var id:String {
@ytyubox
ytyubox / Markdium-Diff.diff
Created June 18, 2019 03:24
Markdium-Hello Markdium!
public class Hello1
{
public static void Main()
{
- System.Console.WriteLine("Hello, World!");
+ System.Console.WriteLine("Rock all night long!");
}
}
@ytyubox
ytyubox / Markdium-TypeScript.ts
Created June 18, 2019 03:24
Markdium-Hello Markdium!
let foo = 'bar'
/**
Don't worry about the code block, it will be saved as a gist with right language format, and auto embed to your post.
**/
@ytyubox
ytyubox / print+dprint.swift
Last active October 5, 2020 05:50
A useful print helping debugging.
func dprint(_ objects:Any..., separator: String = " ", terminator: String = "\n",file:String = #file,line:Int = #line, function:String = #function){
#if DEBUG
print((file).split(separator: "/").last!,line.description + ":",function)
print("🦑 Debug info: \n\t", terminator: "")
for i in objects{
print(i, separator: "", terminator: separator)
}
print(terminator)
#endif
}
@ytyubox
ytyubox / Comparable+maxmin.md
Last active June 21, 2019 09:35
Using max_min like in the OOP pro.

Reason

I found a lot of time waste in reading max(min(_, _), _), trying to reduce pain. So found this a easy way think in OOP, but I had a hard time naming the method, can AnyOne help me?

Before

let variable = 3
let afterValue = max(2, min(30, variable))
@ytyubox
ytyubox / TheCell.swift
Last active June 27, 2019 03:33
Crazy TableViewCell generic
class TheCell:UITableViewCell,Nibed{
...
}
@ytyubox
ytyubox / Markdium-Diff.diff
Created July 8, 2019 09:56
Markdium-A handy tool for using Markdown
public class Hello1
{
public static void Main()
{
- System.Console.WriteLine("Hello, World!");
+ System.Console.WriteLine("Rock all night long!");
}
}
@ytyubox
ytyubox / Markdium-TypeScript.ts
Created July 8, 2019 09:56
Markdium-A handy tool for using Markdown
let foo = 'bar'
/**
Don't worry about the code block, it will be saved as a gist with right language format, and auto embed to your post.
**/
@ytyubox
ytyubox / Markdium-Swift.swift
Created July 8, 2019 09:57
Markdium-Swift Capturing Value: Adventure in Fibonacci Number of Dynamic Programming
func fib(_ n: Int) -> Int {
guard n > 1 else { return n }
return fib(n-1) + fib(n-2)
}
@ytyubox
ytyubox / Markdium-Swift.swift
Last active July 8, 2019 10:01
Markdium-Swift Capturing Value: Adventure in Fibonacci Number of Dynamic Programming
//main
let fibonacci = makeFibonacci()
fibonacci(10)
fibonacci(5)
fibonacci(2)
fibonacci(3)