Skip to content

Instantly share code, notes, and snippets.

View dedeexe's full-sized avatar

dede.exe dedeexe

  • PuraMagia Labs
  • Brazil
View GitHub Profile
@dedeexe
dedeexe / URLRequest+curlCommand.swift
Last active April 17, 2020 13:08
Convert URL Request to curl command
extension URLRequest {
public func curl(pretty:Bool = false) -> String {
var data : String = ""
let complement = pretty ? "\\\n" : ""
let method = "-X \(self.httpMethod ?? "GET") \(complement)"
let url = "\"" + self.url?.absoluteString ?? "" + "\""
var header = ""
@dedeexe
dedeexe / trap.swift
Created November 3, 2016 08:02 — forked from sharplet/trap.swift
Simple signal handling in Swift
import Darwin
enum Signal: Int32 {
case HUP = 1
case INT = 2
case QUIT = 3
case ABRT = 6
case KILL = 9
case ALRM = 14
case TERM = 15
@dedeexe
dedeexe / UIColor+Literals.swift
Last active October 20, 2016 19:50
UIColor extension for literal numbers
//
// UIColor+Literals.swift
// Created by dede.exe
//
import UIKit
public extension UIColor {
public convenience init(red:Int, green:Int, blue:Int, percentAlpha:Int = 100)
{
@dedeexe
dedeexe / UITextField+MaskPattern.swift
Last active November 16, 2018 21:14
Adding Mask to a TextField
//
// UITextField+MaskPattern.swift
// MaskedTextField
//
// Created by dede.exe on 10/07/16.
//
// It's totally base on article : "http://vojtastavik.com/2015/03/29/real-time-formatting-in-uitextfield-swift-basics/"
// And I don't mind if the original author allow me to publish it :)... But I'll keep the reference
// I modified the original implementation to keep it as an Extension...
//
@dedeexe
dedeexe / FloatingView.swift
Last active September 20, 2016 04:52
Creating a kind of toast
import UIKit
extension UIView {
private struct FloatingKeys {
static var FKCompletion : String = "FKCompletion"
}
private class CompletionWrapper {
private var completion : (()->Void)? = nil
import UIKit
public class ResearchButton : UIButton {
private var markView : UIView!
private var circlePath : UIBezierPath!
private var circleLayer : CAShapeLayer!
public var borderWeight : CGFloat = 2
@dedeexe
dedeexe / StringMaskFormatter.swift
Last active July 12, 2019 11:34
Simples And Fast String Mask Formatter.
//
// StringMaskFormatter.swift
// StringMaskFormatter
//
// Created by dede.exe on 10/07/16.
// It's totally base on article : "http://vojtastavik.com/2015/03/29/real-time-formatting-in-uitextfield-swift-basics/"
// And I don't mind if the original author should allow me(or not) to publish it :)... But I'll keep the reference
//
import UIKit
@dedeexe
dedeexe / gist:23a5365ddec90974d050
Created March 5, 2016 03:28 — forked from oliland/gist:5416438
An example of using CIFilters to mess with UIViews on iOS.
- (void)viewDidLoad
{
[super viewDidLoad];
// Great tutorial: http://www.raywenderlich.com/22167/beginning-core-image-in-ios-6
// Official docs: https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185-CH1-TPXREF101
// Alt-click on function names for more!
// Make any old label, with our frame set to the view so we know it's there.
UILabel *label = [[UILabel alloc] initWithFrame:self.view.frame];
@dedeexe
dedeexe / DicionaryJoinString.swift
Created November 27, 2015 17:26
Convert a dictionary to string joining each key/value for a keyValueToken and mark each group by another token
extension Dictionary {
func joinKeyValuesFor(keyValueToken : String, groupedByToken:String ) -> String
{
var str = ""
for (key, value) in self
{
if str != ""
{
@dedeexe
dedeexe / StringBase64.swift
Last active November 25, 2015 17:33
Convert String to base64 String
extension String {
var base64 : String?
{
if let convertedData = self.dataUsingEncoding(NSUTF8StringEncoding)
{
let convertedDataBase64 = convertedData.base64EncodedDataWithOptions(NSDataBase64EncodingOptions(rawValue: 0))
let stringBase64 = String(data: convertedDataBase64, encoding: NSUTF8StringEncoding)
return stringBase64