Skip to content

Instantly share code, notes, and snippets.

@jpoehls
jpoehls / Kill-VisualStudio.ps1
Created May 31, 2012 17:01
Kill-VisualStudio powershell function
function Kill-VisualStudio
{
<#
.SYNOPSIS
Kills all running 'devenv' instances.
#>
Get-Process devenv -ErrorAction SilentlyContinue | Stop-Process
}
Set-Alias killvs Kill-VisualStudio
@jpoehls
jpoehls / exec.ps1
Created May 31, 2012 14:25
PowerShell Exec function from psake
# Taken from psake https://github.com/psake/psake
<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
@jpoehls
jpoehls / gist:2831568
Created May 30, 2012 00:05
Find the <form/> that contains jQuery element
var $form = $('.item').closest('form');
@jpoehls
jpoehls / gist:2828914
Created May 29, 2012 15:00
Handling a row click in SlickGrid
var grid = new Slick.Grid(...);
grid.onClick.subscribe(function (e, args) {
// args:
// - cell
// - grid
// - row
var dataItem = args.grid.getDataItem(args.row);
@jpoehls
jpoehls / xpath-example.ps1
Created May 18, 2012 18:44
Use XPath to update XML using PowerShell
function Edit-XmlNodes {
param (
[xml] $doc = $(throw "doc is a required parameter"),
[string] $xpath = $(throw "xpath is a required parameter"),
[string] $value = $(throw "value is a required parameter"),
[bool] $condition = $true
)
if ($condition -eq $true) {
$nodes = $doc.SelectNodes($xpath)
@jpoehls
jpoehls / gist:2709843
Created May 16, 2012 12:04
jabbr.rpxnow.com/signin/get_login_info
{
"startedDateTime": "2012-05-16T11:57:32.161Z",
"time": 94,
"request": {
"method": "GET",
"url": "https://jabbr.rpxnow.com/signin/get_login_info?time=1337169452162",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept-Encoding",
@jpoehls
jpoehls / master.xml
Created May 4, 2012 18:49
NewsBlur Github feed snippets
<!-- https://github.com/samuelclay/NewsBlur/commits/master.atom -->
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US">
<id>tag:github.com,2008:/samuelclay/NewsBlur/commits/master</id>
<link type="text/html" rel="alternate" href="https://github.com/samuelclay/NewsBlur/commits/master"/>
<link type="application/atom+xml" rel="self" href="https://github.com/samuelclay/NewsBlur/commits/master.atom"/>
<title>Recent Commits to NewsBlur:master</title>
<updated>2012-05-03T19:09:36-07:00</updated>
<entry>
@jpoehls
jpoehls / encoding-helpers.ps1
Created April 17, 2012 14:54
Convert-FileEncoding and Get-FileEncoding
<#
.SYNOPSIS
Converts files to the given encoding.
Matches the include pattern recursively under the given path.
.EXAMPLE
Convert-FileEncoding -Include *.js -Path scripts -Encoding UTF8
#>
function Convert-FileEncoding([string]$Include, [string]$Path, [string]$Encoding='UTF8') {
$count = 0
@jpoehls
jpoehls / csharp.cs
Created March 30, 2012 19:46
Magic String Anti-Pattern
public class Person : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
@jpoehls
jpoehls / duplicate-const-values-with-iota.go
Created March 30, 2012 13:41
Duplicate const values in #golang with iota
package main
import "fmt"
// iota is reset to 0 at every const declaration
const (
Zero = iota // within a const declaration, iota is incremented for every line
One // default value is set to iota, which is now 1
Two = 2 // exlicitly set to 2
TwoAgain // default value is set to iota, which is now 2 creating a duplicate 2