Skip to content

Instantly share code, notes, and snippets.

View justinAurand's full-sized avatar
👋
Probably coding...

Justin Aurand justinAurand

👋
Probably coding...
View GitHub Profile
@justinAurand
justinAurand / RegexOnPDF.cs
Last active December 21, 2015 10:59
Run regex on PDF file. Return results to console.
// Credit: http://stackoverflow.com/questions/17601176/read-a-pdf-and-find-a-specific-column-to-add-to-a-list
// You'll need to download the iTextSharp dll and add a reference to it.
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
@justinAurand
justinAurand / PancakeSort.cs
Last active December 21, 2015 10:59
Pancake sort w/ coded array reversals.
using System;
class PancakeSort
{
public static void Main(string[] args)
{
// Make sure console arguments have been entered.
if (args.Length <= 0)
{
Console.WriteLine("You must enter at least one string to pancake sort.");
@justinAurand
justinAurand / FindFirstDuplicate.cs
Last active December 21, 2015 23:29
Find and return first duplicate in a generic list.
using System;
using System.Collections.Generic;
using System.Collections;
class FindFirstDuplicate
{
public static void Main()
{
var input = new List<string> { "Foo", "Bar", "Bar", "Foo" };
object result = GetFirstDuplicateValue(input);
@justinAurand
justinAurand / SerializeIntoXML.cs
Last active December 24, 2015 14:09
Takes an object and serializes it into XML.
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
// Serialize data object into Xml format.
public StringWriter Serialize<T>(T data)
{
@justinAurand
justinAurand / IndentXml.cs
Last active December 25, 2015 19:59
Format a document XML for readability.
using System.IO;
using System.Text;
using System.Xml;
class IndentXml
{
public static void Main()
{
var xmlDocument = new XmlDocument();
xmlDocument.Load(@"C:\Original.xml");
@justinAurand
justinAurand / GetAttributeValues.cs
Last active December 26, 2015 10:39
Get XML and/or HTML from file. Return the values of the supplied attribute name.
using System;
using System.IO;
using System.Text.RegularExpressions;
class GetAttributeValues
{
public static void Main()
{
// Program settings (at top for convenience since they're most likely to be modified).
string attributeName = "name";
@justinAurand
justinAurand / BasicClass.cs
Last active December 27, 2015 02:09
Basic Class. Keeping SpoonDaddyOBC's brain fresh. So fresh and so clean, clean!
public class ResponseData
{
#region Fields
private int statusCode;
private string responseStream;
#endregion
#region Accessors
public int StatusCode
{
@justinAurand
justinAurand / TextTransfer.cs
Last active December 28, 2015 21:39
Transfer text, line by line, from one text file to another. Good for programmatic text manipulation.
using System;
using System.IO;
class TextTransfer
{
static void Main()
{
const string ReadingFilePath = @"C:\stuff.txt";
const string WritingFilePath = @"C:\stuff2.txt";
const bool AppendToFile = false;
@justinAurand
justinAurand / CountIncrementTraversals.cs
Created January 15, 2014 06:15
Count the number of increments traversed while opening a combination lock. Challenge link: http://www.reddit.com/r/dailyprogrammer/comments/1v4cjd/011314_challenge_148_easy_combination_lock/
using System;
class Program
{
static void Main(string[] args)
{
#region Argument Count / Data Type Validation
// Check for valid number of command line arguments.
if (args == null || args.Length != 4)
{
@justinAurand
justinAurand / LinqNullChecks.cs
Last active August 29, 2015 13:57
Demonstrating LINQ query with 1) check for null list, 2) check for null list items, and 3) check for null property before querying on it.
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication
{
class Program
{
static void Main()
{