Skip to content

Instantly share code, notes, and snippets.

View GenoZhou's full-sized avatar

Hanxuan Zhou GenoZhou

View GitHub Profile
@GenoZhou
GenoZhou / obsidian-web-clipper.js
Last active December 12, 2023 14:17 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/[email protected]?module'), import('https://unpkg.com/@tehshrike/[email protected]'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@GenoZhou
GenoZhou / UITableView.swift
Created November 5, 2017 15:34
Swift 4 UITableView extensions.
public protocol ReusableView: class { }
extension ReusableView where Self: UIView {
public static var reuseIdentifier: String {
return String(describing: self)
}
}
extension UITableViewCell: ReusableView { }
extension UITableViewHeaderFooterView: ReusableView { }
@GenoZhou
GenoZhou / UIView.swift
Last active November 5, 2017 15:34
Swift 4 UIView extensions.
extension UIView {
public func addSubviews(_ subviews: [UIView], tAMIC: Bool = false) {
for subview in subviews {
addSubview(subview)
subview.translatesAutoresizingMaskIntoConstraints = false
}
}
}
@GenoZhou
GenoZhou / UIView+AutoLayout.swift
Last active November 24, 2017 10:41
Swift 4 UIView Autolayout extensions.
extension UIView {
@discardableResult
public func constrainEdges(to view: UIView) -> [NSLayoutConstraint] {
let constraints = [
leadingAnchor.constraint(equalTo: view.leadingAnchor),
topAnchor.constraint(equalTo: view.topAnchor),
trailingAnchor.constraint(equalTo: view.trailingAnchor),
bottomAnchor.constraint(equalTo: view.bottomAnchor)
]
NSLayoutConstraint.activate(constraints)