Skip to content

Instantly share code, notes, and snippets.

View peschkaj's full-sized avatar

Jeremiah Peschka peschkaj

View GitHub Profile
@taddev
taddev / RunElevated.ps1
Created October 27, 2012 04:43
Create a sudo-like command for Powershell
#
# Author: Tad DeVries
# Email: taddevries@gmail.com
# FileName: RunElevated.ps1
#
# Description:
# Creates a "sudo" like command to elevate another
# command to administrative level. This is used to
# simplify the CLI interaction and create a little
# home like feeling for the *nix users out there.
@tjdett
tjdett / MyScalatraServlet.scala
Last active May 24, 2018 05:29
Scala + Apache POI to read uploaded Excel doc
package com.example.app
import org.scalatra._
import servlet.{SizeConstraintExceededException, FileUploadSupport}
import scalate.ScalateSupport
import java.io.ByteArrayInputStream
import org.apache.poi.ss.usermodel.WorkbookFactory
import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.DataFormatter
import org.apache.poi.ss.usermodel.DateUtil
#include <iostream>
using namespace std;
class Monster {
public:
Monster();
Monster(int initial_hp);
~Monster();
void attack() const;
@jbtule
jbtule / LosslessJson.csx
Created May 25, 2013 01:37
This example was inspired by "Serialization is Lossy" http://kellabyte.com/2013/05/02/serialization-is-lossy/
using ImpromptuInterface;
using Newtonsoft.Json.Linq;
/*
* This example was inspired by
* "Serialization is Lossy"
* http://kellabyte.com/2013/05/02/serialization-is-lossy/
*/
@timf
timf / gist:1718425
Created February 1, 2012 18:15
Throttling BW and latency on OSX
sudo ipfw pipe 1 config bw 150kbit/s delay 150ms
sudo ipfw add pipe 1 dst-ip 0.0.0.0/0
# do slow stuff
# done:
sudo ipfw flush
@peschkaj
peschkaj / match_queries_by_hash.sql
Created March 24, 2014 01:24
This will match SQL Server statements to the appropriate portion of the execution plan based on the query_plan_hash
SELECT QueryPlanHash,
CASE WHEN QueryType LIKE '%Stored Procedure%' THEN
QueryPlan.value('declare namespace p="http://schemas.microsoft.com/sqlserver/2004/07/showplan";
sum(//p:StmtSimple/@StatementSubTreeCost)', 'float')
ELSE
QueryPlan.value('declare namespace p="http://schemas.microsoft.com/sqlserver/2004/07/showplan";
sum(//p:StmtSimple[xs:hexBinary(substring(@QueryPlanHash, 3)) = xs:hexBinary(sql:column("QueryPlanHash"))]/@StatementSubTreeCost)', 'float')
END AS cost, *
FROM #procs