Skip to content

Instantly share code, notes, and snippets.

View iggym's full-sized avatar
🎯
😄

Iggy iggym

🎯
😄
View GitHub Profile
@iggym
iggym / Build-Share-Repo-Steps.txt
Created December 10, 2013 17:30
Build and Share Github Repo Steps
##### Create your project locally
##### Create a github repo using web UI (With README, License and .gitignore)
##### Create a git repo locally and commit your newly created project
git init
git commit -m "first code commit"
##### Push an existing repository from the command line
git remote add origin https://github.com/iggym/MyRepoName.git
git push -u origin master
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
@iggym
iggym / NSErrors_how_to_iOS.mm
Last active December 29, 2015 08:49
NSErrors, NSExcpetions and how to properly handle runtime failures in iOS
/**
If you’re coming from other platforms and languages, you may be used to working with exceptions for the majority of error handling.
When you’re writing code with Objective-C, exceptions are used solely for programmer errors, like out-of-bounds array access or
invalid method arguments.
see https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/ErrorHandling/ErrorHandling.html
-Some Delegate Methods Alert You to Errors
-Some Methods Pass Errors by Reference
-Recover if Possible or Display the Error to the User
-Generate your own errors
Many methods of the Cocoa and Cocoa Touch classes include as their last parameter a direct or indirect reference to an NSError object.
@iggym
iggym / Test_HTTP_Requests.md
Last active December 29, 2015 01:09
Testing HTTP POST, GET, PUT, PATCH, DELETE
#!/bin/sh
# Current as working as of 2012/4/17
# Xcode 4.3.2
PROJECT_ROOT="$HOME/SomeDirWhereYourProjectLives/XXXXXXXX"
WORKSPACE="$PROJECT_ROOT/XXXXXXXX.xcodeproj/project.xcworkspace"
CONFIG="AdHoc"
SCHEME="XXXXXXXX"
//Singleton Object in Objective-C
+ (MyClass *)sharedInstance {
static MyClass *_sharedInstance = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedInstance = [[self alloc] init];
});
return _sharedInstance;
}
@iggym
iggym / CheckForEmptyProperties.cs
Created October 11, 2013 15:27
Check For Empty Properties C#
void Main()
{
Person aPerson = new Person();
aPerson.FirstName = "Joe";
aPerson.Age = 21;
aPerson.DateOfBirth = DateTime.Now;
List<string> values
@iggym
iggym / ASP.NET_WebAPI_Routing_Notes.cs
Last active December 25, 2015 05:19 — forked from AlexZeitler/gist:1843616
Web API Routing notes and example
//Web API Routing notes and example
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
//================ The Controller =========================================
public class VTRoutingController : ApiController
@iggym
iggym / ASP.NET_Web_API_Routing.cs
Last active December 25, 2015 02:49
ASP.NET Web API Routing, Parameter binding
//In Web API, just like standard MVC project, the route configuration is called from the Global.asx file.
//The standard Web API project, there exists both a RouteConfig class, and a WebApiConfig class, both in the Application_Start folder:
//The Default MVC Route Template:
{controller}/{action}/{id}
//The Default Web API Route Template: (Note: there is no {action})
api/{controller}/{id}
//The above will work with
@iggym
iggym / How NOT to do website security .NET
Last active December 23, 2015 10:59
How NOT to do website security .NET
http://www.troyhunt.com/2013/09/for-your-security-please-email-your.html
http://www.troyhunt.com/2013/09/for-your-security-please-email-your.html
http://www.troyhunt.com/2011/11/owasp-top-10-for-net-developers-part-9.html
@iggym
iggym / send_accelerometer_data_to_your_app.mm
Last active December 22, 2015 18:39
Have iOS send accelerometer data to your application
//Use the startAccelerometerUpdatesToQueue:withHandler: instance method of CMMotionManager.
#import <UIKit/UIKit.h>
#import <CoreMotion/CoreMotion.h>
@interface Retrieving_Accelerometer_DataViewController : UIViewController
@property (nonatomic, strong) CMMotionManager *motionManager;
@end