Skip to content

Instantly share code, notes, and snippets.

View damianesteban's full-sized avatar
🎯
Focusing

Damian Esteban damianesteban

🎯
Focusing
View GitHub Profile
@damianesteban
damianesteban / git_standards.md
Created September 28, 2016 18:20
git commit and branch naming

Git Branch Naming

Type

Must be one of the following:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
@damianesteban
damianesteban / result.swift
Last active November 13, 2016 19:00
Swift 3 updated code with simple examples from this fantastic article: http://alisoftware.github.io/swift/async/error/2016/02/06/async-errors/
// A Gist.
struct Gist {
let id: String
}
typealias JSONDictionary = [String: AnyObject]
// These methods are "helpers" to transform Data -> JSON -> Result<[Gist]>
func jsonFrom(data: Data) -> Result<AnyObject> {
let json = try! JSONSerialization.jsonObject(with: data, options: [])

emacs --daemon to run in the background. emacsclient.emacs24 <filename/dirname> to open in terminal

NOTE: "M-m and SPC can be used interchangeably".

  • Undo - C-/
  • Redo - C-?
  • Change case: 1. Camel Case : M-c 2. Upper Case : M-u
  1. Lower Case : M-l
@damianesteban
damianesteban / List.swift
Created August 21, 2016 02:04 — forked from kristopherjohnson/List.swift
Functional list type for Swift
import Foundation
/// Abstract functional list type
///
/// Concrete types are EmptyList<T> and Cons<T>
public class List<T>: SequenceType {
/// Return true if this is an empty list, false if not
public var isEmpty: Bool { return true }
@damianesteban
damianesteban / simpleLens.swift
Last active April 23, 2017 18:19
Example of a simple lens in Swift 3
// Concepts based on an excellent article by Maciej Konieczny.
// http://narf.pl/posts/lenses-in-swift
struct ComicBook {
let title: String
let issueNumber: Int
let publisher: Publisher
}
struct Publisher {
@damianesteban
damianesteban / escrowJob.js
Created June 18, 2016 15:48
Braintree Release from Escrow after 48 hours
// new Date Object.
const today = new Date();
// releases a transaction from escrow via the transaction id.
function releaseFromEscrow(transactionId) {
gateway.transaction.releaseFromEscrow(transactionId, (err, result) => {
if (err) {
console.log(`Error releasing transaction - ${err}`);
}
console.log(`Transaction released - ${result}`);
@damianesteban
damianesteban / UIImage+Tinting.swift
Created February 9, 2016 22:11 — forked from iamjason/UIImage+Tinting.swift
Swift UIImage extension for tinting images
/**
Usage:
let originalImage = UIImage(named: "cat")
let tintedImage = originalImage.tintWithColor(UIColor(red: 0.9, green: 0.7, blue: 0.4, alpha: 1.0))
*/
extension UIImage {
func tintWithColor(color:UIColor)->UIImage {
//: [Previous](@previous)
import UIKit
import Behavior
import XCPlayground
//: ## Task: Create a small counter application
//: This approach uses ports and behaviors
struct Counter {
let views = ["v1": v1, "super": self.view]
self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:[super]-(<=0)-[v1(50)]", options: .AlignAllCenterY, metrics: nil, views: views))
self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:[super]-(<=0)-[v1(100)]", options: .AlignAllCenterX, metrics: nil, views: views))