Skip to content

Instantly share code, notes, and snippets.

View eMdOS's full-sized avatar

Emilio Ojeda eMdOS

  • Zapopan, Jalisco
View GitHub Profile
@eMdOS
eMdOS / APIError.swift
Last active February 15, 2017 18:05
API service routing using based on Alamofire
import Foundation
public enum APIError: Error {
case service(message: String)
}
extension APIError: CustomStringConvertible {
public var description: String {
switch self {
case .service(let message):
@eMdOS
eMdOS / regex.txt
Created March 8, 2017 06:03 — forked from nerdsrescueme/regex.txt
Common Regex
Perl and PHP Regular Expressions
PHP regexes are based on the PCRE (Perl-Compatible Regular Expressions), so any regexp that works for one should be compatible with the other or any other language that makes use of the PCRE format. Here are some commonly needed regular expressions for both PHP and Perl. Each regex will be in string format and will include delimiters.
All Major Credit Cards
This regular expression will validate all major credit cards: American Express (Amex), Discover, Mastercard, and Visa.
//All major credit cards regex
'/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/'
@eMdOS
eMdOS / Regex.swift
Last active March 15, 2017 00:53
Regex
public enum Regex: String {
case email = "^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"
}
extension Regex: RegexProvider {
public var regex: String {
return rawValue
}
static func validate(expression: String, forRegex regex: Regex) -> Bool {
@eMdOS
eMdOS / SSH.md
Last active July 17, 2017 22:38
SSH set up

SSH Keys

Generating a new SSH key

  1. Create a ssh key:

    ssh-keygen -t rsa -b 4096 -C "<email>"
@eMdOS
eMdOS / Playground.md
Created July 18, 2017 16:36
Playground (async execution)

Playground

Async execution

  • At the imports section:

     import PlaygroundSupport
@eMdOS
eMdOS / macOS.md
Created July 18, 2017 16:50
macOS : Change where screenshots save

macOS

Change where screenshots save

  1. Creating a folder for screenshots (~/Pictures/Screenshots/):

    mkdir ~/Pictures/Screenshots/
@echo off
title Flash Memory
color 1E
@echo ----------------------------------------------
@echo ------------- Memory Flash Fixer -------------
@echo ----------------------------------------------
@echo Changing Folder Attributes...
Attrib /d /s -r -h -s *.*
@echo ----------------------------------------------
@echo Deleting Links
@eMdOS
eMdOS / RecordAudio.swift
Created August 3, 2017 21:22 — forked from hotpaw2/RecordAudio.swift
Swift 3.0 Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift 3.0 class
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16. Updated 2017Feb07
// Copyright © 2017 HotPaw Productions. All rights reserved.
@eMdOS
eMdOS / UIKit.UIStoryboard.swift
Last active August 15, 2017 18:45
Safe View Controller instances from Storyboards
@available(iOS 5.0, *)
open class UIStoryboard : NSObject {
public /*not inherited*/ init(name: String, bundle storyboardBundleOrNil: Bundle?)
open func instantiateInitialViewController() -> UIViewController?
open func instantiateViewController(withIdentifier identifier: String) -> UIViewController
}
@eMdOS
eMdOS / carthage.sh
Last active September 27, 2017 21:58
Carthage: update | bootstrap ... from bash
#!/bin/bash
update="update"
bootstrap="bootstrap"
expectation_message="EXPECTED: [ $update | $bootstrap ]"
if [ $# -eq 0 ]; then
echo "ERROR: No argument supplied."
echo $expectation_message