Skip to content

Instantly share code, notes, and snippets.

@breezhang
breezhang / shortcut.cs
Created April 10, 2012 17:46
shortcut MG
typedef enum {
ssfALTSTARTUP = 0x1d,
ssfAPPDATA = 0x1a,
ssfBITBUCKET = 0x0a,
ssfCOMMONALTSTARTUP = 0x1e,
ssfCOMMONAPPDATA = 0x23,
ssfCOMMONDESKTOPDIR = 0x19,
ssfCOMMONFAVORITES = 0x1f,
ssfCOMMONPROGRAMS = 0x17,
ssfCOMMONSTARTMENU = 0x16,
Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.
Package Manager Console Host Version 2.0.30619.9119
Type 'get-help NuGet' to see all available NuGet commands.
PM>
Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.
Package Manager Console Host Version 2.0.30619.9119
Type 'get-help NuGet' to see all available NuGet commands.
PM>
@breezhang
breezhang / Sample codeDOM API
Created August 21, 2012 11:52
Using CodeDOM to generate CSharp (C#) and VB code
//Copy from [email protected] 15 Aug 2006 8:29 PM
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using Microsoft.VisualBasic;
using System.IO;
namespace ConsoleApplication1
{
@breezhang
breezhang / snippet Dispose.cs
Created August 22, 2012 23:51
Implementing a Dispose Method
copy from http://msdn.microsoft.com/en-us/library/fs2xkftw(v=vs.110)
using System;
using System.IO;
class Program
{
static void Main()
{
try
@breezhang
breezhang / ExampleModel.cs
Created August 29, 2012 02:07 — forked from DalSoft/ExampleModel.cs
ASP.NET MVC 3 - Improved JsonValueProviderFactory using Json.Net
//Example of a model that won't work with the current JsonValueProviderFactory but will work with JsonDotNetValueProviderFactory
public class CmsViewModel
{
public bool IsVisible { get; set; }
public string Content { get; set; }
public DateTime Modified { get; set; }
public DateTime Created { get; set; }
//This property will not work with the current JsonValueProviderFactory
public dynamic UserDefined { get; set; }
}
@breezhang
breezhang / gist:3520891
Created August 30, 2012 00:21
read Multi-Valued Property

powershell

check some object Property just show one two three ... you want see all values just code

stuff |Select-Object –ExpandProperty YouwantProperty

@breezhang
breezhang / gist:3523645
Created August 30, 2012 07:14 — forked from nickfloyd/gist:1046526
Powershell basic authentication
//This returns a 404 not found - powershell; I expected a 401 if my creds were bad
$Url = "https://github.com/api/v2/xml/commits/list/fellowshiptech/portal/Portal_2011.6.23_15-26"
$webclient = new-object system.net.webclient
$webclient.credentials = new-object system.net.networkcredential("user", "password")
$result = $webclient.DownloadString($Url)
$result
//This returns the data I want via terminal
curl -u user:password https://github.com/api/v2/xml/commits/list/fellowshiptech/portal/Portal_2011.6.23_15-26
@breezhang
breezhang / gistdiff.ps1
Created August 30, 2012 07:33 — forked from timheuer/gistdiff.ps1
My hack start at creating a script for auto-submitting a diff to gist.github.com
# ask the user for a gist name
param (
[string]$gistname = "$(Read-Host 'Enter a name for the gist')"
)
# constant
$gistapi = "https://api.github.com/gists"
$filename = $gistname + '.diff'
$teststring = "`{`"description`": `"the description for this gist`",`"public`": true,`"files`": `{`"file1.txt`": `{`"content`": `"String file contents`"`}`}`}"
# get the diff from the current session
function Get-ChildItemColor {
<#
.Synopsis
Returns childitems with colors by type.
.Description
This function wraps Get-ChildItem and tries to output the results
color-coded by type:
Compressed - Yellow
Directories - Dark Cyan