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 / gist:bee58e7e9894b92a42e9
Created June 23, 2015 11:02
Converting String to Float and Double
import Foundation
extension String {
func toFloat() -> Float
{
return (self as NSString).floatValue
}
func toDouble() -> Double
@dedeexe
dedeexe / temperaturas.swift
Last active September 10, 2015 04:04
Kelvin / Celcius / Fahrenheit
//
//temperaturas.swift
//Autor....: dede.exe
//E-mail...: dede.exe@gmail.com
//Descrição: Convertendo temperaturas em Swift
//
class Medida
{
var valor : Float = 0.0
@dedeexe
dedeexe / format_converter.sh
Last active October 21, 2015 12:18
Converting files to UTF-8 example
#!/bin/bash
#conversor.sh
#Author.....: dede.exe
#E-mail.....: dede.exe@gmail.com
#Description: Convert all files to a another format
# It's not a safe way to do it...
# Just a desperate script to save my life...
# Use it such a last resort...
to_format="utf8"
@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
@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 / 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 / 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 / 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 / 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