Skip to content

Instantly share code, notes, and snippets.

@jdhuntx
jdhuntx / JsonpFormatter.cs
Created June 21, 2012 18:21
JSONP MediaTypeFormatter for ASP.NET Web API Release Candidate
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
@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
Function Test-Url {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String] $Url
)
Process {
if ([system.uri]::IsWellFormedUriString($Url,[System.UriKind]::Absolute)) {
$true
@coolya
coolya / gist:1fccef3591086bd7ba7d
Last active August 29, 2015 14:04
High Performance Loggin
using logv.http;
using logv.ws.core;
using System;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using MongoDB.Bson;
using logv.ws.core.data;
namespace logv.host
{
@clemensv
clemensv / gist:639f832e5151482054f8
Last active August 29, 2015 14:06
"alias" classes in C# ?!
Thought experiment:
Listened to eight .NET Rocks episodes yesterday while driving. One episode was about C# 6.0 with Bill Wagner
(http://www.dotnetrocks.com/default.aspx?showNum=1029), another about DDD with Steve Smith and Julie Lerman
(http://www.dotnetrocks.com/default.aspx?showNum=1023) where they specifically also discussed DDD's notion of
an anti-corruption layer, which aims to provide a neutral zone between different domains. The combination of
the two episodes gave me the following idea which I'll jot down here quickly.
Don't go "you dont do that in DDD, because .." since that's not the point. The point is efficiency and avoiding
data copies. Also, I'm not planning on doing anything further with it, so if anyone wants to take this somewhere,
@dfinke
dfinke / CFSBuddy.ps1
Created September 17, 2014 14:37
PowerShell v5.0 ConvertFrom-String Buddy - A GUI that helps you work with this new powerful cmdlet
#Requires -Version 5.0.9814.0
if(!($PSVersionTable.PSVersion.Major -ge 5 -and $PSVersionTable.PSVersion.Build -ge 9814)) {
"Sorry you need PSVersion 5.0.9814.0 or newer"
$psversiontable
return
}
Add-Type -AssemblyName presentationframework
# Original author Mark Renoden (http://au.linkedin.com/in/markrenoden)
Get-AzureVM |
ForEach-Object {
$vm = $_.name;
Write-Output "$vm VM Properties";
Write-Output "---------------";
Format-List -InputObject $_ -Property *;
Write-Output "$vm VM Endpoints";
Write-Output "---------------" ;
@sdesalas
sdesalas / TwitterClient.cs
Last active May 26, 2023 03:34
An ultra-lightweight Twitter client in C# using OAuth
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;
using System.Linq;
using System.Text.RegularExpressions;
using System.Net;
using System.Web;
@davemackintosh
davemackintosh / long-runner-progress-nice.js
Last active August 29, 2015 14:10
Mongo database currentOp() helper. Makes it a bit nicer
db.currentOp().inprog.forEach(function(op) {
if (op.progress) {
var remaining = op.progress.total - op.progress.done;
var running_for = op.secs_running / 60 / 60;
print(op.ns, op.opid, 'running for', running_for.toPrecision(4), 'hours')
print('job "'+ op.insert.name +'" running in background?', op.insert.background ? 'yes' : 'no');
print(op.msg)
print('Remaining records', remaining, 'finished', op.progress.done, 'docs')
print('Estimated', ((running_for / op.progress.done) * remaining).toPrecision(4), 'hours remaining')
@sdieunidou
sdieunidou / rabbitmq.txt
Created October 22, 2015 19:51
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"