Skip to content

Instantly share code, notes, and snippets.

View KelvinJin's full-sized avatar
🎯
Focusing

Jin Wang KelvinJin

🎯
Focusing
  • Uthoft
  • Melbourne
View GitHub Profile
import UIKit
class ParallaxCollectionViewLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
return super.layoutAttributesForElements(in: rect)?.flatMap { $0.copy() as? UICollectionViewLayoutAttributes }.flatMap(addParallaxToAttributes)
}
// We need to return true here so that everytime we scroll the collection view, the attributes are updated.
override public func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
@KelvinJin
KelvinJin / Logs.md
Created February 2, 2017 23:38
Logs printed out after running jupyter console
iMac:Jupyter jin$ jupyter console --Session.key="b''" --debug --Session.debug=True --kernel=LocalKernel
[ZMQTerminalIPythonApp] Searching ['/Users/jin/Projects/Python/Jupyter', '/Users/jin/.jupyter', '/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[ZMQTerminalIPythonApp] Looking for jupyter_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /usr/local/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /Users/jin/.jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /Users/jin/Projects/Python/Jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /usr/local/etc/jupyter

###Note Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

[UPDATE : Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.]

[UPDATE 2:The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead]

##[UPDATE 3: For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached]

@KelvinJin
KelvinJin / SwiftyBus.swift
Last active October 19, 2016 06:32
A class written in Swift that simplifies how notification works in iOS.
class SwiftyBus {
private static let notificationQueue = DispatchQueue(label: "com.swiftybus.notification")
struct Observer {
let callback: Any
let queue: DispatchQueue
}
static let shared = SwiftyBus()
论坛服务条款
一、用户守则
欢迎您加入『Phoenix』参加交流和讨论,『Phoenix』为公共论坛,为维护网上公共秩序和社会稳定,请您自觉遵守以下条款:
1. 互相尊重,遵守互联网络道德,遵守中华人民共和国的各项有关法律法规。
2. 承担一切因您的行为而直接或间接导致的民事、行政或刑事法律责任。
3. 不得发表违反中华人民共和国宪法和法律、违反改革开放和四项基本原则的言论。
4. 不得利用本论坛危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本论坛制作、复制和传播下列信息:
1) 不得发表反对宪法所确定的基本原则,煽动抗拒、破坏宪法和法律、行政法规实施的;
<html>
<head>
<meta property="og:title" content="Introducing Amazon Echo">
<meta property="og:image" content="https://i.ytimg.com/vi/KkOCeAtKHIc/maxresdefault.jpg">
<meta property="og:description" content="Amazon Echo is always ready, connected, and fast. Just ask for information, music, news, weather, and more. Echo is controlled by your voice for hands-free c...">
<meta property="og:video" content="http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8">
@KelvinJin
KelvinJin / pi.swift
Last active September 5, 2016 13:10
Calculate Pi
import Foundation
srand48(Int(arc4random()))
func rand(from: Double, to: Double) -> Double {
assert(to - from > 0)
let seed = drand48()
return seed * (to - from) + from
}
// XXNibBridge.m
// Version 2.2
//
// Copyright (c) 2015 sunnyxx ( http://github.com/sunnyxx )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
#EXTM3U
#EXT-X-TARGETDURATION:400
#EXT-X-VERSION:2
#EXTINF:400,
http://23.236.118.40/youku/657173189714584074FE8B3A8E/0300011A0057300714F2A2080D48DD530B3109-2D53-6FC6-5CBE-4C8E8B569BB0.flv.ts?ts_start=0&ts_end=400&ts_seg_no=0&ts_keyframe=1
#EXTINF:398,
http://23.236.118.40/youku/657173189714584074FE8B3A8E/0300011A0057300714F2A2080D48DD530B3109-2D53-6FC6-5CBE-4C8E8B569BB0.flv.ts?ts_start=400&ts_end=798&ts_seg_no=1&ts_keyframe=1
#EXT-X-ENDLIST
@KelvinJin
KelvinJin / audioAds.xml
Created December 23, 2015 03:11
The xml file for audio ads. VAST format.
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.0">
<Ad id="2967">
<InLine>
<AdSystem>Mixberry Media</AdSystem>
<Impression>
http://imp.mixberrymedia.com/impressions/capture?parameters=4UV3V8gq_qFhxdSloAjDv2sFtu6uQta0vRQG7haMxCYjgvBFmZx0vphz4-SbbX4KW6OMs9BvMUaEBoSltBh1ETMvRb8qAj_w0vIRlPyNwm35i1v9AFfhz-U2joq7A1bT
</Impression>
<Creatives>
<Creative AdID="2967">
<Linear>