Skip to content

Instantly share code, notes, and snippets.

View robertgreiner's full-sized avatar

Robert Greiner robertgreiner

View GitHub Profile
using System;
using System.Text;
using System.Globalization;
namespace TimeManager{
class ParseDate{
static void Main(string[] args) {
/* Take a date in string format, and convert it to a DateTime object
This can be useful for parsing log files with unique date formats. */
/* using System.Net.Mail; */
function sendEmail(string name, string subject, string body) {
MailMessage newMail = new MailMessage();
newMail.To.Add(toAddress);
newMail.Subject = subject;
newMail.Body = body;
newMail.From = new MailAddress(fromAddress, name);
newMail.IsBodyHtml = true;
/**
* This is a proof of concept to show that it is possible to monitor a directory for changes.
*/
using System;
using System.Text;
using System.IO;
namespace FolderWatcher {
class Watcher {
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
class MailManager {
public void send(String subject, String body) {
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("name@domain.com");
message.Subject = subject;
message.From = new System.Net.Mail.MailAddress("name@domain.com");
message.Body = body;
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "host";
//using System.Net
private static string reverseUrl(string shortenedUrl) {
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(shortenedUrl);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Uri uri = response.ResponseUri;
return uri.AbsoluteUri;
}
@robertgreiner
robertgreiner / index.html
Created June 4, 2010 19:41
source code for searchstackoverflow.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search StackOverflow</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.gsc-control-cse {
font-family: Arial, sans-serif;
border-color: #FFFFFF;
background-color: #FFFFFF;
@robertgreiner
robertgreiner / PiDay.txt
Created February 23, 2011 21:59
Notes for pi day 3/14
http://en.wikipedia.org/wiki/Pi#Estimating_%CF%80
3.1415926535 8979323846 2643383279 5028841971 6939937510
5820974944 5923078164 0628620899 8628034825 3421170679 8214808651 3282306647 0938446095 5058223172 5359408128 4811174502 8410270193 8521105559 6446229489 5493038196 4428810975 6659334461 2847564823 3786783165 2712019091 4564856692 3460348610 4543266482 1339360726 0249141273 7245870066 0631558817 4881520920 9628292540 9171536436 7892590360 0113305305 4882046652 1384146951 9415116094 3305727036 5759591953 0921861173 8193261179 3105118548 0744623799 6274956735 1885752724 8912279381 8301194912 9833673362 4406566430 8602139494 6395224737 1907021798 6094370277 0539217176 2931767523 8467481846 7669405132 0005681271 4526356082 7785771342 7577896091 7363717872 1468440901 2249534301 4654958537 1050792279 6892589235 4201995611 2129021960 8640344181 5981362977 4771309960 5187072113 4999999837 2978049951 0597317328 1609631859 5024459455 3469083026 4252230825 3344685035 2619311881 7101000313 7838752886 5875332083 8
@robertgreiner
robertgreiner / LifeCycleEvents.cs
Created March 1, 2011 01:54
An example of the different lifecycle events an ASP .NET page goes through
namespace LifeCycleEvents {
public partial class Default : System.Web.UI.Page {
protected void Page_PreInit(object sender, EventArgs e) {
System.Diagnostics.Debug.WriteLine("Page_PreInit");
}
protected void Page_Init(object sender, EventArgs e) {
System.Diagnostics.Debug.WriteLine("Page_Init");
}
protected void Page_InitComplete(object sender, EventArgs e) {
System.Diagnostics.Debug.WriteLine("Page_InitComplete");
@robertgreiner
robertgreiner / index.html
Created June 14, 2011 12:42
jQuery skeleton
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery Example</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.6.1.min.js">
</script>
<script type="text/javascript">
//$(document).ready() is cross-browser