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 / 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 / HttpWebRequestExtensions.cs
Created May 14, 2013 15:44
A simple static class in C# holding extensions for the System.Net.HttpWebRequest class, to make life a little easier when communicating with HTTP interfaces on the web, especially JSON-based REST-style services.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
// Customize this namespace as needed
namespace Utility
{
@eralston
eralston / UDK .gitignore
Last active July 26, 2019 23:38
A .gitignore for projects created using the Unreal Development Kit (UDK). This will retain your changes in custom config, code, and content, but ignore foundational components of a UDK install. This list is current as of the February 2013 Beta UDK installation. To use, simply add this content to a .gitignore file before running your initial "git…
# File Types known to be unecessary
*.swp
*.bin
*.checkpoint
*ShaderCache*
*PCTOC*
*.log
*.obj
*IphoneTOC*
*.dmp
@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>
@eralston
eralston / Singleton.m
Last active October 13, 2015 23:08
A simple Singleton template in Objective-C, based on the Big Nerd Ranch snippet
///
/// A singleton class template for header (.h)
///
@interface Singleton : NSObject
+ (Singleton*)shared;
@end
///
@eralston
eralston / DataGridAdapt.js
Created April 17, 2012 17:07
jQuery Plug-In to fix .Net DataGrid Output into Something DataTables Can Accept
//
// .Net DataGrid spits out only a tbody for the entire table, but http://datatables.net/ needs thead as well
// This yanks out the first row of the table, assumed to be the header row, then places it within a new thead
// Should be called like this: #("#dot_net_table_id").convertFirstTableRowToHeader().dataTable();
//
(function ($) {
$.fn.convertFirstTableRowToHeader = function () {
return this.each(function () {
var table = $(this);
if (!table.is("table"))
@eralston
eralston / Reset.css
Created May 19, 2011 00:39
CSS Snippet for resetting browser inconsistencies, thanks meyerweb :D
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
<style type="text/css">
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
@eralston
eralston / trim.js
Created May 13, 2011 16:31
JavaScript snippet for trimming whitespace from strings - http://www.somacon.com/p355.php
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
return this.replace(/\s+$/,"");
}
/*
* Cross-browser display: inline-block
*
* References:
* - http://foohack.com/2007/11/cross-browser-support-for-inline-block-styling/
* - http://www.getonthenet.eu/css-howto-cross-browser-inline-block/
*/
inline-block {
display: -moz-inline-box; /* Firefox 2 */