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 / ZeroClipboardExample
Last active August 29, 2015 14:19
A code snippet for adding ZeroClipboard (https://github.com/zeroclipboard/zeroclipboard/) to an HTML page from CDN.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.2.0/ZeroClipboard.min.js"></script>
<script>
$(function () {
ZeroClipboard.config({ swfPath: "https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.2.0/ZeroClipboard.swf" });
client = new ZeroClipboard($(".copy-button"));
})
</script>
@eralston
eralston / Web.Release.config
Created April 9, 2015 18:24
Web.config setting example for inserting a setting to force SSL in IIS; originally used in an ASP.Net MVC web application in Visual Studio
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
@eralston
eralston / .tfignore
Created February 26, 2015 19:00
Example ignore file for Team Foundation Server, excluding files from Bin, NuGet packages, etc
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
bin
obj
#include nuget executable
@eralston
eralston / jquery.plugintemplate.js
Created February 7, 2015 20:01
jQuery Plug-In Template
///
/// jqury.plugintemplate.js
/// A short explanation of what it does right here
///
///
/// Intended HTML structure for targeted complex form (if applicable)
/// .postal-code-form - outer wrapper
/// .locationInputs - wrapper around all inputs
/// .postal-input - postal code input
@eralston
eralston / drop_schema.sql
Last active August 10, 2021 15:09
Drops all Stored Procedures, Views, Functions, Foreign and Primary Key Constraints, and Tables
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
@eralston
eralston / AsyncMethodExample.h
Created February 27, 2014 18:53
A contrived asynchronous method using two operation queues
-(void)exampleAsyncMethod
{
// This method can have a dedicated queue for all instances on it
// Or maybe per instance if downloadQueue were instead a class variable
static NSOperationQueue *downloadQueue = nil;
if(!downloadQueue) {
downloadQueue = [[NSOperationQueue alloc] init];
}
// Capture the queue that called us
@eralston
eralston / SimpleFilesCache.h
Created February 27, 2014 18:37
An Objective-C class for caching files in the CachesDirectory of an app quickly and easily
//
// SimpleFilesCache.h
//
#import <Foundation/Foundation.h>
///
/// A static class for basic management of the NSCachesDirectory contents
///
@interface SimpleFilesCache : NSObject
@eralston
eralston / Blocks.h
Created February 27, 2014 18:08
An example of block typedefs in Objective-C
#ifndef Blocks_h
#define Blocks_h
#import <Foundation/Foundation.h>
typedef void (^VoidBlock)();
typedef BOOL (^ReturnBoolBlock)();
typedef void (^DictionaryBlock)(NSDictionary *dictionary);
@eralston
eralston / SimpleNotifier.h
Created February 27, 2014 17:52
A basic, block-oriented pub-sub pattern in Objective-C, demonstrating typedef of blocks and use of operation queues
//
// SimpleNotifier.h
//
#import <Foundation/Foundation.h>
typedef void (^VoidBlock)();
///
/// A simple notification to-many observers
@eralston
eralston / KeyboardAnimation.m
Created January 3, 2014 19:41
An example in Objective-C of animating the UI based on keyboard appearance/disappearance
///
/// Category to help with animating UIView instances
///
@implementation UIView (Animation)
-(void)translateX:(float)x andY:(float)y
{
CGPoint center = self.center;
center.x += x;
center.y += y;