Skip to content

Instantly share code, notes, and snippets.

View ElanHasson's full-sized avatar
💥
Building Stuff

Elan Hasson ElanHasson

💥
Building Stuff
View GitHub Profile
@mikepugh
mikepugh / TfvcTemplate.12.WithChaining.xaml
Last active August 29, 2015 13:57 — forked from jstangroome/TfvcTemplate.12.WithChaining.xaml
Modify the chained build template to only execute the chained builds if unit tests passed.
<Activity x:Class="TfsBuild.Process" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mt="clr-namespace:Microsoft.TeamFoundation;assembly=Microsoft.TeamFoundation.Common" xmlns:mtbc="clr-namespace:Microsoft.TeamFoundation.Build.Client;assembly=Microsoft.TeamFoundation.Build.Client" xmlns:mtbco="clr-namespace:Microsoft.TeamFoundation.Build.Common;assembly=Microsoft.TeamFoundation.Build.Common" xmlns:mtbw="clr-namespace:Microsoft.TeamFoundation.Build.Workflow;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtba="clr-namespace:Microsoft.TeamFoundation.Build.Activities;assembly=Microsoft.TeamFoundation.Build.Activities" xmlns:mtbac="clr-namespace:Microsoft.TeamFoundation.Build.Activities.Core;assembly=Microsoft.TeamFoundation.Build.Activities" xmlns:mtbag="clr-namespace:Microsoft.TeamFound
@clemensv
clemensv / gist:9953010
Last active January 3, 2017 14:11
However often you call me, I'm only going to flush every 200msec from the first flush call
Task flushingTask = null;
public override Task FlushAsync(CancellationToken cancellationToken)
{
Interlocked.CompareExchange(
ref flushingTask,
Task.Delay(200, cancellationToken).ContinueWith(
async (t) =>
{
await write.FlushAsync(cancellationToken);
@ctgswallow
ctgswallow / gist:3409231
Created August 20, 2012 23:27
Create a template within a ruby block
ruby_block "create ssh key" do
block do
k = SSHKey.generate(:type => 'RSA', :bits => 1024, :comment => "Postgres Master")
node.set[:postgresql][:pubkey] = k.ssh_public_key
node.save
# Much of the DSL disappears in ruby blocks. Here's how to create a template.
rc = Chef::RunContext.new(node, node.cookbook_collection)
t = Chef::Resource::Template.new "/var/lib/postgresql/.ssh/id_rsa"
t.source("id_rsa.erb")
@jpluimers
jpluimers / get-msbuildExe-path.bat
Last active March 2, 2019 22:26
Get the path to the most recent msbuild.exe from the registry.
@echo off
:: http://stackoverflow.com/questions/328017/path-to-msbuild
:: http://www.csharp411.com/where-to-find-msbuild-exe/
:: http://timrayburn.net/blog/visual-studio-2013-and-msbuild/
:: http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx
setlocal
:vswhereModernTry
:: https://github.com/Microsoft/vswhere/wiki/Find-MSBuild
:: Normal output example of `vswhere -legacy -latest -property installationPath` has no trailing back-slash:
@HellBrick
HellBrick / Program.cs
Created November 3, 2015 21:07
Roslyn analyzer test console
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HellBrick.Diagnostics.UnusedReferences;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.MSBuild;
public class DistributedMutex {
private readonly string key;
private readonly string storageConnectionString;
private readonly string storageContainerName;
private CloudBlobClient blobClient;
private string leaseId;
public DistributedMutex(string storageConnectionString, string storageContainerName, string key)
{
this.key = key;
@codingoutloud
codingoutloud / BlobSemaphore.cs
Created February 13, 2013 20:02
Use Windows Azure Blob to create a semaphore spanning the cloud.
// intended to be called only ONCE in real installations - or for a clean test run when no Jobs container exists
public static void GloballyInitializeJobManager(bool quiet)
{
var blobContainer = AzureStorageAccess.GetBlobContainer(JobContainerName);
bool didNotExistCreated = blobContainer.CreateIfNotExist();
if (!quiet) System.Diagnostics.Debug.Assert(didNotExistCreated); // else, we probably should not be calling this method
var blob = blobContainer.GetBlobReference(JobGlobalJobIdSequencePath);
if (!blob.Exists())
{
blob.UploadText(JobGlobalJobIdSequenceStartingValue);
@stefanteixeira
stefanteixeira / EnableTCPSQLServer.ps1
Created August 25, 2015 20:02
PowerShell script to enable TCP in SQL Server
Import-Module "sqlps"
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer').
# List the object properties, including the instance names.
$Wmi
# Enable the TCP protocol on the default instance.
$uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Tcp']"
$Tcp = $wmi.GetSmoObject($uri)
@benfoster
benfoster / gist:4416655
Last active June 19, 2021 18:32
A lightweight message bus using TPL DataFlow
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
namespace TDFDemo
{
class Program
{
package main
import (
"fmt"
"time"
"sync"
)
func main() {
wg := &sync.WaitGroup{}