Skip to content

Instantly share code, notes, and snippets.

View ajaysinghthakur's full-sized avatar
🏠
Working from home

ajay singh thakur ajaysinghthakur

🏠
Working from home
View GitHub Profile
@gdavis
gdavis / gist:2845766
Created May 31, 2012 19:46
iOS Phone Number Field Formatting With User Entry
#pragma mark - Phone Number Field Formatting
// Adopted from: http://stackoverflow.com/questions/6052966/phone-number-formatting
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (textField == self.mobileNumberField || textField == self.homeNumberField || textField == self.workNumberField) {
int length = [self getLength:textField.text];
if(length == 10) {
if(range.length == 0)
#!/usr/bin/env xcrun swift
import Foundation
let kDelayUSec : useconds_t = 500_000
func DragMouse(from p0: CGPoint, to p1: CGPoint) {
let mouseDown = CGEventCreateMouseEvent(nil, .LeftMouseDown, p0, .Left)
let mouseDrag = CGEventCreateMouseEvent(nil, .LeftMouseDragged, p1, .Left)
let mouseUp = CGEventCreateMouseEvent(nil, .LeftMouseUp, p1, .Left)
@JohnSundell
JohnSundell / AnyOf.swift
Created August 21, 2017 21:23
A way to easily compare a given value against an array of candidates
import Foundation
struct EquatableValueSequence<T: Equatable> {
static func ==(lhs: EquatableValueSequence<T>, rhs: T) -> Bool {
return lhs.values.contains(rhs)
}
static func ==(lhs: T, rhs: EquatableValueSequence<T>) -> Bool {
return rhs == lhs
}