Skip to content

Instantly share code, notes, and snippets.

View oddmagne's full-sized avatar

Odd Magne Hågensen oddmagne

View GitHub Profile
@Jaybles
Jaybles / UIDeviceHardware.h
Created October 28, 2011 19:33
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@bignerdranch
bignerdranch / BNRTimeBlock.h
Created March 9, 2012 13:51
Timing Utility Post 20120308
CGFloat BNRTimeBlock (void (^block)(void));
// UIImage+Alpha.h
// Created by Trevor Harmon on 9/20/09.
// Free for personal or commercial use, with or without modification.
// No warranty is expressed or implied.
// Helper methods for adding an alpha layer to an image
@interface UIImage (Alpha)
- (BOOL)hasAlpha;
- (UIImage *)imageWithAlpha;
- (UIImage *)transparentBorderImage:(NSUInteger)borderSize;
@skeeet
skeeet / xcode_ramdisk.sh
Created April 12, 2012 13:35 — forked from MaximKeegan/xcode_ramdisk.sh
Create a RAM disk for using with XCode
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
SYS_CACHES_DIR="/Library/Caches"
@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@sburlot
sburlot / xc_ramdisk.sh
Created March 8, 2014 15:03
Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
#!/bin/bash
# Creates a ramdisk and start Xcode with the DerivedData stored in ramdisk. Also deletes the ramdisk and reset Xcode prefs.
# xc_ramdisk.sh
# - creates a ramdisk, set Xcode DerivedData to this disk and start Xcode.
# - umount a ramdisk, set Xcode DerivedData to default
# Stephan Burlot, Coriolis Technologies, http://www.coriolis.ch
#
# based on Alex Shevchenko xcode_ramdisk.sh script (https://gist.github.com/skeeet/2367298)
# based on Diego Freniche xc-launch.sh script (https://github.com/dfreniche/xc-launch)
@Duraiamuthan
Duraiamuthan / Unique identifiers
Created April 5, 2014 09:31
UDID vs UUID vs GUID
UUID:
It is the acronym of Universally Unique Identifier.
A sequence of 128 bits that can guarantee uniqueness across space and time, defined by RFC 4122.
GUID:
It is the acronym of Globally Unique Identifier
It is Microsoft's implementation of the UUID specification; often used interchangeably with UUID.
In dot net framework its called as Plain GUID and in sql server its called as newid
UDID:
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
{
//how to set identifier for an unwind segue:
//1. in storyboard -> documento outline -> select your unwind segue
//2. then choose attribute inspector and insert the identifier name
if ([@"UnwindFromSecondView" isEqualToString:identifier]) {
return [[MyCustomUnwindSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController];
}else {
@jbergen
jbergen / get-fonts
Created November 18, 2014 20:38
Print all available font families and font names (Swift)
for family in UIFont.familyNames() {
let sName: String = family as String
println("family: \(sName)")
for name in UIFont.fontNamesForFamilyName(sName) {
println("name: \(name as String)")
}
}
@licvido
licvido / app.swift
Created March 9, 2015 20:57
SWIFT: UITableView sections example
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
var itemsInSections: Array<Array<String>> = [["1A", "1B", "1C"], ["2A", "2B"], ["3A", "3B", "3C", "3D", "3E"]]
var sections: Array<String> = ["Section 1", "Section 2", "Section 3"]