Skip to content

Instantly share code, notes, and snippets.

$('div[data-block-id]:has(div:contains("c8f6e963-f28b-444e-ad23-054d6d94f25d"))').waitUntilExists('div[data-block-id]:has(div:contains("c8f6e963-f28b-444e-ad23-054d6d94f25d"))', function() {
// Page has loaded
$('div[data-block-id]:has(div:contains("c8f6e963-f28b-444e-ad23-054d6d94f25d"))').css('display', 'none');
$('div[data-block-id]:has(div:contains("Directory"))').css('display', 'none');
$('a.notion-link-token.notion-enable-hover span').css('opacity', 1.0);
$('a:regex(href, ^((?!:\/\/).)*$)').removeAttr('target');
$('a:regex(href, ^((?!:\/\/).)*$)').removeAttr('data-token-index');
}, true);
(function (e, f) {
var b = {};
var g = function (a) {
if(b[a]) {
f.clearInterval(b[a]);
b[a] = null;
};
};
e.fn.waitUntilExists = function (s, h, o, c) {
guard (
!argument.isEmpty,
nums.count == arguments.count
) else {
print("Blah blah")
}
import UIKit
public protocol ConstraintStateMachineType: class {
// MARK: Types
typealias State: RawRepresentable
// MARK: Properties
var state: State? { get set }
var allConstraints: [NSLayoutConstraint] { get }
@pcperini
pcperini / BlockChaining.swift
Created June 5, 2014 20:12
Chain blocks for asynchronous, callback-based execution. Always ends in main queue.
operator infix ~> { associativity right }
@infix func ~>(firstBlock: (() -> Void), secondBlock: (() -> Void)) -> (() -> Void) {
return {
dispatch_async(dispatch_get_global_queue(-32768, 0), {
firstBlock()
dispatch_async(dispatch_get_main_queue(), secondBlock)
})
}
}
def Enum(**kwargs):
values = kwargs
class EnumClass(type):
def __new__(cls, name, parents, dct):
# create a class_id if it's not specified
if 'class_id' not in dct:
dct['class_id'] = name.lower()
# we need to call type.__new__ to complete the initialization
new_type = super(EnumClass, cls).__new__(cls, name, parents, dct)
class ContainedViewController: UIViewController {
weak var dataDelegate: FrameViewControllerDataDelegate?
override func willMoveToParentViewController(parent: UIViewController?) {
super.willMoveToParentViewController(parent)
self.dataDelegate = parent as? FrameViewControllerDataDelegate
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
class ViewController: UIViewController, ConstraintStateMachineType {
typealias State = Alignment
enum Alignment: String {
case Left = "Left"
case Right = "Right"
}
override func viewDidLoad() {
super.viewDidLoad()
public extension ConstraintStateMachineType where Self: UIViewController {
// MARK: Properties
var allConstraints: [NSLayoutConstraint] {
return self.view.flatConstraints // helper function, recursively collects constraints
// https://gist.github.com/pcperini/5a8ea37e8cbbe904a031
}
// MARK: Mutators
func setNeedsUpdateConstraints() {
self.view.setNeedsUpdateConstraints()
public extension CollectionType {
// MARK: Flatteners
public func flatten(path: (Self.Generator.Element) -> [Self.Generator.Element]) -> [Self.Generator.Element] {
guard !self.isEmpty else { return [] }
return self + self.flatMap { path($0).flatten(path) }
}
}
public extension UIView {
// MARK: Properties