Skip to content

Instantly share code, notes, and snippets.

@vixvix
vixvix / UIAlertController+TextField.swift
Created August 31, 2018 15:14 — forked from ole/UIAlertController+TextField.swift
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@vixvix
vixvix / Timer.swift
Created August 7, 2018 20:33 — forked from jstn/Timer.swift
simple nanosecond timer using mach_absolute_time
/*
var t = Timer()
t.start()
// do something
t.stop()
print("took \(t.seconds)")
*/
@vixvix
vixvix / gist:9a5b19213689df2a5786
Created October 17, 2014 20:08
How to create a Menubar application for Mac
http://stackoverflow.com/questions/3409985/how-to-create-a-menubar-application-for-mac
https://github.com/shpakovski/Popup
http://blog.shpakovski.com/2011/07/cocoa-popup-window-in-status-bar.html
http://cocoatutorial.grapewave.com/2010/01/creating-a-status-bar-application/
@vixvix
vixvix / gist:2f7b5ed617014749ae76
Created October 7, 2014 18:31
P12 Inspection
http://magnus-k-karlsson.blogspot.ca/2010/02/how-to-see-expiration-date-and-other.html
openssl pkcs12 -in maka.p12 -info
-----BEGIN CERTIFICATE-----
The content to copy...
-----END CERTIFICATE-----
openssl x509 -in <your_file.crt> -inform PEM -text
@vixvix
vixvix / gist:72ae1a89a9e34c519158
Created September 13, 2014 03:44
OSX hide/show user from login window
Hide:
sudo chpass -s /usr/bin/false username
Show:
sudo chpass -s /bin/bash username
@vixvix
vixvix / gist:88655388e78881f29ea6
Created August 26, 2014 20:06
Bypassing “clang: error: unknown argument : '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]"
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install django-toolbelt
@vixvix
vixvix / gist:21a5ecad0fd3970d896f
Created April 30, 2014 19:50
RESTful authentication
GET /session/new gets the webpage that has the login form
POST /session authenticates credentials against database
DELETE /session destroys session and redirect to /
GET /users/new gets the webpage that has the registration form
POST /users records the entered information into database as a new /user/xxx
GET /users/xxx // gets and renders current user data in a profile view
POST /users/xxx // updates new information about user
http://stackoverflow.com/questions/7140074/restfully-design-login-or-register-resources
@vixvix
vixvix / gist:8794985
Created February 4, 2014 00:00
Xcode 4 .xib Create iPad Version
Make a copy of the .xib in the Finder.
Open the copied file in a text editor.
Change "com.apple.InterfaceBuilder3.CocoaTouch.XIB" to "com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB".
Change all instances of "IBCocoaTouchFramework" to "IBIPadFramework".
Search for sizes like {480, 320} and edit them. Or just reopen the file in Xcode and use the GUI to resize items as needed.
http://stackoverflow.com/questions/5347198/xcode-4-xib-create-ipad-version
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@vixvix
vixvix / gist:8567432
Created January 22, 2014 21:13
diable/enable osx dashboard
disabled:
defaults write com.apple.dashboard mcx-disabled -boolean YES && killall Dock
enabled:
defaults write com.apple.dashboard mcx-disabled -boolean NO && killall Dock
http://apple.stackexchange.com/questions/91722/can-i-disable-dashboard-in-mountain-lion