Skip to content

Instantly share code, notes, and snippets.

View gotomanners's full-sized avatar

Manners gotomanners

  • Dublin, Ireland
View GitHub Profile
@gotomanners
gotomanners / gist:3788039
Created September 26, 2012 13:28 — forked from shazron/gist:2127546
iOS WebKit Database Locations

iOS WebKit Database Locations

"~" signifies the application's folder.

window.localStorage (4.3)

  1. ~/Library/WebKit/LocalStorage/file__0.localstorage
@gotomanners
gotomanners / executeSqlBridgeForPhonegapSQLitePlugin.js
Created September 26, 2012 16:31 — forked from orbitaloop/executeSqlBridgeForPhonegapSQLitePlugin.js
executeSql Bridge For PhonegapSQLitePlugin (because there are some differences between the WebSQL API and the plugin)
/* to use WebSQL or the SQLite plugin (https://github.com/davibe/Phonegap-SQLitePlugin) with the same function) */
executeSqlBridge: function(tx, sql, params, dataHandler, errorHandler) {
var self = this;
if (typeof self.db.dbPath !== 'undefined') {
//Native SQLite DB with phonegap : https://github.com/davibe/Phonegap-SQLitePlugin/
//this is a native DB, the method signature is different:
var sqlAndParams = [sql].concat(params);
var cb = function(res) {
@gotomanners
gotomanners / jquery.spin.js
Created November 25, 2012 05:13 — forked from innotekservices/jquery.spin.js
jQuery Plugin for Spin.js
/*
You can now create a spinner using any of the variants below:
$("#el").spin(); // Produces default Spinner using the text color of #el.
$("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el.
$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color).
$("#el").spin({ ... }); // Produces a Spinner using your custom settings.
$("#el").spin(false); // Kills the spinner.
# 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)
MKMapRect zoomRect = MKMapRectNull;
for (id <MKAnnotation> annotation in mapView.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
} else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
}
#import <UIKit/UIKit.h>
@interface UIImage (ResizeImage)
+ (UIImage *)convertImage:(UIImage *)image toSize:(CGSize)size;
@end
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
if (!self.manuallyChangingMap) {
BOOL updateRegion = NO;
MKCoordinateRegion restrictedRegion = [self restrictedRegion];
if ((mapView.region.span.latitudeDelta > restrictedRegion.span.latitudeDelta * 4) || (mapView.region.span.longitudeDelta > restrictedRegion.span.longitudeDelta * 4) ) {
updateRegion = YES;
}
if (fabs(mapView.region.center.latitude - restrictedRegion.center.latitude) > restrictedRegion.span.latitudeDelta) {
@gotomanners
gotomanners / gist:e0f21d6c30f3471ce7e1
Last active August 29, 2015 14:28 — forked from deurell/gist:10f4108d0aff5e97e70d
WinRT string conversion
std::wstring StringConverter::StringToWideString(const std::string& s) {
int len = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), s.length(), NULL, 0);
std::wstring ws(L"", len);
wchar_t* pWSBuf = const_cast<wchar_t*>(ws.c_str());
MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, pWSBuf, len);
return ws;
}
std::string StringConverter::WideStringToString(const std::wstring& ws) {
int len = WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.length(), 0, 0, NULL, NULL);
##
# Creates an alias called "git hist" that outputs a nicely formatted git log.
# Usage is just like "git log"
# Examples:
# git hist
# git hist -5
# git hist <branch_name>
# git hist <tag_name> -10
##
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
@gotomanners
gotomanners / DeviceUID.m
Created April 8, 2016 13:04 — forked from miguelcma/DeviceUID.m
iOS Unique Device ID that persists between app reinstalls
/* DeviceUID.h
#import <Foundation/Foundation.h>
@interface DeviceUID : NSObject
+ (NSString *)uid;
@end
*/
// Device.m