Skip to content

Instantly share code, notes, and snippets.

View eralston's full-sized avatar
🏠
Working from home

Erik Ralston eralston

🏠
Working from home
View GitHub Profile
@eralston
eralston / RoundedTableView.m
Created December 17, 2013 22:38
A code snippet for adding rounded cells to a UITableView in Objective-C (Originally from http://stackoverflow.com/questions/18822619/ios-7-tableview-like-in-settings-app-on-ipad)
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(tintColor)]) {
if (tableView == self.tableView) {
CGFloat cornerRadius = 5.f;
cell.backgroundColor = UIColor.clearColor;
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
CGMutablePathRef pathRef = CGPathCreateMutable();
CGRect bounds = CGRectInset(cell.bounds, 10, 0);
BOOL addLine = NO;
@eralston
eralston / gist:7865300
Created December 8, 2013 23:52
A basic example of checking for available sharing mechanisms with SimpleSocial.
BOOL isFacebookLoggedInAndiOS6 = [SimpleSocial isFacebookAvailable];
BOOL isTwitterLoggedInAndiOS6 = [SimpleSocial isTwitterAvailable];
BOOL isSmsAvailable = [SimpleSocial isSmsAvailable];
BOOL isEmailAvailable = [SimpleSocial isEmailAvailable];
@eralston
eralston / gist:7865288
Created December 8, 2013 23:49
A basic demonstration of using SimpleSocial.
@implementation ViewControllerChild
{
// For holding the simple social instance
SimpleSocial *_simpleSocial;
// An outlet to the button, so we can show/hide only when Facebook is available
__weak IBOutlet UIButton *_shareBtn;
}
- (void)viewDidLoad
@eralston
eralston / MailExtensions.cs
Last active December 23, 2015 07:59
A static class in C# that simplifies setting properties of the System.Net.Mail.MailMessage class, concealing all of those extraneous new instances of objects you have to create.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net.Mime;
/// <summary>
@eralston
eralston / Code First Entity Framework Examples.cs
Last active December 21, 2015 05:48
Example C# class showing the basic and recurring patterns of fields used in Code First Entity Framework
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Globalization;
using System.Linq;
using System.Web.Security;
class Example
@eralston
eralston / Common Package Manager Console Commands
Last active December 21, 2015 05:39
The commands for common package manager console tasks for ASP.Net MVC web app projects, such as migration of Code-First Entity Framework
///
/// UPDATE NuGET PACKAGES
///
Once a project is created, be sure to run "update-packages" to get the latest version of each package
///
/// To ensure NuGet packages are working on teammate machines:
/// Go tools -> Options -> Package Manager -> General
/// Check "Allow NuGet to download missing packages during build
/// Right click on the project solution
@eralston
eralston / SimpleSocial.h
Last active December 20, 2015 19:18
An Objective-C class that simplifies using the iOS 6 Native social posting dialogs for Facebook and Twitter, plus SMS messaging and E-mail
//
// SimpleSocial.h
//
// Copyright (c) 2013 Erik Ralston
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@eralston
eralston / SimpleCaptureSession.h
Last active December 19, 2015 13:38
A sub-class of AVCaptureSession that adds a few helper properties for simplifying access to device hardware and add capabilities like flipping between the front and back camera.
//
// SimpleCaptureSession.h
//
// Copyright (c) 2013 Erik Ralston
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@eralston
eralston / SimpleDatabase.h
Last active December 19, 2015 06:29
An Objective-C base class for a basic CoreData data model implemented in SQLite, compiling all of the boilerplate code for setting up the necessary trio of CoreData classes (NSManagedObjectContext, NSManagedObjectModel, and NSPersistentStoreCoordinator) and providing a simplified interface for creating, fetching, and deleting NSManagedObject sub…
//
// SimpleDatabase.h
//
// Copyright (c) 2013 Erik Ralston
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@eralston
eralston / HtmlHelperExtensions.cs
Last active December 14, 2015 08:59
A simple static class in C# for ASP.Net MVC 4 that extends @html with a method for checking if the current build is debug or release
/// <summary>
/// Class for holding extensions for the HtmlHelper function
/// </summary>
public static class HtmlHelperExtensions
{
/// <summary>
/// Returns true if the build is DEBUG; otherwise, returns false
/// </summary>
/// <param name="htmlHelper"></param>
/// <returns></returns>