Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am xcud on github.
* I am xcud (https://keybase.io/xcud) on keybase.
* I have a public key whose fingerprint is 3639 68AF 7B4C 85CA 8188 6F73 AFAE A77A 020D FE73
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am xcud on github.
  • I am xcud (https://keybase.io/xcud) on keybase.
  • I have a public key whose fingerprint is 7BA8 6448 F6D1 3723 C179 A1E8 B6D3 B627 C518 10F7

To claim this, I am signing this object:

@xcud
xcud / lessons-learned.md
Last active August 17, 2017 03:02
Lessons Learned by Eric Schmidt transcribed by Abheek Anand

Lessons Learned – The Hard Way Eric Schmidt, E&VC Final Class Transcribed by Abheek Anand

About Management Culture:

  • You get personal leverage through delegation and empowerment, along with inspection
  • Hiring defines a company. Review every job offer every time.
  • Manager (or teams reporting to a manager) should never have the unilateral authority to hire people.
  • Major decisions should be made in large groups, by two joint owners.
  • Be careful about goal-misalignment; goaling drives behavior and conflict.
@xcud
xcud / IsImage
Created January 29, 2015 06:55
Quickly determine whether a given path is an image
public static bool IsImage(string path)
{
Dictionary<string, string[]> knownImageHeaders = new Dictionary<string, string[]>()
{
{"jpg", new [] { "FF", "D8" } },
{"bmp", new [] { "42", "4D" } },
{"gif", new [] { "47", "49", "46" } },
{"tif", new [] { "49", "49", "2A" } },
{"png", new [] { "89", "50", "4E", "47", "0D", "0A", "1A", "0A" } },
};
@xcud
xcud / Get-Rights.ps1
Last active August 29, 2015 14:09
Get-Rights
$source = @"
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using System.Collections.Generic;
public static class ADPermissions {
public static string[] EnumRights()
{
@xcud
xcud / AttributeOptionSet.cs
Created April 16, 2013 20:59
Extends Mono.Options, a better command line parser.
using System;
using System.Linq;
using Mono.Options;
namespace xcud
{
public class AttributedOptionSet : OptionSet
{
public static T Parse<T>(string[] args) where T : AttributedOptionSet, new()
{
@xcud
xcud / DynamicWebServiceProxy.cs
Created February 22, 2013 16:10
I'm spoiled by PowerShell's New-WebServiceProxy. I want to poke around at a WCF but I don't want to precompile a WSDL, or add a service reference, or include a contract interface that'll break on compile when it changes. Let me just interact with the web services reflectively like I do in PowerShell. The performance profile is terrible. It does …
using System;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Reflection;
namespace Xcud.Net
{
/// <example>
/// DynamicWebServiceProxy proxy = new DynamicWebServiceProxy(uri);
@xcud
xcud / Implement-Verbose.ps1
Last active December 13, 2015 19:18
Demonstrate built-in Verbose support
<#
.Synopsis
Demonstrate built-in Verbose support
.Example
PS> Correct-Example -Verbose
VERBOSE: This works
PS> Incorrect-Example -Verbose
PS> Incorrect-Example2 -Verbose
@xcud
xcud / Get-Content.ps1
Created February 14, 2013 19:15
Extend Get-Content to include a -Fast parameter; much less flexible but much more performant
<#
.Synopsis
Extend Get-Content to include a -Fast parameter; much less flexible but more performant
.Example
PS> (Measure-Command { Get-Content .\data.xml} ).TotalMilliseconds
1609.3267
PS> (Measure-Command { Get-Content .\data.xml -Fast} ).TotalMilliseconds
39.2511
#>
@xcud
xcud / Out-PDF.ps1
Created February 7, 2013 21:41
Writes a string to a PDF via Microsoft Word automation
<#
.Synopsis
Writes a string to a PDF via Microsoft Word automation
.Example
PS> ps | out-string | out-pdf -Path ".\processes.pdf"
#>
function Out-PDF() {
param(
[Parameter(Mandatory=$True, Position=0, ValueFromPipeline=$true)] $Text,