Skip to content

Instantly share code, notes, and snippets.

View jarrettmeyer's full-sized avatar

Jarrett Meyer jarrettmeyer

View GitHub Profile
@jarrettmeyer
jarrettmeyer / create_dates.sql
Last active January 3, 2018 21:04
Create a reference table of numbers
-- Drop the ref.dates table if it already exists.
IF OBJECT_ID('ref.dates') IS NOT NULL DROP TABLE ref.dates;
GO
-- Create a temp table with computed values. We will delete this
-- temp table at the end of this script.
CREATE TABLE #dates (
date DATE NOT NULL,
year AS DATEPART(YEAR, date),
/*
fn_FilenameFromFullPath.sql (c) 2017 Jarrett Meyer
Description:
Extracts a filename from a full path. Files may have spaces.
Examples:
dbo.fn_FilenameFromFullPath('file.txt') -> 'file.txt'
dbo.fn_FilenameFromFullPath('C:\file.txt') -> 'file.txt'
dbo.fn_FilenameFromFullPath('C:\temp\examples\file.txt') -> 'file.txt'
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace ServerCertificateValidationDemo
{
public class Program
{
private static string _defaultUrl = @"https://www.google.com";
create function [dbo].[DecryptString]
(
@xml xml
)
returns varchar(max)
as
begin
declare @returnString varchar(max);
declare @temp table (line int, encryptedText varbinary(max), plainText varchar(max));
@jarrettmeyer
jarrettmeyer / NHibernateSessionManager.cs
Last active July 31, 2017 23:26
How I configure NHibernate with Ninject
public class NHibernateSessionManager
{
private const string CONNECTION_STRING_NAME = "...";
private static Configuration configuration;
private static readonly ILog log;
private static ISessionFactory sessionFactory;
static NHibernateSessionManager()
{
# Install prerequisites.
sudo apt-get install -y build-essential \
libreadline6 libreadline6-dev \
gfortran \
libxorg-dev \
libbz2-dev \
liblzma-dev \
libpcre3-dev \
libcurl4-openssl-dev \
libjpeg-dev libtiff5-dev libicu-dev libcairo2-dev \
@jarrettmeyer
jarrettmeyer / threaddemo.js
Created March 3, 2016 11:27
multiple threads in a NodeJS application
'use strict';
const args = process.argv;
const cluster = require('cluster');
function getThreads() {
let threads = 1;
let tag = args.indexOf('--threads');
if (tag > 0) {
let newThreads = parseInt(args[tag + 1], 10);
@jarrettmeyer
jarrettmeyer / pubsub
Last active March 2, 2016 20:46
pubsub with NodeJS and AMQPLib
#!/usr/bin/env node
//
// Example of publisher/subscriber pattern in NodeJS, with AMQPLib. This program has been
// demonstrated to work with 500k messages and 4 subscribers.
//
// #WorksOnMyMachine
//
// Usage: ./pubsub
//
@jarrettmeyer
jarrettmeyer / HttpSession.cs
Created February 17, 2013 14:58
How to work with sessions in .NET
public abstract class HttpSession : IHttpSession
{
protected IKeyValueStore storage;
public virtual int UserId
{
get { return Get<int>("user_id"); }
set { storage["user_id"] = value; }
}
@jarrettmeyer
jarrettmeyer / environment.txt
Last active January 3, 2016 09:19
Windows environment variables
PATH
%WINDOWS_PATH%;%SQL_SERVER_PATH%;%VISUAL_STUDIO_PATH%;%GIT_PATH%;%NODEJS_PATH%;%DEVTOOLS_PATH%
WINDOWS_PATH
C:\Windows;C:\Windows\system32;C:\Windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\
SQL_SERVER_PATH
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\