Skip to content

Instantly share code, notes, and snippets.

View derekgates's full-sized avatar

Derek Gates derekgates

View GitHub Profile
@DamianEdwards
DamianEdwards / MyHub.cs
Created July 31, 2013 23:51
Hub methods with progress support
public class MyHub : Hub
{
// The hub method must be Task returning and accept an IProgress<T>
public async Task DoLongRunningThing(IProgress<int> progress)
{
for (var i = 0; i <= 100; i+=5)
{
await Task.Delay(200);
progress.Report(i);
}
@aroben
aroben / pstree.ps1
Created May 8, 2013 18:34
Script to print a process tree on Windows
$ProcessesById = @{}
foreach ($Process in (Get-WMIObject -Class Win32_Process)) {
$ProcessesById[$Process.ProcessId] = $Process
}
$ProcessesWithoutParents = @()
$ProcessesByParent = @{}
foreach ($Pair in $ProcessesById.GetEnumerator()) {
$Process = $Pair.Value
@tkrotoff
tkrotoff / Log.cs
Created April 11, 2013 13:44
Enhancements for C# System.Diagnostics.Trace: add class and method names to the trace message
namespace Log
{
/// <summary>
/// Helps you trace the execution of your code.
/// </summary>
/// <remarks>
/// Same as System.Diagnostics.Trace but adds the class and method names to the trace message.<br/>
/// <br/>
/// More documentation about Trace and Debug:<br/>
/// <list type="bullet">
@ThomasArdal
ThomasArdal / gist:5132711
Created March 11, 2013 08:10
Remote creation of IIS websites.
$username = "insert_username_here"
$password = ConvertTo-SecureString "insert_password_here" -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$password
$session = New-PSSession "insert_hostname_here" -Credential $credential
Invoke-Command -Session $session -ScriptBlock {
Set-ExecutionPolicy RemoteSigned
Import-Module WebAdministration
New-Item iis:\Sites\%teamcity.build.branch%.insert_local_name_here -bindings @{protocol="http";bindingInformation=":80:%teamcity.build.branch%.insert_local_name_here"} -physicalPath c:\inetpub\wwwroot\%teamcity.build.branch%.insert_local_name_here
Set-ItemProperty 'IIS:\Sites\%teamcity.build.branch%.insert_local_name_here' ApplicationPool "ASP.NET v4.0"
@aras-p
aras-p / gist:5088284
Last active December 14, 2015 12:39
GfxDevice source sizes
Platform specific GfxDevice implementation source code size in Unity:
Direct3D 9 342k
Direct3D 11 446k, 146k of which fixed function emulation ;)
Flash Stage3D 147k
OpenGL 303k
OpenGL ES 1.1 140k
OpenGL ES 2.0 308k
PS3 libGCM 279k
Xbox 360 225k
@dotMorten
dotMorten / HttpGZipClientHandler.cs
Last active May 8, 2018 19:38
GZip support for PCL HttpClient. Create HttpClient using: HttpClient client = new HttpClient(new HttpGZipClientHandler());
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
namespace SharpGIS.Http
{
public class HttpGZipClientHandler : HttpClientHandler
{
@mmooney
mmooney / deploy.ps1
Last active December 11, 2015 03:39 — forked from srkirkland/deploy.ps1
#Modified and simplified version of https://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/
#From: #https://gist.github.com/3694398
$subscription = "[SubscriptionName]" #this the name from your .publishsettings file
$service = "[ServiceName]" #this is the name of the cloud service
$storageAccount = "[StorageAccountName]" #this is the name of the storage service
$slot = "production" #staging or production
$package = "[Fully Qualified Path to .cspkg]"
$configuration = "[Fully Qualified path to .cscfg]"
$publishSettingsFile = "[Path to .publishsettings file, relative is OK]"
$timeStampFormat = "g"

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?

@madrobby
madrobby / gist:4161897
Created November 28, 2012 15:16
Retina screen media query
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 144dpi),
(min-resolution: 1.5dppx) {
/* Retina rules! */
}
@yantonov
yantonov / hg2git.sh
Last active March 25, 2016 05:32
Creates git repo from mercurial repo using fast-export tool
#/bin/bash
# script creates git repo from hg (mercurial) repo using fast-export tool
tempDirectory="tmp-"`date +%s`
function get_working_directory_path() {
echo "/tmp/$tempDirectory"
}