Skip to content

Instantly share code, notes, and snippets.

View jstangroome's full-sized avatar

Jason Stangroome jstangroome

View GitHub Profile
@meklarian
meklarian / PZIAdapter.cpp
Created May 26, 2010 09:59
Source code for a Win32 DLL and a sample C# project demonstrating a single function that can be used to scrub out Persistent-Zone-Identifiers (PZIs) from files.
// PZIAdapter.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "PZIAdapter.h"
// This is an example of an exported function.
PZIADAPTER_API DWORD _stdcall StripFilePZI(BSTR bstrFilename)
{
if(!bstrFilename){return E_INVALIDARG;}
@tathamoddie
tathamoddie / RequiresPowerShell.bat
Created August 5, 2010 03:48
Batch file to automatically detect, download and install PowerShell 2 on to an XP SP3 machine
@echo off
REM If PowerShell 2 is not installed, this script will automatically download and install it.
REM Only works on XP SP3 with .NET 3.5. Only for dev boxes, not designed for servers.
REM Based on http://blog.codeassassin.com/2009/12/10/no-web-browser-need-powershell/
ver | find "XP" > nul
if %ERRORLEVEL% neq 0 goto not_xp
ver | find "5.1.2600" > nul
@huyng
huyng / reflect.py
Created February 7, 2011 17:57
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@aaronpowell
aaronpowell / selectMany.js
Created November 19, 2012 03:22
LINQ SelectMany in JavaScript
Array.prototype.selectMany = function (fn) {
return this.map(fn).reduce(function (x, y) { return x.concat(y); }, []);
};
// usage
console.log([[1,2,3], [4,5,6]].selectMany(function (x) { return x; })); //[1,2,3,4,5,6]
console.log([{ a: [1,2,3] }, { a: [4,5,6] }].selectMany(function (x) { return x.a; }));
@aaronpowell
aaronpowell / gist:4159243
Created November 28, 2012 05:37
Get changeset from workspace
var localPath = "Some Path";
if (!Workstation.Current.IsMapped(localPath)) {
Log.LogError(string.Format("The local path '{0}' is not mapped to a TFS workspace.", LocalPath));
return false;
}
var info = Workstation.Current.GetLocalWorkspaceInfo(localPath);
var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(info.ServerUri);
var workspace = info.GetWorkspace(collection);
var localVersions = workspace.GetLocalVersions(new [] {new ItemSpec(localPath, RecursionType.Full)}, false);
#requires -Version 2.0
param(
[Parameter(Mandatory=$true)]
[string]
$databaseRootDirectory
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 'Latest'
$fileGroupSpecification = "ON [PRIMARY]"
@pauloconnor
pauloconnor / gist:4707710
Last active December 1, 2022 09:33
Logstash Mutate Filter for stripping Linux color codes from log files
# Get rid of color codes
mutate {
gsub => ["message", "\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", ""]
}
@relekang
relekang / wsgi.py
Created February 12, 2013 22:18
django wsgi.py with new relic intialize
# -*- coding: utf-8 -*-
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
import newrelic.agent
newrelic.agent.initialize(os.path.join(os.path.dirname(os.path.dirname(__file__), 'newrelic.ini')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
@robwierzbowski
robwierzbowski / gitcreate.sh
Last active August 8, 2023 07:31
A simple litte script. Create and push to a new github repo from the command line.
#!/bin/bash
# https://gist.github.com/robwierzbowski/5430952/
# Create and push to a new github repo from the command line.
# Grabs sensible defaults from the containing folder and `.gitconfig`.
# Refinements welcome.
# Gather constant vars
CURRENTDIR=${PWD##*/}
GITHUBUSER=$(git config github.user)
@jjmaestro
jjmaestro / whisper-calculator.py
Last active November 26, 2019 07:13
whisper-calculator.py: Calculates the size of the whisper storage for the given retention (in frequency:history format)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def archive_to_bytes(archive):
def to_seconds(s):
SECONDS_IN_A = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,