Skip to content

Instantly share code, notes, and snippets.

Carlos Umanzor cumanzor

  • Renovatio Cloud Solutions
  • Costa rica
Block or report user

Report or block cumanzor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cumanzor
cumanzor / alert.swift
Created Dec 5, 2018
[Show simple UIAlerts from any VC] #ios #swift
View alert.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)
alertController.addAction(defaultAction)
}
for action in actions{
@cumanzor
cumanzor / logAllocation.swift
Created Nov 16, 2018
[Manually chasing memory leaks] #swift
View logAllocation.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){
#if DEBUGALLOC
let file = ("\(filename)" as NSString).lastPathComponent as String
let objName = String(describing: type(of: caller))
@cumanzor
cumanzor / customError.swift
Created Dec 16, 2017
localizable error types
View customError.swift
// avoid the whole switch error type set description pattern we were using before (unless custom actions need to be attached or something)
// see: https://stackoverflow.com/questions/39176196/how-to-provide-a-localized-description-with-an-error-type-in-swift
import Foundation
public enum customError:Error{
case NONETWORK
case INVALIDJSON
case UNEXPECTEDRESPONSE
case INVALIDCREDENTIALS
@cumanzor
cumanzor / getfontfamily.txt
Last active Jun 13, 2019
get ios font family valid names #ios #lldb #debug
View getfontfamily.txt
In the lldb cli:
po [UIFont fontNamesForFamilyName:@"Avenir"]
<__NSArrayM 0x608000247ec0>(
Avenir-Oblique,
Avenir-HeavyOblique,
Avenir-Heavy,
Avenir-BlackOblique,
Avenir-BookOblique,
@cumanzor
cumanzor / UITableViewTransparentBg.swift
Last active Sep 28, 2018
UITableView transparent background #ios #swift #uikit
View UITableViewTransparentBg.swift
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
}
View steppedSlider.swift
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
}
View koranAddresses.js
/**
* Attempts to parse the string into a SK address.
* https://en.wikipedia.org/wiki/Addresses_in_South_Korea#Postal_Address
* https://en.wikipedia.org/wiki/ISO_3166-2:KR
* https://en.wikipedia.org/wiki/Administrative_divisions_of_South_Korea#Gun_.28County.29
* @returns An object of the form {province, city, street, zip}
*/
function parseAddress(string) {
var address = {};
address.extra = [];
You can’t perform that action at this time.