Skip to content

Instantly share code, notes, and snippets.

;config.ini
[Network]
DataFeed=http://mydomain.com/feed.xml
Port=68
NextUpdate=3/23/2009 9:11:48 PM
You can load it:
var configurationSource = new IniConfigurationSource("config.ini");
var datafeed = configurationSource.Sections["Network"].Get<string>("DataFeed");
@idavis
idavis / SecurityTest.txt
Created May 16, 2011 20:50
Executing scripts while script execution is disabled
PS C:\Development\PowerStudio> set-executionpolicy default
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution
policy might expose you to the security risks described in the about_Execution_Policies help topic.
Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
PS C:\Development\PowerStudio> type .\test.ps1
gci
PS C:\Development\PowerStudio> .\test.ps1
@idavis
idavis / Models.cs
Created July 6, 2011 22:33
Inverse null coalescing 'operator' support. Only properties are allowed.
#region Using Directives
using System.Threading;
#endregion
namespace ObjectExtensions.Tests
{
public class Person
{
@idavis
idavis / gist:1303952
Created October 21, 2011 14:13
If have the values...or not
// Variable names have been changed to protect the guilty. Class and method names are real.
//If have the values, set foo and bar
if (!false)
{
CommonFunctions.SetFieldValue(row, "foo", foo);
}
if (!false)
{
var codingMusic = from music in AllMusic
where !music.ContainsGrowling
where ( !music.IsInEnglish || music.HasNoLyrics )
where music.Genres.Contains( "Metal", "FolkMetal" )
where HasTalent( music.Artist )
select music;
@idavis
idavis / Settings.cs
Created November 13, 2011 05:05
settings example
// pulls the values from the configuration file
// you can have a separate config file per env
// Environment is a value set in the config file that ConfigurationBase uses to determine default values with the Default() method.
public class ServicesConfig : ConfigurationBase
{
public Uri WebServer
{
get { return Get(()=> WebServer, Default("DevDefault", "TestDefault", "ProdDefault")); }
}
@idavis
idavis / after.ps
Created November 28, 2011 17:55
Still needs work, but which is more readable
function Get-XADUserPasswordExpirationDate {
param ([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, HelpMessage="Identity of the Account")]
$accountIdentity)
$accountObj = Get-ADUser $accountIdentity -properties PasswordExpired, PasswordNeverExpires, PasswordLastSet
if ($accountObj.PasswordExpired) {
Write-Host ("Password of account: $($accountObj.Name) already expired!")
return
}
@idavis
idavis / UnitCircleSampler.cs
Created February 12, 2012 22:31
Generate Random Points Within a Unit Circle
public void Sample()
{
for ( int i = 0; i < 100; i++ )
{
Console.WriteLine(Locator.GetLocationNear());
}
}
using System;
@idavis
idavis / .autotest
Created February 14, 2012 16:56
Config settings for continuous js testing
require 'autotest/growl'
require 'autotest/fsevent' if RUBY_PLATFORM =~ /darwin/
@idavis
idavis / fubar.nuspec
Created March 6, 2012 02:02
Tools scripts do not work unless ANSI encoded
<?xml version="1.0"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Issue1949</id>
<version>0.2.2</version>
<authors>Ian Davis</authors>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<licenseUrl>https://raw.github.com/idavis/Toji/master/LICENSE.txt</licenseUrl>
<description>Toji is a bootstrapping project for setting up psake builds.</description>
<summary>Custom brewed psake goodness</summary>