Skip to content

Instantly share code, notes, and snippets.

View loucimj's full-sized avatar

Javier Loucim loucimj

  • Vicente López, Buenos Aires, Argentina.
View GitHub Profile
@loucimj
loucimj / DebugPrint.swift
Created October 23, 2016 00:04
Friendlier and safer print for debug console
//
// DebugPrint.swift
//
// Created by Javier Loucim on 10/22/16.
// Copyright © 2016 Javier Loucim. All rights reserved.
//
import Foundation
func print(_ message:String , separator: String = " ", terminator: String = "\n", functionName: String = #function, fileName: String = #file, lineNumber: Int = #line) {
@loucimj
loucimj / NSExtensionAttributes for image
Last active July 14, 2017 23:20
Description of gist
content <key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
@loucimj
loucimj / regex.playground
Last active July 26, 2017 12:04
search for mention with dots in the middle
content//: Playground - noun: a place where people can play
import UIKit
import Foundation
var str = "Hello, @playground.something more"
//(?<=\\s|^|\\b)(?:[-'.%$#&/]\\b|\\b[-'.%$#&/]|[A-Za-z0-9]|\\([A-Za-z0-9]+\\))+(?=\\s|$|\\b)
let range = NSMakeRange(0, str.characters.count)
var regex = try! NSRegularExpression(pattern: "@(?<=\\s|^|\\b)(?:[-'.%$#&/]\\b|\\b[-'.%$#&/]|[A-Za-z0-9]|\\([A-Za-z0-9]+\\))+(?=\\s|$|\\b)", options: .caseInsensitive)
import Unbox
import Foundation
extension Unboxable {
func safeUnbox(unboxer: Unboxer,key :String )->String{
do{
return try unboxer.unbox(key: key) as String
}catch{
return ""
import Foundation
import UIKit
extension String {
//MARK: - Localized
var localized: String {
return NSLocalizedString(self, tableName: "Main", bundle: Bundle.main, value: "", comment: "")
@loucimj
loucimj / Diffable.swift
Last active April 12, 2018 16:38
Diffable workaround for structs with IGListKit
//
// Diffable.swift
//
// Created by danielgalasko on 8/5/17.
//
import Foundation
import IGListKit
@loucimj
loucimj / SectionController.swift
Created August 7, 2017 15:09
SectionController using DiffableBox
//
// TicketSectionController.swift
//
// Created by Javier Loucim on 8/5/17.
// Copyright © 2017 Javier Loucim. All rights reserved.
//
import Foundation
import UIKit
import IGListKit
@loucimj
loucimj / MessagesViewController.swift
Created August 7, 2017 15:11
Using DiffableBox with ListAdapterDataSource
extension MessagesViewController: ListAdapterDataSource {
func objects(for listAdapter: ListAdapter) -> [ListDiffable] {
var objects:Array<ListDiffable> = Array<ListDiffable>()
for item in data {
switch item {
case is String:
objects.append(item as! ListDiffable)
case is TicketShort:
objects.append((item as! TicketShort).diffable())
@loucimj
loucimj / TicketShort+Diffable.swift
Created August 7, 2017 15:12
Customizing structs to use Diffable
extension TicketShort: Diffable {
var diffIdentifier: String {
return id
}
static func ==(lhs: TicketShort, rhs: TicketShort) -> Bool {
return lhs.id == rhs.id
}
@loucimj
loucimj / UIView+GlowBackground.swift
Created September 9, 2017 03:14
UIView+GlowBackground.swift
//
// UIView+GlowBackground.swift
// GlowBackgroundView
//
// Created by Javier Loucim on 9/8/17.
// Copyright © 2017 Qeeptouch. All rights reserved.
//
import Foundation
import UIKit