Skip to content

Instantly share code, notes, and snippets.

@bradjolicoeur
bradjolicoeur / RandomHelper.cs
Created March 28, 2019 15:54
Extension method that creates a random negative or positive value
using System;
namespace GenerateLatLon.Helpers
{
public static class RandomHelper
{
public static int NegativePositive(this Random r)
{
int iNum;
@bradjolicoeur
bradjolicoeur / Split
Created May 11, 2015 19:04
Function for splitting a delimited and qualified string (CSV)
public string[] Split(string line, string qualifier, string delimiter)
{
bool qualifierState = false;
int startIndex = 0;
List values = new List();
//split the line into a character array so we can parse the line and take text qualifiers into consideration
char[] items = line.ToCharArray();
@bradjolicoeur
bradjolicoeur / gist:e77c508089aea6614af3
Created August 8, 2014 20:15
Powershell Script to Increment Build Number in AssemblyInfo.cs
#
# This script will increment the build number in an AssemblyInfo.cs file
#
$assemblyInfoPath = "C:\Data\Temp\AssemblyInfo.cs"
$contents = [System.IO.File]::ReadAllText($assemblyInfoPath)
$versionString = [RegEx]::Match($contents,"(AssemblyFileVersion\("")(?:\d+\.\d+\.\d+\.\d+)(""\))")
Write-Host ("AssemblyFileVersion: " +$versionString)
@bradjolicoeur
bradjolicoeur / gist:9918928
Created April 1, 2014 17:29
Oracle script to code gen an insert statement for an existing table.
with col as (
select atc.column_name, atc.data_type, atc.data_length, atc.nullable, atc.table_name from all_tab_cols atc
where table_name = '[table name here]'
order by column_id)
select distinct 'insert into ' || lower(table_name) ||' (' from col
union all
select case when rownum != 1 then ', ' || lower(column_name) else lower(column_name) end from col
union all
select ') values (' from dual
union all
@bradjolicoeur
bradjolicoeur / FileHelper.cs
Last active August 29, 2015 13:55
File Helper for working with files...will add more methods in the future.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
public static class FileHelper
{
/// <summary>
@bradjolicoeur
bradjolicoeur / SerializationHelper.cs
Created January 30, 2014 14:51
Serialization Helper
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
@bradjolicoeur
bradjolicoeur / ScriptEngine.cs
Last active November 30, 2019 16:17
Csharp Dynamic Script Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.CSharp;
public class ScriptEngine