Skip to content

Instantly share code, notes, and snippets.

View pcperini's full-sized avatar

Patrick Perini pcperini

View GitHub Profile
$('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")
}
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
public protocol ConstraintStateMachineType: class {
// MARK: Types
typealias State: RawRepresentable
// MARK: Properties
var state: State? { get set }
var allConstraints: [NSLayoutConstraint] { get }
// MARK: Mutators
func setNeedsUpdateConstraints()
@IBDesignable
public class StatefulConstraint: NSLayoutConstraint {
// MARK: Properties
@IBInspectable var state: String = ""
}