Skip to content

Instantly share code, notes, and snippets.

View scottoffen's full-sized avatar
💭
Live in SLC

Scott Offen scottoffen

💭
Live in SLC
View GitHub Profile
@scottoffen
scottoffen / grapevine-route-params.md
Last active June 3, 2017 18:28
Grapevine: Adding Parameters To Routes

To set up a route that parses parameters from the path info:

[RestRoute(HttpMethod = HttpMethod.GET, PathInfo = "/cars/[carId]")]
public IHttpContext GetCarById(IHttpContext context)
{
	// Get the car id from the incoming context:
	Console.WriteLine(context.Request.PathParameters["carId"]);
}
@scottoffen
scottoffen / add-datatables.js
Last active November 19, 2016 22:15
Apply the DataTables jQuery plugin to any table on a website
var options = { class : "wikitable", idx : 0, id : "firstWikiTable" };
var dt_options = { paging: false, scrollY: 400 };
var jscript = document.createElement("script"); jscript.src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"; document.body.appendChild(jscript);
jscript.onload = function ()
{
var script = document.createElement("script"); script.src="https://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"; document.body.appendChild(script);
script.onload = function ()
{
var css = document.createElement("link"); css.rel="stylesheet"; css.href="https://cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css"; document.body.appendChild(css);
css.onload = function ()
@scottoffen
scottoffen / open-cover-xunit.bat
Created July 25, 2016 00:56
Original implementation of OpenCover and Xunit on the Grapevine project
@ECHO OFF
REM OpenCover-xunit.bat
REM Run opencover against xunit tests in your test project and show report of code coverage
Set SearchDirectory=%~dp0Grapevine.Tests\bin\Debug
SET DllContainingTests=%~dp0Grapevine.Tests\bin\Debug\Grapevine.Tests.dll
REM *** IMPORTANT - Change DllContainingTests variable (above) to point to the DLL
@scottoffen
scottoffen / .gitconfig
Last active March 7, 2016 16:05
Git Personal
[alias]
personal = config user.email "personal@emailaddress.com"
@scottoffen
scottoffen / mongodb-service.bat
Last active March 4, 2016 08:12
MongoDB Windows Service Setup
@echo off
if %1.==. goto UseDefaults
set srvname=%1
if %2.==. goto UseDefaultApp
set app=%2
if %3.==. goto UseDefaultConfig
set config=%3
@scottoffen
scottoffen / create-mysql-db.sql
Last active February 1, 2016 20:35
Create New MySQL Database (with user)
-- Using GRANT for creating new users has been deprecated and will be removed in the future
-- as of 5.7.1
-- Create a new user
create user '[username]'@'[host]' identified by '[password]';
-- Create a new database/user
create database [schema];
-- Grant user access to database
@scottoffen
scottoffen / TestParticleMan.groovy
Last active January 1, 2016 06:29
Groovy test case for the song Particle Man by TMBG!
import groovy.util.GroovyTestCase;
class TestMan extends GroovyTestCase
{
def particleMan = new Man(Man.Type.Particle);
def triangleMan = new Man(Man.Type.Triangle);
def universeMan = new Man(Man.Type.Universe);
def personMan = new Man(Man.Type.Person);
void testParticleMan ()

Using NTLM in Node.js

Add a project dependency for express-ntlm. In your express configuration, require in this package.

var app = require('express');
var ntlm = require('express-ntlm');

Just before adding routes to the app (after all the body parsing and static references, etc.):

@scottoffen
scottoffen / autoloader.js
Last active December 9, 2015 01:01
Autoload Express Routes
var config = require('config/config');
var debug = require('debug')(global.app.name + ':autoloader');
var path = require('path');
var fs = require('fs');
var mask = /\.routes?\.js/i;
var _ = require('lodash');
/***********************************************************************************
* Autoloader entry point *
@scottoffen
scottoffen / neo4j.md
Last active August 29, 2015 14:26
Neo4j Resource

Utilities

  • Structr : Not yet sure what exactly this does.

node/npm

  • Seraph (npm) : A terse & familiar binding to the Neo4j REST API that is idiomatic to node.js
  • Seraph-Model (npm) : provides some convenient functions for storing and retrieving typed nodes from a neo4j database using seraph
  • Seraph-Resource : creates a controller with crud methods for a seraph model.