Skip to content

Instantly share code, notes, and snippets.

@sabernar
sabernar / gist:3e05123814de8151822b30fdb68a6195
Created June 14, 2016 20:50 — forked from Bouke/gist:10454272
Install FreeTDS, unixODBC and pyodbc on OS X

First, install the following libraries:

$ brew install unixodbc
$ brew install freetds --with-unixodbc

FreeTDS should already work now, without configuration:

$ tsql -S [IP or hostname] -U [username] -P [password]
locale is "en_US.UTF-8"

locale charset is "UTF-8"

@sabernar
sabernar / NSManagedObject+Cloner.h
Created October 20, 2015 01:23 — forked from shto/NSManagedObject+Cloner.h
NSManagedObject cloner files
#import <CoreData/CoreData.h>
@interface NSManagedObject (Cloner)
- (NSManagedObject *)clone;
- (NSManagedObject *)cloneInContext:(NSManagedObjectContext *)differentContext;
@end
@sabernar
sabernar / xcode-build-bump.sh
Created September 30, 2015 23:51 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@sabernar
sabernar / gist:7e479631c2229dbbd6a6
Created August 28, 2014 00:57
Recursively rename files
for file in $(find . -name '*.JPG'); do mv $file $(dirname $file)/xxxxxxx_$(basename $file); done
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
@sabernar
sabernar / transparent_nav_bar.m
Created May 7, 2014 18:44
iOS 7 transparent navigation bar
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
@sabernar
sabernar / fileMIMEType.m
Created April 15, 2014 18:07
Determine MIME type of file using the file's extension
- (NSString*) fileMIMEType
{
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[self.filename pathExtension], NULL);
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);
CFRelease(UTI);
return (NSString *)CFBridgingRelease(MIMEType);
}
@sabernar
sabernar / MKMapRectMake
Created February 26, 2014 00:33
Set mapRect for MKMapView
// lower-left co-ordinate of map
CLLocationCoordinate2D lowerLeftCoOrd = CLLocationCoordinate2DMake(45.48, -122.67);
MKMapPoint lowerLeft = MKMapPointForCoordinate(lowerLeftCoOrd);
// upper-right co-ordinate of map
CLLocationCoordinate2D upperRightCoOrd = CLLocationCoordinate2DMake(45.52, -122.63);
MKMapPoint upperRight = MKMapPointForCoordinate(upperRightCoOrd);
// create a map-rect using both co-ordinates as follows.
MKMapRect mapRect = MKMapRectMake(lowerLeft.x, upperRight.y, upperRight.x - lowerLeft.x, lowerLeft.y - upperRight.y);
@sabernar
sabernar / MyTableCellView.m
Created February 11, 2014 19:21
Change highlight text color of NSTableViewCell
- (void) setBackgroundStyle:(NSBackgroundStyle)backgroundStyle
{
NSTableRowView *row = (NSTableRowView*)self.superview;
if (row.isSelected) {
self.textField.textColor = [NSColor blackColor];
} else {
self.textField.textColor = [NSColor whiteColor];
}
}