Skip to content

Instantly share code, notes, and snippets.

View PMUNOZ08's full-sized avatar

Pedro Muñoz Cabrera PMUNOZ08

View GitHub Profile
@PMUNOZ08
PMUNOZ08 / current_selected_installed_xcode.md
Created February 27, 2025 06:39 — forked from dive/current_selected_installed_xcode.md
How to get the current selected Xcode and list installed

How to get the current selected Xcode and list installed

Current Selected Xcode

xcode-select

This is the most common way to get the path to the selected instance:

xcrun xcode-select --print-path
@PMUNOZ08
PMUNOZ08 / NSDate+Utilities.h
Last active March 1, 2019 23:07
NSDate category to make easy to work with date components
//
// NSDate+Utilities.h
//
// Created by PEDRO MUÑOZ CABRERA on 15/03/13.
// Copyright (c) 2013. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSDate (Utilities)
@PMUNOZ08
PMUNOZ08 / gist:4960995
Last active December 13, 2015 19:09
Given an UIImage return a new UIImage with the colors inverted
- (UIImage *)negativeImage:(UIImage *)img
{
// get width and height as integers, since we'll be using them as
// array subscripts, etc, and this'll save a whole lot of casting
CGImageRef imageRef = [img CGImage];
int widthI = CGImageGetWidth(imageRef);
int heightI = CGImageGetHeight(imageRef);
// Create a suitable RGB+alpha bitmap context in BGRA colour space
@PMUNOZ08
PMUNOZ08 / gist:4960985
Last active December 13, 2015 19:09
Given an UIImage return a new UIImage with the colors in gray scale
- (UIImage *)convertToGrayscale:(UIImage*)img {
CGImageRef imageRef = [img CGImage];
int widthI = CGImageGetWidth(imageRef);
int heightI = CGImageGetHeight(imageRef);
// the pixels will be painted to this array
uint32_t *pixels = (uint32_t *) malloc(widthI * heightI * sizeof(uint32_t));
// clear the pixels so any transparency is preserved
#import <Foundation/Foundation.h>
@interface NSObject (NSDictionaryRepresentation)
/**
Returns an NSDictionary containing the properties of an object that are not nil.
*/
- (NSDictionary *)dictionaryRepresentation;
@end