Skip to content

Instantly share code, notes, and snippets.

View josipbernat's full-sized avatar

Josip Bernat josipbernat

View GitHub Profile
@anubhavshrimal
anubhavshrimal / CountryCodes.json
Last active April 30, 2024 15:17 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
@dedeexe
dedeexe / CustomFocusView.swift
Created November 6, 2015 10:30
Creating a custom focus view for tvOS
//
// FocusView.swift
// CustomNavigation
//
// Creating a CustomFocusView
// This code shows how to implement a custom view that can be focused in tvOS
// Just set this class as an UIView's custom class
//
import UIKit
@soffes
soffes / UIColorExtension.swift
Created July 21, 2015 15:48 — forked from asarode/UIColorExtension.swift
Swift extension to get luma value of a UIColor
import UIKit
extension UIColor {
var luminance: CGFloat {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
getRed(&red, green: &green, blue: &blue, alpha: nil)
@ericdke
ericdke / resizeNSImage.swift
Last active March 3, 2023 13:47
Resize NSImage
func resize(image: NSImage, w: Int, h: Int) -> NSImage {
var destSize = NSMakeSize(CGFloat(w), CGFloat(h))
var newImage = NSImage(size: destSize)
newImage.lockFocus()
image.drawInRect(NSMakeRect(0, 0, destSize.width, destSize.height), fromRect: NSMakeRect(0, 0, image.size.width, image.size.height), operation: NSCompositingOperation.CompositeSourceOver, fraction: CGFloat(1))
newImage.unlockFocus()
newImage.size = destSize
return NSImage(data: newImage.TIFFRepresentation!)!
}
@dimitribouniol
dimitribouniol / UIGestureRecognizer+DBTrackingAdditions.h
Created June 15, 2011 06:06
Simple property to check if a UIGestureRecognizer is tracking (like UIControl).
#import <UIKit/UIKit.h>
@interface UIGestureRecognizer (DBTrackingAdditions)
@property (nonatomic, readonly, getter=isTracking) BOOL tracking;
@end