Skip to content

Instantly share code, notes, and snippets.

View leoniralves's full-sized avatar
:octocat:

Leonir Deolindo leoniralves

:octocat:
View GitHub Profile
@xNekOIx
xNekOIx / iOSAutoLayoutDebug
Last active July 7, 2020 17:45
iOS AutoLayout debug
po [[UIWindow keyWindow] _autolayoutTrace] // prints layouts ambiguity
po [UIViewController _printHierarchy] // prints view controllers hierarchy
po [view constraintsAffectingLayoutForAxis:0] // horizontal
po [view constraintsAffectingLayoutForAxis:1] // vertical
[view hasAmbiguousLayout] // BOOL
[view exerciseAmbiguityInLayout] // visualizing ambiguity
UIViewAlertForUnsatisfiableConstraints // symbolic breakpoint
UIConstraintBasedLayoutDebugging // symbolic breakpoint
@artemstepanenko
artemstepanenko / NSOperationQueue+Completion.h
Created November 23, 2013 21:57
This NSOperationQueue's category solves very simple task. Now you can add completion callback to NSOperationQueue instance.
//
// NSOperationQueue+Completion.h
// QueueTest
//
// Created by Artem Stepanenko on 23.11.13.
// Copyright (c) 2013 Artem Stepanenko. All rights reserved.
//
typedef void (^NSOperationQueueCompletion) (void);
@anunay
anunay / autoconf-phpize-xampp
Last active July 16, 2021 10:52
Installing AutoConf and Fixing Phpize on OSX 10.9
Installing AutoConf and Fixing Phpize on OSX 10.9
@JohnEstropia
JohnEstropia / JEProgressView.h
Last active October 5, 2023 14:59
Workaround an annoying bug with iOS 7.1 where custom track and progress images for UIProgressView gets ignored
//
// JEProgressView.h
//
//
// Created by John Rommel Estropia on 2014/03/11.
// Copyright (c) 2014 John Rommel Estropia.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@kharmabum
kharmabum / tappable-nav-bar.m
Last active July 20, 2016 15:17
Tappable title view UINavigationBar
#pragma mark - UIGestureRecognizerDelegate
// Toggle mode through touch gesture on navigation bar
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return (self.navigationController.visibleViewController == self &&
(ABS([touch locationInView:self.navigationController.navigationBar].x - self.navigationController.navigationBar.width/2) < 50));
}
- (void)viewWillAppear:(BOOL)animated {
@jonathantneal
jonathantneal / README.md
Last active March 19, 2024 23:31
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@StefanJager
StefanJager / UIColor+Components.swift
Last active June 16, 2022 08:52
A more SWIFT-friendly approach to getting components from an UIColor
//
// UIColor+Components.swift
//
// Copyright (c) 2015 Stefan Jager
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
@pejalo
pejalo / MemoryUsage.swift
Created February 23, 2018 19:06
Swift 4 iOS app memory usage
/// If an error occurs while getting the amount of memory used, the first returned value in the tuple will be 0.
func getMemoryUsedAndDeviceTotalInMegabytes() -> (Float, Float) {
// https://stackoverflow.com/questions/5887248/ios-app-maximum-memory-budget/19692719#19692719
// https://stackoverflow.com/questions/27556807/swift-pointer-problems-with-mach-task-basic-info/27559770#27559770
var used_megabytes: Float = 0
let total_bytes = Float(ProcessInfo.processInfo.physicalMemory)
@cprovatas
cprovatas / Data+PrettyPrint.swift
Created May 23, 2018 15:52
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@issuran
issuran / Using kdiff3
Created July 12, 2018 13:34
Changing mergetool tool to use kdiff3 on Mac
The list of supported tools
$ git mergetool --tool-help
Setting kdiff3 as mergetool tool
$ git config --global merge.tool kdiff3
In case you want to config diff.tool
$ git config --global diff.tool kdiff3
If kdiff3 is not in your PATH environment also do