Skip to content

Instantly share code, notes, and snippets.

View theredhead's full-sized avatar

Kris theredhead

View GitHub Profile
@theredhead
theredhead / prop.code-snippets
Created July 15, 2019 12:05
Visual Studio Code code-snippets
{
"property": {
"prefix": ["prop"],
"body": [
"private _${1:propertyName}: ${2:propertyType};",
"public get $1(): $2 {",
"\treturn this._$1;",
"}",
"public set $1(value: $2) {",
"\tif (value !== this._$1) {",
@theredhead
theredhead / Angular Material Module
Created June 27, 2019 07:58
Material Design Components module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatBadgeModule } from '@angular/material/badge';
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatChipsModule } from '@angular/material/chips';
@theredhead
theredhead / storage.servicve.ts
Created December 10, 2018 09:59
PouchDB backed storage service
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
// Probably want a better way to do this, but this needs to be referenced:
// <script src="//cdn.jsdelivr.net/npm/pouchdb@7.0.0/dist/pouchdb.min.js"></script>
// because no other way to declare PouchDB appears to work at this time
declare const PouchDB;
function newid(): string {
.container {
margin: 1em;
padding: 1em;
}
button {
position: relative;
border: none;
padding: 8px;
background-color: rgba(66, 100, 200, .9);
@import <Foundation/CPObject.j>
@import <Foundation/CPAttributedString.j>
var _regexColors;
@implementation ColorizingTextView : KVOCPText
{
}
@theredhead
theredhead / DataAdditions.cs
Last active December 1, 2016 16:40
Some useful utility extension methods on IDbConnection and IDbCommand to aid in keeping connectivity code concise
using System;
using System.Collections.Generic;
using System.Data;
namespace Data.Additions
{
/// <summary>
/// Represents an object that can be loaded from an IDataReader
/// </summary>
public interface IDataReaderLoadable
@theredhead
theredhead / hello-node.js
Created November 6, 2015 08:28
Simple "Hello World!" node test
"use strict";
var http = require("http");
http.createServer(function(request, response){
response.writeHead(200, 'OK');
response.write('<h1>Hello, Nodejs</h1>');
response.end();
}).listen(8080);
@theredhead
theredhead / DbClient.cs
Last active October 30, 2018 08:42
DbClient offers some utility for working with databases.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
namespace Red.Data
{
/// <summary>
/// DbClient offers some utility for working with databases.
/// </summary>
@theredhead
theredhead / sproc_info.sql
Created October 29, 2014 14:07
Get parameter name and other info for a stored procedure (SqlServer)
SELECT
R.SPECIFIC_NAME,
R.ROUTINE_BODY,
R.ROUTINE_DEFINITION,
P.PARAMETER_NAME,
P.DATA_TYPE,
P.CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.ROUTINES R
INNER JOIN INFORMATION_SCHEMA.PARAMETERS P ON P.SPECIFIC_NAME = R.SPECIFIC_NAME
WHERE
@theredhead
theredhead / SeparatePascalCasedWords.cs
Created May 21, 2014 07:28
Extension method to separate words in a PascalCased string (transforms "MyGreatApplication" into "My Great Application")
static public string SeparatePascalCasedWords(this string input)
{
System.Text.RegularExpressions.Regex.Replace(input, "(?<=[a-z])([A-Z])", " $1", System.Text.RegularExpressions.RegexOptions.Compiled).Trim();
}