Skip to content

Instantly share code, notes, and snippets.

@Garren
Garren / install_tools.bat
Last active August 14, 2020 16:59
Fix node's TLS issues when installing chocol on WinServer 2016.
"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command Start-Process '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' -ArgumentList '-NoProfile -InputFormat None -ExecutionPolicy Bypass -Command iex Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(''https://chocolatey.org/install.ps1'')); choco upgrade -y python visualstudio2017-workload-vctools; Read-Host ''Type ENTER to exit'' ' -Verb RunAs

Keybase proof

I hereby claim:

  • I am garren on github.
  • I am garren (https://keybase.io/garren) on keybase.
  • I have a public key whose fingerprint is FFCE 43BD 4A44 1576 90A1 954F FF8D B568 DD7F 4D68

To claim this, I am signing this object:

@Garren
Garren / gist:4948246
Created February 13, 2013 21:05
Re-create ID field with identity
-- http://decipherinfosys.wordpress.com/2008/03/21/getting-the-list-of-columns-for-a-table/
exec sp_msforeachtable '
if objectproperty(object_id(''?''), ''TableHasIdentity'') = 0 and exists (select * from information_schema.columns where table_name = object_name(object_id(''?'')) group by table_schema, table_name having count(column_name) > 1)
begin
declare @tableName varchar(64)
select @tableName = object_name(object_id(''?''))
declare @cols varchar(4096)
set @cols = (SELECT TOP 1
STUFF((SELECT '', '' + T2.COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS AS T2 WHERE T2.TABLE_NAME = T1.TABLE_NAME FOR XML PATH ('''')), 1, 2,'''') AS COL_NAMES
@Garren
Garren / timestamp.py
Created October 31, 2012 17:35 — forked from robcowie/timestamp.py
Insert date and time stamps in Sublime Text 2
# -*- coding: utf-8 -*-
from datetime import datetime
import sublime_plugin
import getpass
class TimestampCommand(sublime_plugin.EventListener):
"""Expand `isoD`, `now`, `datetime`, `utcnow`, `utcdatetime`,
`date` and `time`
"""
@Garren
Garren / QuickXsdValidate.cs
Created February 28, 2012 18:49
Programmatically validate against a schema (pulled from an SO post and slightly modified)
class Program {
static void Main(string[] args) {
var doc = ".\\file.xml";
var xsd = ".\\schema.xsd";
var settings = new XmlReaderSettings {
CloseInput = true,
ValidationType = ValidationType.Schema,
ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings
| XmlSchemaValidationFlags.ProcessIdentityConstraints
| XmlSchemaValidationFlags.ProcessInlineSchema
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Reflection.Emit;
using System.Collections.Concurrent;
using System.Data;
using System.Reflection;
// Ripped off from a StackOverflow thread - just here for my own reference
using System;
using System.Collections.Generic;
namespace ConsoleApplication1 {
public static class EnumerableExtensions {
public static void Each<T>(this IEnumerable<T> collection, Action<T> action) {
foreach (var item in collection) {
action(item);
}
// Slapped together from a StackOverflow thread with "LendReader" pulled in
// from "Design Patterns in C#" by Steven John Metsker
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;