Skip to content

Instantly share code, notes, and snippets.

View cumanzor's full-sized avatar

Carlos Umanzor cumanzor

  •, Inc.
  • Costa rica
View GitHub Profile
cumanzor / MakeMediumReadadableUserscript.user.js
Last active March 22, 2020 19:21 — forked from luke3butler/MakeMediumReadadableUserscript.user.js
Userscript version of the MMRA (Make Medium Readable Again) Chrome extension
// ==UserScript==
// @name Make Medium Readable Userscript
// @namespace http://make.medium.readable.again
// @version 0.1
// @description
// @author luke3butler (Credits to Matt Baer)
// @match *://*/*
// @grant none
// ==/UserScript==
cumanzor / alert.swift
Created December 5, 2018 07:11
[Show simple UIAlerts from any VC] #ios #swift
extension UIViewController {
func showAlert(withTitle title: String, message : String, withActions actions:[UIAlertAction] = [], withCompletion c:(()->())?=nil) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
if actions.isEmpty{ // default ok action
let defaultAction = UIAlertAction(title: "Ok", style: .default)
for action in actions{
cumanzor / logAllocation.swift
Created November 16, 2018 06:35
[Manually chasing memory leaks] #swift
// can be made dry by adding a alloc/dealloc parameter
// add the DEBUGALLOC flag to Active Compilation Conditions -> Debug and use it only when necessary.
// note that you should be using Instruments for this, but this helps to catch issues in real time when running the app, and I gnenerally don't recommend following this approach for several reasons.
func LogDealloc<T>(from caller:T, filename: String = #file, line: Int = #line, funcname: String = #function){
let file = ("\(filename)" as NSString).lastPathComponent as String
let objName = String(describing: type(of: caller))
cumanzor / customError.swift
Created December 16, 2017 21:34
localizable error types
// avoid the whole switch error type set description pattern we were using before (unless custom actions need to be attached or something)
// see:
import Foundation
public enum customError:Error{
cumanzor / getfontfamily.txt
Last active June 13, 2019 20:45
get ios font family valid names #ios #lldb #debug
In the lldb cli:
po [UIFont fontNamesForFamilyName:@"Avenir"]
<__NSArrayM 0x608000247ec0>(
cumanzor / UITableViewTransparentBg.swift
Last active September 28, 2018 22:59
UITableView transparent background #ios #swift #uikit
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath)
cell.backgroundColor = .clear
cell.backgroundView = UIView()
cell.selectedBackgroundView = UIView()
return cell
cumanzor / steppedSlider.swift
Created June 6, 2016 03:01
stepped UISlider.
let step: Float = 50;
// extra slider initialization. the IBAction func below points to the UISlider we are using.
@IBAction func onStrengthChange(sender: UISlider) {
let roundedValue = round(sender.value/step) * step
sender.value = roundedValue
* Attempts to parse the string into a SK address.
* @returns An object of the form {province, city, street, zip}
function parseAddress(string) {
var address = {};
address.extra = [];