Skip to content

Instantly share code, notes, and snippets.

View micheltlutz's full-sized avatar
🎧

Michel Anderson Lütz Teixeira micheltlutz

🎧
View GitHub Profile
package com.example.alarmmanager;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
@micheltlutz
micheltlutz / Rename.go
Last active March 28, 2018 12:20
Renomear arquivos removendo acento e espaço - GO
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"unicode"
"golang.org/x/text/transform"
@danielCarlosCE
danielCarlosCE / ChainResponsibility.playground.swift
Created October 13, 2017 17:42
Chain of Responsibility to handle errors on iOS application
import UIKit
class AppDelegate {
var window: UIWindow?
}
//Chain of Resposability: Handler
protocol ErrorHandler {
var errorHandlerSuccessor: ErrorHandler? {get}
func handleError(error: Error)
@fpillet
fpillet / Results+Rx.swift
Created February 13, 2016 17:23
turn Realm auto-updating Results into an RxSwift Observable sequence
//
// Results+Rx.swift
//
// Make Realm auto-updating Results observable. Works with Realm 0.98 and later, RxSwift 2.1.0 and later.
//
// Created by Florent Pillet on 12/02/16.
// Copyright (c) 2016 Florent Pillet. All rights reserved.
//
import Foundation
@natecook1000
natecook1000 / SimplePickerView.swift
Created January 6, 2015 21:48
Simple UIPickerView subclass
class SimplePickerView : UIPickerView {
class SimplePickerViewModel : NSObject, UIPickerViewDelegate, UIPickerViewDataSource {
var titles: [String]
var selectionHandler: ((pickerView: UIPickerView, row: Int, title: String) -> ())?
init(titles: [String], selectionHandler: ((pickerView: UIPickerView, row: Int, title: String) -> ())? = nil) {
self.titles = titles
self.selectionHandler = selectionHandler
}
@diefferson
diefferson / RemoveAcentos.php
Last active August 6, 2019 19:50
Função Para substituir caracteres com acentos por caracteres comuns
<?php
function removerAcentos( $string ) {
$mapaAcentosHex = array(
'a'=> '/[\xE0-\xE6]/',
'A'=> '/[\xE0-\xE6]/',
'e'=> '/[\xE8-\xEB]/',
'E'=> '/[\xE8-\xEB]/',
'i'=> '/[\xEC-\xEF]/',
@rockbruno
rockbruno / buck_targets_to_test.swift
Last active October 14, 2019 23:50
Buck: Script to find out which rules should be tested based on what was changed
import Foundation
func run(command: String, wait: Bool = true) -> String? {
let task = Process()
task.launchPath = "/bin/bash"
task.arguments = ["-c", command]
let pipe = Pipe()
task.standardOutput = pipe
task.launch()
guard wait else {
@gazolla
gazolla / stack.swift
Created June 20, 2016 01:00
Programmatically create UIStackView
lazy var v1:UIView = {
let v = UIView()
v.backgroundColor = .blueColor()
return v
}()
lazy var v2:UIView = {
let v = UIView()
v.backgroundColor = .blueColor()
return v
@PEZ
PEZ / UIControl+ListenBlock.swift
Created September 20, 2017 23:04
Swift3 UIControl extension for adding block event listeners. Adapted from: https://stackoverflow.com/a/44917661/44639
import Foundation
import UIKit
extension UIControl {
func listen(_ action: @escaping () -> (), for controlEvents: UIControlEvents) -> AnyObject {
let sleeve = ClosureSleeve(attachTo: self, closure: action, controlEvents: controlEvents)
addTarget(sleeve, action: #selector(ClosureSleeve.invoke), for: controlEvents)
return sleeve
}