Skip to content

Instantly share code, notes, and snippets.

View StevenMcD's full-sized avatar

Steven McDonald StevenMcD

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
namespace ConsoleApplication2
{
class Program
public static List<string> GetColumnHeadings()
{
List<string> ColumnHeadings = new List<string>();
StreamReader rawFile = new StreamReader(@"filePath");
string stringFile = rawFile.ReadToEnd();
////
//// Split the rows into an array
////
@StevenMcD
StevenMcD / Table Results scrape - Powershell.ps
Created January 14, 2011 14:57
scrape table results from page
cls
$comics = @()
foreach($number in 1..25){
   $page = (new-object System.Net.Webclient).DownloadString("http://www.awx.co.za/e107_plugins/shop/show_cat.php?lettersort=B&catpath=64/Comics&page=$number")
   $startIndex = $page.IndexOf("main_section")
   $startIndex = $page.IndexOf("main_section",$startIndex + 20)
@StevenMcD
StevenMcD / SQLStripHTML.sql
Created February 17, 2011 11:41
SQL StripHTML from String
CREATE FUNCTION StripHTMLTags(
@HTMLText VARCHAR(MAX)
) RETURNS VARCHAR(MAX)
AS
--=========================================================
-- Author : Steven McDonald
-- Date : 17 February 2011
-- Description : Removes all HTML tags from provided Text
-- Link : Original version - http://blog.sqlauthority.com/2007/06/16/sql-server-udf-user-defined-function-to-strip-html-parse-html-no-regular-expression/
--=========================================================
@StevenMcD
StevenMcD / node_directory_watcher.js
Created October 21, 2012 19:15
NodeJS directory watcher - basic monitor&move script
function Watcher(watchDir, processedDir){
this.watchDir = watchDir;
this.processedDir = processedDir;
};
var events = require('events');
Watcher.prototype = new events.EventEmitter();
var fs = require('fs'),
@StevenMcD
StevenMcD / node_sequential_tasking.js
Created October 21, 2012 19:41
NodeJS - Sequential tasking - Random RSS feed selector
var path = require('path'),
fs = require('fs'),
request = require('request'),
htmlparser = require('htmlparser'),
tasks = [];
function getRssFeeds(){
var configFileName = "./rss_feeds.txt";
path.exists(configFileName, function(exists){
if(!exists){
@StevenMcD
StevenMcD / node_parallel_tasking.js
Created October 21, 2012 20:14
NodeJS - Parallel Tasking - reading multiple files at once and counting word totals
var fs = require('fs'),
completedTasks = 0,
tasks = [],
wordCounts = {},
filesDir = './text';
function checkIfComplete(){
completedTasks++;
if(completedTasks == tasks.length){
for(var index in wordCounts){
@StevenMcD
StevenMcD / node_todo_http_verbs.js
Created October 27, 2012 21:52
NodeJS - Basic todo. More of a HTTP Verb handling exercise
var http = require('http'),
url = require('url'),
items = [],
server;
server = http.createServer(function(req, res){
switch(req.method){
case 'POST':
AddTodoItem(req, res, items);
break;
@StevenMcD
StevenMcD / Powershell_git_helpers.ps1
Created November 2, 2012 08:37
Powershell script with git helpers for work
Function pull {
git fetch origin
$part1 = git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
$part2 = git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 4
if($part2 -ne ""){
$branchName = $part1 + "/" + $part2
} else {
$branchName = $part1
}
@StevenMcD
StevenMcD / TeamCity_helperFunctions.ps1
Created November 3, 2012 20:20
TeamCity - Powershell Helper functions
#############################
# Mercilessly copied from https://github.com/kvarv/Continuous-Delivery
#############################
function TeamCity-TestSuiteStarted([string]$name) {
Write-Output "##teamcity[testSuiteStarted name='$name']"
}
function TeamCity-TestSuiteFinished([string]$name) {
Write-Output "##teamcity[testSuiteFinished name='$name']"