This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// test for localStorage support | |
if(('localStorage' in window) && window['localStorage'] !== null){ | |
var f = document.getElementById('mainform'); | |
// test with PHP if the form was sent (the submit button has the name "sent") | |
<?php if(isset($_POST['sent']))){?> | |
// get the HTML of the form and cache it in the property "state" | |
localStorage.setItem('state',f.innerHTML); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prompt { | |
write-host; | |
get-location | write-host; | |
if (isCurrentDirectoryGitRepository) { | |
$status = gitStatus | |
Write-Host('[') -nonewline -foregroundcolor Yellow | |
write-host $status["branch"] -nonewline -foregroundcolor Yellow; | |
if ($status["remote"] -ne ""){ | |
if ($status["behind"] -ne 0){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-FileEncoding($Path) { | |
$bytes = [byte[]](Get-Content $Path -Encoding byte -ReadCount 4 -TotalCount 4) | |
if(!$bytes) { return 'utf8' } | |
switch -regex ('{0:x2}{1:x2}{2:x2}{3:x2}' -f $bytes[0],$bytes[1],$bytes[2],$bytes[3]) { | |
'^efbbbf' { return 'utf8' } | |
'^2b2f76' { return 'utf7' } | |
'^fffe' { return 'unicode' } | |
'^feff' { return 'bigendianunicode' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class TrackXml { | |
[Test] | |
public void ShouldSerialiseKeyValuePairs() { | |
var xml = @"<track><title>Abracadabra</title><artist>Steve Miller Band</artist></track>"; | |
var track = new Track(); | |
track.Properties["title"] = "Abracadabra"; | |
track.Properties["artist"] = "Steve Miller Band"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> time { ping -n 1 google.com } -Samples 10 -Silent | |
.......... | |
Avg: 62.1674ms | |
Min: 56.9945ms | |
Max: 87.9602ms | |
PS> time { ping -n 1 google.com } -Samples 10 -Silent -Long | |
.......... | |
Avg: 00:00:00.0612480 | |
Min: 00:00:00.0572167 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET NOCOUNT ON | |
GO | |
PRINT 'Using Master database' | |
USE master | |
GO | |
PRINT 'Checking for the existence of this procedure' | |
IF (SELECT OBJECT_ID('sp_generate_inserts','P')) IS NOT NULL --means, the procedure already exists | |
BEGIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from http://www.simple-talk.com/sql/database-administration/automated-script-generation-with-powershell-and-smo/ | |
<# | |
.SYNOPSIS | |
Generate file-per-object scripts of specified server and database. | |
.DESCRIPTION | |
Generate file-per-object scripts of specified server and database to specified directory. Attempts to create specified directory if not found. | |
.PARAMETER ServerName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in desktop IE and metro IE - create a bookmark with the line below | |
javascript:document.location=("chrome2://"+document.location) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ObjectExtensions | |
{ | |
public static TReturn safe<T, TReturn>(this T testedObject, Func<T, TReturn> member, TReturn defaultValue = default(TReturn)) | |
where T : class | |
{ | |
return testedObject != null ? member(testedObject) : defaultValue; | |
} | |
} | |
// Usage example: |
OlderNewer