Skip to content

Instantly share code, notes, and snippets.

View jondlm's full-sized avatar

Jon de la Motte jondlm

  • Stripe
  • Portland, OR
View GitHub Profile
@jondlm
jondlm / UnknownRecord.sql
Last active December 14, 2015 17:19
A TSQL helper stored proc to generate and insert your unknown records for you. Be sure to modify and test the stored proc before implementing it. It can be tested by not supplying the third @action parameter, and it can be executed by specifying a third @action parameter of ‘runit’. Credit to http://www.bidn.com/blogs/PatrickLeBlanc/ssis/745/ins…
-- author: jond@csgpro.com
-- create: 2013-03-08
-- description: this proc will take table name, schema name, and optional action parameters
-- and insert an "unknown" record into that dimension table for you. If you don't
-- specific the @Action parameter as 'runit', then it will only print the SQL
-- output for you.
create proc [helper].[UnknownRow]
@TableName sysname,
@TableSchema sysname = 'dbo',
@jondlm
jondlm / CompareTableColumns.sql
Created March 28, 2013 23:35
A TSQL helper stored proc for comparing the column names of two tables.
-- =============================================
-- Author: Jon - jond@csgpro.com
-- Create date: 2013-03-05
-- Description: Helper function for comparing columns between two tables.
-- =============================================
CREATE FUNCTION [helper].[fnCompareTableColumns] (
@baseTable varchar(250),
@compareTable varchar(250)
)
RETURNS TABLE
@jondlm
jondlm / Execute Sql Agent Job.ps1
Last active December 20, 2015 09:30
A small script to kick off a SQL agent job on SQL Server.
Write-Host "Loading connection..." -ForegroundColor Yellow -NoNewline
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
Write-Host "Done." -ForegroundColor Green
#Set the connection string
$SqlConnection.ConnectionString = "Server=,<server name>;Database=<database name>;Integrated Security=True"
#Declare a SqlCommand object
$SqlCommand = New-Object System.Data.SqlClient.SqlCommand
@jondlm
jondlm / jslint-header.js
Created September 16, 2013 19:11
Node / browserify / jQuery jslint header
/*jslint
browser: true,
node: true */
/*global $ */
@jondlm
jondlm / sql-server_row-count-and-size.sql
Last active December 28, 2015 03:49
Some general scripts for SQL Server to get a data about tables in your databases
USE DatabaseName
GO
CREATE TABLE #temp_table (
table_name sysname ,
row_count INT,
reserved_size VARCHAR(50),
data_size VARCHAR(50),
index_size VARCHAR(50),
unused_size VARCHAR(50))
@jondlm
jondlm / xmodmap.md
Last active September 13, 2017 12:57
Xmodmap swap caps lock and ctrl

Create a file, like ~/.xmodmap and paste the following in it:

!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
@jondlm
jondlm / logger.js
Last active August 29, 2015 14:03
A flexible console logger for Node.js complete with log levels and color
// Logging levels:
//
// INFO
// WARN
// ERROR
// FATAL
//
// Usage:
// var log = require('./logger.js');
//
@jondlm
jondlm / q.js
Created September 22, 2014 21:54
Node style callbacks to q promises
var Q = require('q');
var assert = require('assert');
// Node style callback
function echo(thing, callback) {
callback(null, thing + thing);
}
//
// Test code
@jondlm
jondlm / centos_shellshock_patch.yml
Created September 26, 2014 19:51
ShellShock fix Ansible playbook for CentOS
- hosts: all
gather_facts: false
sudo: true
tasks:
- name: check for shellshock bash vulnerability
shell: executable=/bin/bash env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
register: test_vuln
- name: update bash from yum if vulnerable
yum: name=bash
@jondlm
jondlm / sinon_example.js
Last active August 29, 2015 14:07
Mocha, Chai, and Sinon Example
// `npm install -g mocha`
// `npm install chai sinon`
// Run with `mocha sinon_example.js`
var assert = require('chai').assert;
var sinon = require('sinon');
var clock = sinon.useFakeTimers();
// Sample function, this would normally be where you `require` your modules
var slow = function(cb) {