Skip to content

Instantly share code, notes, and snippets.

View digoreis's full-sized avatar
🙃

Rodrigo Reis digoreis

🙃
  • Lisbon
View GitHub Profile
@digoreis
digoreis / test_es6.js
Last active August 29, 2015 13:59
Rodando Script Node com Harmony
#!/usr/bin/env node --use-strict --harmony
if ('function' === typeof Map) {
console.log("ES6 Console Sucess!");
} else {
throw new Error("ES6 is required; add --harmony");
}
@digoreis
digoreis / 0_reuse_code.js
Created October 14, 2015 17:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@digoreis
digoreis / carrier-swift
Created October 14, 2015 17:24
Implementação de Operadora em Swift
import CoreTelephony
var phoneInfo = CTTelephonyNetworkInfo()
var phoneCarrier = phoneInfo.subscriberCellularProvider
println(phoneCarrier)
@digoreis
digoreis / Queue.swift
Created January 8, 2016 11:47
This a Queue implementation by Luo Jie
protocol ExcutableQueue {
var queue: dispatch_queue_t { get }
}
extension ExcutableQueue {
func execute(closure: () -> Void) {
dispatch_async(queue, closure)
}
}
@digoreis
digoreis / HigherInteger.swift
Last active February 15, 2016 21:20
Example for Problem Siblings Integer
func generateHigherInteger(number:Int) -> Int {
let siblingsStr = String(number).characters.map { String($0) }
let bigSibling = siblingsStr.sort(>).reduce("", combine:+)
return Int(bigSibling) ?? number
}
@digoreis
digoreis / CURLSwift.swift
Last active May 15, 2018 20:45
test extension for curl - Update to Swift 3
//
// CURLDebug.swift
//
// Created by apple on 02/06/16.
// Copyright © 2016 Rodrigo Reis. All rights reserved.
//
import Foundation
@digoreis
digoreis / EnumExampleEither.swift
Last active August 1, 2016 01:31
Group Values with Enum
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
enum CellData<A, B, C> {
case Number(A)
case Name(B)
case Money(C)
@digoreis
digoreis / FlowTestRouter.swift
Created July 31, 2016 23:18
CreateRouteToTest
//Include this in AppDelegate
if let window = window where NSProcessInfo.processInfo().arguments.contains("UITestRun") {
FlowTestRouter.selectRoute(window, routes: NSProcessInfo.processInfo().arguments)
return true
}
import UIKit
class FlowTestRouter {
@digoreis
digoreis / repeatcurl.sh
Created January 10, 2017 20:17
Repeat curl with notification
until $(curl -v --header "SessionToken: 16676855" https://chat-esd-dev.appls.cmpn.paas.gsnetcloud.corp/chat/reasons/0001/permissions\?app\=00); do
osascript -e 'display notification "Não funcionou o serviço"'
printf 'Waiting 240 seconds ....................................... '
sleep 240
done
osascript -e 'display notification "Funcionou o serviço"'
@digoreis
digoreis / CircularQueue.swift
Created March 23, 2017 19:35
CircularQueue
class CircularQueue<T> : IteratorProtocol, RandomAccessCollection {
typealias Element = T
public typealias Index = Int
public typealias Indices = CountableRange<Int>
var position = 0
let items : [T]
init(items:[T]){
self.items = items