Skip to content

Instantly share code, notes, and snippets.

View vcsjones's full-sized avatar
㊙️

Kevin Jones vcsjones

㊙️
View GitHub Profile
$URI = "https://myserver/webservices/sswebservice.asmx" #The URI of the webservice
$templateName = "File Storage" #The name of the secret template we are going to use.
$username = "myusername"
$domain = "" #Leave empty if you aren't using domain accounts
$password = "mypassword"
$organizationCode = "" #Leave empty unless you are using Secret Server Online
$pathToFile = "C:\Users\My Account\Desktop\input.txt" #The path to the file we are going to upload.
$maxFieldSize = 1991
$secretName = "My New File 2"
using System.Threading;
using System.Windows;
using System.Windows.Threading;
namespace BorderTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
// Written for .NET 3.5.
[DataContract]
public class JSONObject
{
/// <summary>
/// This is how you can escape a keyword as an identifier.
/// </summary>
[DataMember]
public string @public
{
@vcsjones
vcsjones / IoC.cs
Created November 26, 2010 01:03
WP7 IoC
public static partial class IoC
{
private static readonly Dictionary<Type, Type> _registration = new Dictionary<Type, Type>();
private static readonly Dictionary<Type, object> _rot = new Dictionary<Type, object>();
private static readonly object[] _emptyArguments = new object[0];
private static readonly object _syncLock = new object();
static partial void RegisterAll();
static IoC()
@vcsjones
vcsjones / gist:718189
Created November 27, 2010 19:24
WP7 Zip
//Throws exception if number of items in the collection are different.
public static IEnumerable<R> Zip<T, U, R>(this IEnumerable<T> first, IEnumerable<U> second, Func<T, U, R> selector)
{
var enumerator1 = first.GetEnumerator();
var enumerator2 = second.GetEnumerator();
while (true)
{
var move1 = enumerator1.MoveNext();
var move2 = enumerator2.MoveNext();
if (move1 != move2)
public static void SafeInvoke(this Action act)
{
if (act != null)
{
act();
}
}
@vcsjones
vcsjones / gist:724486
Created December 2, 2010 00:00
CaptainHook Example
public class RequireTargetProcessNumber : PreCommitHook
{
protected override bool HandleHookEvent(ITransactionInfo commit)
{
string commitMessage = commit.LogMessage;
if (!HasTargetProcessNumber(commitMessage))
{
this.Context.Output.WriteError("TargetProcess Number was not specified in commit message.");
return false;
}
@vcsjones
vcsjones / gist:1108373
Created July 26, 2011 23:39
NHibernate 3 Query
ISession mySession = //Get your session object.
var myUsers = from user in mySession.Query<User>() where user.Name == "Kevin" select user;
using (var timer = new System.Timers.Timer(2){AutoReset = false, Enabled = false})
{
using (var latch = new ManualResetEventSlim(false))
{
timer.Elapsed += (a, o) => latch.Set();
timer.Start();
latch.Wait();
}
}
class Program
{
static void Main(string[] args)
{
var foo = (MyType<string>) "cat";
}
}
public class MyType<t>
{