Skip to content

Instantly share code, notes, and snippets.

View sendoa's full-sized avatar

Sendoa Portuondo sendoa

View GitHub Profile
@sendoa
sendoa / .gitignore
Last active May 7, 2021 12:33
Sendoa's .gitignore for Laravel+PHPStorm projects
/node_modules
/public/storage
/storage/*.key
/vendor
Homestead.yaml
Homestead.json
.env
# ====== OS X ===========================================
.DS_Store
@sendoa
sendoa / .gitattributes
Last active January 29, 2019 18:41
Sendoa's .gitattributes for Xcode Projects
# Read http://robots.thoughtbot.com/xcode-and-git-bridging-the-gap for an explanation
# Read https://roadfiresoftware.com/2015/09/automatically-resolving-git-merge-conflicts-in-xcodes-project-pbxproj/ for more
*.pbxproj merge=union
*.strings text diff
@sendoa
sendoa / Playgrounds.swift
Created February 8, 2017 19:50 — forked from SpacyRicochet/Playgrounds.swift
Snippet of the Week: Lighter and Darker Colors
import UIKit
import PlaygroundSupport
public extension UIColor {
public func hsba() -> (hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat)? {
var hue: CGFloat = .nan, saturation: CGFloat = .nan, brightness: CGFloat = .nan, alpha: CGFloat = .nan
guard self.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) else {
return nil
}
return (hue: hue, saturation: saturation, brightness: brightness, alpha: alpha)

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

@sendoa
sendoa / update_xcode_plugins.sh
Created February 26, 2016 09:02 — forked from mokagio/update_xcode_plugins.sh
Script updating all plugins to be compatible with the latest Xcode and Xcode-beta
#!/bin/bash
#
# Updates all plug-ins to be compatible with the latest Xcode and Xcode-beta
#
plugins_location="~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins"
# Get Xcode's version
current_xcode_version="$(defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID)"
@sendoa
sendoa / measure.swift
Created February 22, 2016 11:55 — forked from MugunthKumar/measure.swift
Measures Time Taken for a closure to run
func measure(prefix: String = "Time Taken", closure:()->()) {
let a = CFAbsoluteTimeGetCurrent()
closure()
let b = CFAbsoluteTimeGetCurrent()
let m = ((b-a) * 1000.0)
print("\(prefix): \(m) ms")
}
sys_rb_usr=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr
sdk_rb_usr=`xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr
sudo cp -r $sdk_rb_usr/include $sys_rb_usr/include
@sendoa
sendoa / Dlog.h
Created July 9, 2013 20:33
NSLog and NSAssert substitution macros based on the ones from Marcus Zarra http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/ When the app runs on "Release" mode, assertions are linked to TestFlight checkpoints. I always name assertion type checkpoints with "ASSERTION" prefix. Example: Alog(@"ASSERTION_NON_PARSEABLE_ITEM_DATA_RECEIVED");
#ifdef DEBUG
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
#define DLog(...) do { } while (0)
#define ALog(...) [TestFlight passCheckpoint:[NSString stringWithFormat:__VA_ARGS__]]
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#endif
@sendoa
sendoa / SDWebImageDecoder.m
Created July 4, 2013 10:06
Force image decompression
// https://github.com/rs/SDWebImage
// https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F
#import "SDWebImageDecoder.h"
@implementation UIImage (ForceDecode)
+ (UIImage *)decodedImageWithImage:(UIImage *)image
{
CGImageRef imageRef = image.CGImage;