Skip to content

Instantly share code, notes, and snippets.

View gotomanners's full-sized avatar

Manners gotomanners

  • Dublin, Ireland
View GitHub Profile
Without reminder:
:beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer: :beer:
:beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers:
:beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers:
:beers: :beers: :beers: :beers: :beers: :beers:
:beers: :beers: :beers: :beers: :beers: :beers:
:beers: :beers: :beers: :beers: :beers: :beers:
:beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers:
:beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers:
@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
##
# 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 / DebugOut.cpp
Created September 9, 2015 13:14
Simple windows debug out
// http://coliru.stacked-crooked.com/a/481b444c09361f1d
#include <sstream>
#include <thread>
#include <cstdio>
#include <cstdarg>
#include <cwchar>
#include <cstdlib>
#include <windows.h>
@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);
- (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 / GIT Stuff
Last active August 29, 2015 14:08
Some git commands
Merge changes from remote github repository to your local repository
// https://help.github.com/articles/syncing-a-fork
// http://stackoverflow.com/q/867831/184646
git remote add {name} {Public Clone URL}
git pull {name} master
git push
Undo commit not pushed
@interface NSString (TruncateToWidth)
- (NSString*)stringByTruncatingToWidth:(CGFloat)width withFont:(UIFont *)font;
@end
#import <UIKit/UIKit.h>
@interface UIImage (ResizeImage)
+ (UIImage *)convertImage:(UIImage *)image toSize:(CGSize)size;
@end
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);
}
}