Skip to content

Instantly share code, notes, and snippets.

View yonat's full-sized avatar

Yonat Sharon yonat

View GitHub Profile
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
branches = for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads
[push]
@grosch
grosch / GSRegex.swift
Last active October 17, 2015 03:24
Implement regex in Swift, based off http://nshipster.com/swift-literal-convertible/
import Foundation
public protocol GSRegularExpressionMatchable {
func match(regex: GSRegex) -> Bool
func match(regex: NSRegularExpression) -> Bool
}
public class GSRegex: StringLiteralConvertible {
let regex: NSRegularExpression?
@mchambers
mchambers / serializer.swift
Created June 25, 2014 07:49
A simple, limited model-to-JSON serializer in Swift.
// Here we'll use Swift's IDE-supporting reflect()
// function to build a basic JSON serializer.
// Per the fine engineers at WWDC, Swift's reflection support
// exists purely to support the IDE and the Playground. But
// we can have some fun with it anyway. ;)
class SerializerBase {
}
@yonat
yonat / Save-iOS-image-name.md
Last active March 16, 2017 10:01
Set Image Name in iOS Camera Roll
@mattt
mattt / regex.swift
Created August 11, 2014 18:08
Creating a regular expression object from a String literal
class Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: nil, error: nil)
}
required init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern
#import <Foundation/Foundation.h>
#import <ifaddrs.h>
#import <net/if.h>
#import <SystemConfiguration/CaptiveNetwork.h>
@interface SMTWiFiStatus : NSObject
- (BOOL) isWiFiEnabled;
- (BOOL) isWiFiConnected;
@Inferis
Inferis / ViewController.swift
Last active December 1, 2019 23:27
Beginnings of a GCD wrapper in swift
import UIKit
import QuartzCore
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel
@IBOutlet weak var counter: UILabel
override func viewDidLoad() {
super.viewDidLoad()
@damienlaughton
damienlaughton / UIAccessorizedTextField.swift
Created March 28, 2018 15:16
UIAccessorizedTextField is an iOS friendly alternative to the drop down list
//
// UIAccessorizedTextField.swift
// AccessorizedTextField
//
// Created by Damien Laughton on 28/03/2018.
// 2018 Mobilology Limited. No rights reserved.
//
import Foundation
import UIKit
@shaildyp
shaildyp / UIView+roundCorners.swift
Last active December 7, 2022 12:14
Backward compatible maskedCorners of iOS 11.
extension UIView {
func roundCorners(_ corners: CACornerMask, radius: CGFloat) {
if #available(iOS 11, *) {
self.layer.cornerRadius = radius
self.layer.maskedCorners = corners
} else {
var cornerMask = UIRectCorner()
if(corners.contains(.layerMinXMinYCorner)){
cornerMask.insert(.topLeft)
@yonat
yonat / Badge.swift
Last active December 22, 2022 09:40
Rounded UILabel and UIButton, Badged UIBarButtonItem
//
// Badge.swift
// Extensions for Rounded UILabel and UIButton, Badged UIBarButtonItem.
//
// Usage:
// let label = UILabel(badgeText: "Rounded Label");
// let button = UIButton(type: .System); button.rounded = true
// let barButton = UIBarButtonItem(badge: "42", title: "How Many Roads", target: self, action: "answer")
//
// Created by Yonat Sharon on 06.04.2015.