Skip to content

Instantly share code, notes, and snippets.

View sendoa's full-sized avatar

Sendoa Portuondo sendoa

View GitHub Profile
@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")
}
@sendoa
sendoa / ios7statusbar.md
Last active August 29, 2015 14:25 — forked from hujunfeng/ios7statusbar.md
About iOS 7 Status Bar Style

UIStatusBarStyle in iOS 7

  • The status bar in iOS 7 is transparent, the view behind it shows through.

  • The style of the status bar refers to the appearances of its content. In iOS 7, the status bar content is either dark (UIStatusBarStyleDefault) or light (UIStatusBarStyleLightContent). Both UIStatusBarStyleBlackTranslucent and UIStatusBarStyleBlackOpaque are deprecated in iOS 7.0. Use UIStatusBarStyleLightContent instead.

How to change UIStatusBarStyle

  • If below the status bar is a navigation bar, the status bar style will be adjusted to match the navigation bar style (UINavigationBar.barStyle):
//
// BinaryDataScanner.m
//
// Copyright 2009 Dave Peck <davepeck [at] davepeck [dot] org>. All rights reserved.
// http://davepeck.org/
//
// This class makes it quite a bit easier to read sequential binary files in Objective-C.
//
// This code is released under the BSD license. If you use it in your product, please
// let me know and, if possible, please put me in your credits.
@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
#import <Foundation/Foundation.h>
// typedef
typedef NSString*(^ConvertBlock)(NSString *text);
@interface Thing : NSObject
@property (nonatomic, strong) void (^coolPropertyBlock)(NSString *text); // Property
// method param
- (void)doSomething:(void(^)(NSString *text))block with:(NSString *)person;
@sendoa
sendoa / gist:19c4453ee76c37527771
Created May 8, 2014 14:36 — forked from odrobnik/gist:2106f26379fd609d4ed3
Hide status bar & navigation bar together
- (IBAction)handleTap:(id)sender
{
BOOL isHiding = !_statusBarHidden;
_statusBarHidden = isHiding;
[UIView animateWithDuration:UINavigationControllerHideShowBarDuration delay:0 options:0
animations:^{
[self setNeedsStatusBarAppearanceUpdate];
}
completion:NULL];