Skip to content

Instantly share code, notes, and snippets.

View csdear's full-sized avatar

Stuart Dear csdear

View GitHub Profile
@csdear
csdear / HTTP : Get HTTP StatusCode Response Description
Created October 29, 2014 15:17
HTTP : Get HTTP StatusCode Response Description. Params : HTTP url string Method returns the the HTTP StatusCode Description e.g. 'OK'
public String GetHttpResponse(string url)
{
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("http://" + url);
//webRequest.AllowAutoRedirect = false;
HttpWebResponse response = (HttpWebResponse) webRequest.GetResponse();
response.Close();
return response.StatusCode.ToString();
}
@csdear
csdear / CSV to List - Console
Last active August 29, 2015 14:07
.CSV to List Collection using StreamReader. Simple console demo, outputs contents of list to the console. e.g., 1 on the subject of StreamReader to List
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace CONSOLE
{
class MainLoader
{
@csdear
csdear / Try Catch Basic
Created October 7, 2014 14:13
Try / Catch Basic : A try block with a StreamReader statement that opens a data file called data.txt and writes a string from the file. Following the try block is a catch block that catches any exception that results from the try block.
// This will throw a 'System.IO.FileNotFoundException'
public class ProcessFile
{
public static void Main()
{
try
{
StreamReader sr = File.OpenText("data.txt");
Console.WriteLine("The first line of this file is {0}", sr.ReadLine());
sr.Close();
@csdear
csdear / Update and or Replace.sql
Last active March 17, 2016 19:22
SQL UPDATE / Replace 1. simple update of values #2. Wildcard to replace LIKE values #3. Dealing with the common datatype 'ntext' error #4 Simple Update and replace. Find the oldstring, insert this new string... # 5. Clone values of column x to column y 6. Gotcha multiple updates you dummy
--Updating values - simple
-- SET is the column name(s), and the new values
-- Include where statement to target a specific row
--1. simple update of values
Update dbo.dealers
SET latitude='34.000854', longitude='-81.099379'
WHERE dealer_code = '39054'
***
@csdear
csdear / sqlWildCard_LIKE_.sql
Created May 16, 2014 13:40
SQL LIKE Pattern and Wildcards A. Table Reference B. Where COLUMN NAME C. LIKE '20%' . Percent sign is the wildcard. E.g., '%20', '20%', '%camry% D. OR column name. If you want to search for the pattern in additional columns.
***
SELECT * FROM seo_templates
WHERE main_copy LIKE '20%'
OR page_title LIKE '20%'
***