Skip to content

Instantly share code, notes, and snippets.

//
// RBResizer.swift
// Locker
//
// Created by Hampton Catlin on 6/20/14.
// Copyright (c) 2014 rarebit. All rights reserved.
//
import UIKit
import Foundation
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
import Foundation
extension NSString {
/**
http://stackoverflow.com/questions/800123/what-are-best-practices-for-validating-email-addresses-in-objective-c-for-ios-2
RFC 2822 http://tools.ietf.org/html/rfc2822
*/
func isEmail() -> Bool {
let sRegex = "(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"
@sumate-sdk
sumate-sdk / CGContextExt.swift
Last active August 29, 2015 14:27 — forked from venkatperi/CGContextExt.swift
CGContext Syntactic Sugar
// CGContextABCD(context!, ...) becomes context?.ABCD(...)
import Cocoa
extension CGContext {
func saveGState() { CGContextSaveGState(self) }
func restoreGState() { CGContextRestoreGState(self) }
func scaleCTM( sx: CGFloat, sy: CGFloat) { CGContextScaleCTM(self, sx, sy) }
func translateCTM( tx: CGFloat, ty: CGFloat) { CGContextTranslateCTM(self, tx, ty) }
func rotateCTM( angle: CGFloat) { CGContextRotateCTM(self, angle) }
@sumate-sdk
sumate-sdk / chacha20
Created February 17, 2016 13:09
ChaCha20 stream cipher in Python 3
# Pure Python ChaCha20
# Based on Numpy implementation: https://gist.github.com/chiiph/6855750
# Based on http://cr.yp.to/chacha.html
#
# I wanted an implementation of ChaCha in clean, understandable Python
# as a way to get a handle on the algorithm for porting to another language.
# There are plenty of bindings but few pure implementations, because
# Pure Python is too slow for normal practical use in Cryptography.
#
# The preceding implementation used NumPy, which avoided a lot of the
@sumate-sdk
sumate-sdk / Anchor.swift
Created July 9, 2016 06:37
NSLayoutAnchor for 10.10/iOS8
//
// Anchor.swift
// AnchorTest
//
// Created by Jonathan Wight on 7/10/15.
// Copyright © 2015 schwa.io. All rights reserved.
//
#if os(OSX)
import AppKit
//
// UIResponder.swift
//
// Created by Groom on 23/03/2015.
// Copyright (c) 2015 Stephen Groom. All rights reserved.
//
import UIKit
extension UIResponder {
@sumate-sdk
sumate-sdk / main.dart
Created May 11, 2022 09:46
Rounded any acute corner
import 'dart:ui';
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {