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 / 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 / git.ps1
Created July 16, 2021 13:31
PowerShell utilities for Git
# Delete all branches except trunk (and current - which will error out and not be deleted even if it's not trunk)
git branch | %{ $_.Trim() } | ?{ $_ -ne 'trunk' } | %{ git branch -D $_ }
@eralston
eralston / TypeGuards.ts
Created June 15, 2021 22:40
Useful type guards in Typescript, for validating all your inputs
function isValidNumber (it: unknown): it is number {
return it != null && typeof it === 'number' && !Number.isNaN(it)
}
@eralston
eralston / gulpfile.js
Last active November 5, 2020 21:10
Gulp + SCSS + BrowserSync Example
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync').create();
var Paths = {
HERE: './',
DIST: 'dist/',
CSS: './assets/css/',
@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;
declare global {
namespace NodeJS {
interface ProcessEnv {
DYNAMODB_TABLE: string
SOCOTRA_INSTANCE_HOST_NAME: string
SOCOTRA_API_BASE_URI: string
SOCOTRA_AUTH_USERNAME: string
SOCOTRA_AUTH_PASSWORD: string
}
}
@eralston
eralston / ControllerExtensions.cs
Last active August 9, 2020 10:40
A set of helpers to enable ASP.Net MVC Controllers to render their views and send them as e-mail
/// <summary>
/// Extension methods for the system MVC controller and related classes
/// </summary>
public static class ControllerExtensions
{
/// <summary>
/// Renders a view to string using the given model
/// </summary>
/// <param name="controller"></param>
/// <param name="viewName"></param>
/**
* Utility class around window.sessionStorage that simplifies access and provides strong-typing
* */
export default class StorageValue<ValueType> {
private key: string;
private storage: Storage;
constructor(key: string, storage: Storage = sessionStorage) {
this.key = key;
import PublicError from './PublicError';
// Based catch-decorator by Enkot https://github.com/enkot/catch-decorator
// decorator factory function
export default (name: string, message?: string): any => {
return (
target: any,
propertyKey: string,
descriptor: PropertyDescriptor,
// https://webpack.js.org/loaders/raw-loader/
npm install raw-loader --save-dev
// In webpack.config.js
module.exports = {
...
module: {
rules: [
...