Roy Ashbrook

let go or be dragged
posts - 198, comments - 29, trackbacks - 8


Generating a Date Dimension table in C#

I use a table similar to this quite frequently for my own personal reporting and analytics on various things. I figured I would polish it slightly and publish it in case anyone else needed it. =)

posted @ Monday, June 30, 2014 8:35 AM | Feedback (0) | Filed Under [ DEV ]

List Fields/Formfields data in a Word Document using C# and Microsoft.Office.Interop.Word

I have a set of documents I need to review regularly. They are *mostly* form data in word so I wanted to write a simple script to extract the data I need from all of the documents and put it into a table. I wasn't sure how to do this so I wrote a little script to iterate over the data in the document. The documents I review have several versions, different form fields, and other irregularities. I wanted to save a little script I wrote that uses various methods to iterate through the document. I use LINQPad regularly, so...

posted @ Wednesday, June 25, 2014 9:28 AM | Feedback (0) | Filed Under [ DEV ]

AppHarbor and dealing with annoying firewall rules. =P

A few days ago I was reading one of my usual news feeds The Daily WTF and saw Alex’s post (A (Long Overdue) BuildMaster Introduction) on their BuildMaster product. It looked pretty cool so I downloaded it myself and forwarded it to a colleague at another place of employment. Unfortunately for that individual their firewall policy prevents downloading .EXE files so they could not download any of the installs as they were all .EXE files. So firstly, I would recommend that anyone that wants to have their cool/nifty product downloaded by someone in a large corp should at least...

posted @ Thursday, April 4, 2013 11:30 AM | Feedback (0) | Filed Under [ DEV ]

Minecraft Password Recovery from lastlogin file

A few months ago my kids and I started up another round of playing Minecraft. The only issue was my daughter had forgotten her password and she lost the password to the email she registered it on and she couldn’t remember her questions etc to recover the password. So as I was looking for ways to recover her password I came across a way to recover it from the lastlogin file used by Minecraft if you check the ‘save password’ box, which she had done fortunately months previously when she last played. I used the Java code below and...

posted @ Wednesday, March 20, 2013 11:28 AM | Feedback (0) | Filed Under [ DEV ]

Setting the File DateTime properties

This is pretty much a no brainer for code. However I went and looked and everything I found was either overkill, or i wasn't certain of the internals so i had to say run it, look at the properties etc. So I wrote a simple app to do it and put it on codeplex at: This problem stemmed from the fact that I got this weird DVD player and I needed it to play some files from a USB stick in a loop. It loops fine, the problem was ordering. No clue how the ordering was. I thought it might...

posted @ Thursday, January 13, 2011 10:54 PM | Feedback (0) | Filed Under [ DEV ]

set transaction isolation level read only uncommitted in LINQ

apparently you can use a transaction scope for this and just wrap everything that way. but to me that seems more complicated than just enabling it with execute command.   some LINQ code like (note that ‘this’ is a data context): this.ExecuteCommand("set transaction isolation level read uncommitted"); MyTable.Take(5).Dump(); Produces this sql code: set transaction isolation level read uncommitted GO SELECT TOP 5 <fieldnames…> FROM [MyTable] AS [t0] GO   That’s what I want to see, so yay. =)     some links:   ps. trying to use livewriter today. so far, not excited about it and still like word more =P hopefully i’ll get elightened.

posted @ Friday, August 13, 2010 10:43 AM | Feedback (0) | Filed Under [ DEV ]

Careful with your LINQ joins (WHERE IN TSQL with LINQ)

So today I needed to cross reference some stuff in a text file with some stuff in a db. No big deal. Had about 200 unique values to lookup a few pieces of info out of a larger table in a db. The target table had about a half million rows in it, but was indexed on this particular column I needed to lookup on so it seemed like it should be no big deal. I have found myself using LINQPad more and more for little ad-hoc stuff like this. Anyway, I was prepared to do something similar to this:...

posted @ Tuesday, June 8, 2010 6:20 PM | Feedback (0) | Filed Under [ DEV ]

stupid macro for adding some leading text in an outlook window

so since i have looked this up and figured it out (i know... there isn't much to figure it out, but there it is) i figured i should blog about it so i can quit looking it up somewhere else. basically i just needed to hit a button/hotkey int outlook and have it insert the time/date stamp and my name and a couple of pipes to just divide everything up. no biggy. but if you never create macros and do this once every two years, it's a bit of a pain to remember how. this is for outlook 2007, i think...

posted @ Wednesday, May 26, 2010 10:20 AM | Feedback (0) | Filed Under [ DEV ]

Adding a task item to sharepoint with VBScript and Microsoft.XMLHttp

who'd want to such a crazy thing? well me. i just wanted to find the dirtiest quickest way with zero overhead to push data directly into a sharepoint list. i found a few articles with some information about this, but the closest one was this one using jquery. so here it is in vbscript with no extra libraries or anything (except what is build into windows which is still plenty). one cool thing about this is it was quite faster than the .net method i posted previously. i attribute that to building a nice web reference with all the different...

posted @ Thursday, October 15, 2009 10:46 PM | Feedback (12) | Filed Under [ DEV ]

Adding an task item to sharepoint with C# .net

There are lots of ways to do things like this. Here's a pretty simple way with c# and .net. forgive some of the using shortcuts, i was just isolating a couple of areas. and as always i normally just post these so i don't forget =P this is just a console app to add a single item to a task list in sharepoint. very simple. the only thing that was a bit of a pain is you need to find your sharepoint id for the person. the easiest way i found that for myself was simply to go to the list,...

posted @ Thursday, October 15, 2009 10:38 PM | Feedback (0) | Filed Under [ DEV ]

old ruby code for working with sugarcrm

Login and show basic info require 'soap/wsdlDriver' require 'digest/md5' u = "user" p = Digest::MD5.hexdigest("password") ua = {"user_name" => u,"password" => p} wsdl = "" #create soap s = #uncomment this line for debugging. saves xml packets to files #s.wiredump_file_base = "soapresult" #create session ss = s.login(ua,nil) #check for login errors if ss.error.number.to_i != 0 #status message puts "failed to login - #{ss.error.description}" #exit program exit else #get id sid = ss['id'] #get current user id uid = s.get_user_id(sid) #status message puts "logged in to session #{sid} as #{u} (#{uid}) " #logout s.logout(sid) #status message puts "logged out" end Adding an account After login, you can create new accounts using the code : module_name = "Accounts" ...

posted @ Sunday, March 15, 2009 8:01 PM | Feedback (1) | Filed Under [ DEV ]

partial trust, permcalc, and caspol, OH MY!

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 ...

posted @ Friday, July 18, 2008 3:54 PM | Feedback (0) | Filed Under [ DEV ]

count lines with linq

so i needed to count the lines of a bunch of different filetypes in a folder. i decided to try using linq for this. here's what i came up with. basically a single linq statement =P you can tune the regex to taste. i just said (i think, i'm not a regex wizard) something that isn't a newline (.+) and the line terminators i'm using (\r\n).   using System; using System.Collections; using System.IO; using System.Linq; using System.Text.RegularExpressions; namespace LineCounter {     class LineCounter     {         static void Main(string[] args)         {             // dir to search             string d = @"c:\pathtocode";             // regex match for newlines             string lf = @".+\r\n";                         // get the...

posted @ Wednesday, June 11, 2008 2:07 PM | Feedback (1) | Filed Under [ DEV ]

directory list with a stack instead of recursion

Stack q = new Stack(); q.Push(argument); while (q.Count > 0) {     string d = q.Pop().ToString();     Console.WriteLine(d);     foreach (string sd in Directory.GetDirectories(d))         q.Push(sd); }

posted @ Tuesday, June 10, 2008 6:41 PM | Feedback (0) | Filed Under [ DEV ]

multiple objects in a using and compression sample

Found something nifty I didn't know about today. create multiple objects in a single using statement. I figured i would include some sample code i use for compression/decompression. I'm using the #ziplib libraries, but you could use any stream based process really. The bufferSize variable you can change to fit your needs.      //unzip data. assume we have a compressed file and are creating the output file using (FileStream     u = File.Create(PathToUncompressedFile),     c = File.OpenRead(PathToCompressedFile)) using (GZipInputStream gzip = new GZipInputStream(c))     while ((bufferSize = gzip.Read(buffer, 0, buffer.Length)) != 0)         u.Write(buffer, 0, bufferSize);   //zip data. assume we have a uncompressed file and are creating the...

posted @ Saturday, March 8, 2008 1:52 AM | Feedback (0) | Filed Under [ DEV ]

Show ip addresses on the local machines

foreach (IPAddress ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)      Console.WriteLine(ip.ToString());

posted @ Thursday, February 21, 2008 6:56 PM | Feedback (0) | Filed Under [ DEV ]

.Net DataReader to ArrayList

string sql = "some sql" ArrayList al = new ArrayList(); using (SqlConnection cn = new SqlConnection(cs)) using (SqlCommand cmd = new SqlCommand(sql, cn)) {     cn.Open();     using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))     while (dr.Read()) {         object[] o = new object[dr.FieldCount];         dr.GetValues(o);         al.Add(o);     } } foreach(object[] o in al)     Console.WriteLine(a1(o[0].ToString());

posted @ Thursday, December 13, 2007 3:16 PM | Feedback (0) | Filed Under [ DEV ]

chunking binary or xml into sql

this is a little unique of a setup. i'm having to update a varbin field, but the data that is coming in from the other sources is being cast from xml. so i'm sort of replicating the stupid thing we are doing on the other side, but it seems like a good code sample for this particular method. if you wanted to chunk up xml, you could use this method.   using (SqlConnection cn = new SqlConnection(cs)) { string staging_sql = @" create table ##t (t varchar(max)); insert ##t select ''; ";   update tablewithvarbincolumn set varbincolumn = cast(cast( (select top 1 t from ##t) as xml) as varbinary(max)) where id1= @a and id2= @b; drop...

posted @ Monday, October 29, 2007 2:28 PM | Feedback (0) | Filed Under [ DEV ]

chunking varbinary into sql2005

//reference this metholodogy justification at // int bufferSize = 0; byte[] buffer = new byte[8040]; string update_sql = @"update tablewithblobs set blobcolumn .write(@a,null,0) where id = @b"; using (FileStream fs = File.Open(abinaryfilepath, FileMode.Open, FileAccess.Read)) using (BinaryReader br = new BinaryReader(fs)) using (SqlConnection cn = new SqlConnection(cs)) using (SqlCommand cmd = new SqlCommand(update_sql, cn)) { cmd.CommandTimeout = 0; cmd.Parameters.Add("@a", SqlDbType.VarBinary, bufferSize); cmd.Parameters.AddWithValue("@b", v1); cn.Open(); while ((bufferSize = br.Read(buffer, 0, buffer.Length)) != 0) { cmd.Parameters[0].Value = buffer; cmd.ExecuteNonQuery(); } cn.Close(); }     note that you will have to zero out the field if it's not empty by setting it to 0x0 first.

posted @ Friday, October 26, 2007 10:56 PM | Feedback (0) | Filed Under [ DEV ]

More CLR Internal, Debugging, Etc reading material

I'm done with most of these, but not totally. Tons of great information!   Here are some more great articles that I found doing debugging research. They mostly pertain to debugging and CLR internals type of stuff. CLR Inside Out - Investigating Memory Issues Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects So, what’s new in the CLR 2.0 GC? Windows Debuggers: Part 1: A WinDbg Tutorial Debug Tutorial Part 1: Beginning Debugging Using CDB and NTSD Debug Tutorial...

posted @ Wednesday, July 18, 2007 7:55 AM | Feedback (0) | Filed Under [ DEV ]

First/Second Chance Exceptions Defined

"A debugger attached to a process can receive two types of notifications for each thrown exception: first and second chance. The debugger gets the first chance to handle the exception. If the debugger allows the execution to continue and does not handle the exception, the application will see the exception as usual. If the application does not handle the exception, the debugger gets a second chance to see the exception. In this case the application would normally crash if the debugger was not present."

posted @ Wednesday, July 18, 2007 7:11 AM | Feedback (0) | Filed Under [ DEV ]


As I mentioned in a previous post,  David Hayden sat in the front row and gave me an especially hard time about ‘set nocount on’ as a tip. I don’t remember the exact words, so I’m going to have to roughly paraphrase. His complaint was that some data access layers or object relational mapping tools or other data abstraction methods in .NET sometimes utilized the return record count to determine success or failure. Michael Wells (also in the front row) stated that normally he just utilized a try/catch to determine success, or just relying on a thrown error. Typically, I...

posted @ Tuesday, July 17, 2007 6:26 AM | Feedback (0) | Filed Under [ DEV ]

use CommandBehavior.CloseConnection even with usings

Recently I put together a SQL talk for developers and gave it at our local JAXDUG meeting. It went over well and one of the items I covered was utilizing CommandBehavior.CloseConnection with the command being used. While the implicit finally created by the using connection below will close the connection, in the interest of "open late close early" you should go ahead and implement this CommandBehavior setting. This will cause the connection to be closed as soon as you exit the reader using enclosure below. If you do not, the connection will remain open until you are out of the...

posted @ Wednesday, July 11, 2007 12:47 AM | Feedback (0) | Filed Under [ DEV ]

re: Testing your code

A colleague of mine asked me to comment on this post. For the duration of my post, I will assume that Mads is a "smart" guy, not a "stupid" guy. =) First, I suppose I should give my views of unit testing. If you are writing business logic code, I think you should write unit tests for it. Always. It's that simple. So, moving on.  I’m very ambivalent about unit testing and always have been for many different reasons. Although testing is very important, I often find unit testing to be a time consuming liability but it depends on the project. When smart...

posted @ Tuesday, July 10, 2007 4:31 PM | Feedback (2) | Filed Under [ DEV ]

re: Imprisoning Mort

this is in response to does this mean that I am bound to write unmaintainable [sic] code and should be locked down to a very small set of "safe" choices, which were chosen for me by those Above Me ? In my experience, those often placed above me are _not_ there because they are smarter or better. I rarely see that they make the best choices for what is "safe" code. I would say I rarely see choices that just plain don't suck. Why would you hire someone to write completely disposable code? If you have no faith in their ability, why...

posted @ Monday, July 9, 2007 8:05 PM | Feedback (0) | Filed Under [ DEV ]

simple web service

using System; using System.Data; using System.Data.SqlClient; using System.Web.Services; namespace IamSimple.Service.WebServices {     [WebService(Namespace = "")]     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]     public class simple : System.Web.Services.WebService     {         [WebMethod(Description = "Return a query as a dataset")]         public DataSet QueryAsDataSet(string q)         {             string cs = "connection string"             using (SqlConnection c = new SqlConnection(cs))                 using (SqlCommand cm = new SqlCommand(q, c))                     using (SqlDataAdapter da = new SqlDataAdapter(cm))                         using (DataSet ds = new DataSet())                         {                             ds.RemotingFormat = SerializationFormat.Binary;                             c.Open();                             da.Fill(ds);                             c.Close();                             return ds;                         }     } }

posted @ Wednesday, July 4, 2007 12:50 AM | Feedback (0) | Filed Under [ DEV ]

Odds and Ends

Stuff I've been intending to post a meaningful post about, but haven't: If you have ever wondered what ildasm is all about, here's a great link. Simple SQLCLR stored Proc deployment Walthrough: Three sweet articles about Threads, System.Threading.Thread, and !threads (sos.dll) A couple of sites that led me to err.exe some unit testing stuff i wanted to read and, finally, a great article on troubleshooting memory management issues with .net   I'm tagging this post with 'tips' if for nothing else than err.exe =) 

posted @ Sunday, July 1, 2007 2:13 AM | Feedback (0) | Filed Under [ DEV ]

Top 10 WinDbg.exe Usage Articles

These are the articles (in no particular order) that I felt best showed a thorough use of the WinDbg.exe tool from start to finish. They were absolutely priceless to me. Enjoy! ASP.NET 2.0 Crash case study: Unhandled exceptions A word for WinDbg (2) Some new SOS functions System.ArgumentException: Illegal characters in path ...

posted @ Sunday, June 24, 2007 5:42 PM | Feedback (0) | Filed Under [ DEV ]

Top 5 SOS.dll Tips

5 things I wish I had known or done prior to attempting to work with SOS.dll and windbg.exe:  sos.dll needs to be in the path for windbg in order to load it you can .load %full path to sos.dll% instead of .load sos mscorwks or other statements SOS for .NET 2.0 does *NOT* have all the commands the .NET 1.x version does (a source) ...

posted @ Sunday, June 24, 2007 4:53 PM | Feedback (0) | Filed Under [ DEV ]

unicode paths in windows

something cool i've never heard of. quoted from about a path value of \\?\C:\WEBSites\WWWMyApp\scripts: First of all, what is illegal about this path? Well, nothing, if you are a Unicode Win32 API. As you can read in Naming a File on MSDN, certain Unicode Win32 file handling APIs allow a path to be prefixed with \\?\ which allow paths to be up to 32,000 characters in length among other things. It also tells the operating system to not canonicalize the path by interpreting things such as .. to mean 'go to the parent directory'. Unfortunately not all parts of the System.IO namespace...

posted @ Sunday, June 24, 2007 4:27 PM | Feedback (0) | Filed Under [ DEV ]

managed threads

I found this while in my surfing and thought it was a noteworthy point on .net multi-threading. quoted from (underlining is mine): The CLR exposes managed threads, which are distinct from Microsoft Win32® threads. The logical thread is the managed representation of a thread, and the physical thread is the Win32 thread that actually executes code. You cannot guarantee that there will be a one-to-one correspondence between a managed thread and a Win32 thread. If you create a managed thread object and then do not start it by calling its Start method, a new Win32 thread is not created. When a managed thread...

posted @ Sunday, June 24, 2007 8:09 AM | Feedback (0) | Filed Under [ DEV ]

for > foreach

i feel like i have seen a ton of places that say for and foreach are the same performance-wise in .net. i never really worried about it much. i have historically done a lot of refactoring and loops are definitely one area you can see lots of improvement in. so i figured i would post some actual documentation about this. =)  quoted from Using foreach can result in extra overhead because of the way enumeration is implemented in .NET Framework collections. .NET Framework 1.1 collections provide an enumerator for the foreach statement to use by overriding the IEnumerable.GetEnumerator. This approach is...

posted @ Sunday, June 24, 2007 7:42 AM | Feedback (0) | Filed Under [ DEV ]

re: XmlDocument-to-Byte-Array - don't forget your usings. =)

This is in response to this article and is me giving dennis a hard time. =P byte[] XmlToByte(XmlDocument d) {     using (StringWriter sw = new StringWriter())     {         using (XmlTextWriter xw = new XmlTextWriter(sw))         {             d.WriteTo(xw);             ASCIIEncoding encoding = new ASCIIEncoding();             return encoding.GetBytes(sw.ToString());         }     } }

posted @ Friday, June 22, 2007 10:52 PM | Feedback (0) | Filed Under [ DEV ]

Top 20 .NET Garbage Collection (GC) Articles

Ah. Garbage Collection... how I love and hate thee. =P I think one sad thing about programming in .net is that it seems many developers don't know or care anything about garbage collection and memory management. You used to *have* to know about it in order to write bug free code. I suppose it is a two edge sword in that developers can develop faster as the intention was to relieve developers of the need to know or care anything about memory management. I personally have always tried to follow best practices for implementation and have tried to stay somewhat cautious...

posted @ Friday, June 22, 2007 4:49 AM | Feedback (0) | Filed Under [ DEV ]

command cancel vs close

There are a ton of articles about using command cancel vs close when you are using a datareader. The idea is that it will make things faster if you cancel the command rather than just closing it if you have an occasion to interrupt the execution. If you don’t cancel, it seems that it will read the rest of the items even if you break the loop, it just won’t do anything with them. Since you are breaking out, you normally don’t need to process the rest of the records, and so you can simply cancel the execution of that...

posted @ Thursday, May 3, 2007 9:54 PM | Feedback (0) | Filed Under [ DEV ]

how to debug classic asp pages

Davegot a request to allow someone to setup Visual Studio 6 so they could use Visual InterDev. I’m talking about recently, not years ago. For reasons I’m sure most people can guess, those packages are not allowed. It took me about 15 seconds on Google to locate the answer for this person. The answer is really to use a new version of Visual Studio. Anyway, I thought I’d post the links we sent to this individual just in case anyone else has a burning need to debug asp code./font>  /font> ...

posted @ Thursday, May 3, 2007 8:56 PM | Feedback (1) | Filed Under [ DEV ]

stupid svn log tricks

ok, this is way lame, but it's just a simple poc =P this is a winform app that will launch svn log and all of the files you drop onto it or sendto it and put them all in one window. i also put a little bit of basic logic to remove blank lines and the seperators from between the log entries. the only purpose of this is if you have to regularly get these comments back for about 10 or 20 files, using multiple threads will be way faster. hopefully this will help someone else who needs a basic...

posted @ Friday, March 30, 2007 7:35 AM | Feedback (0) | Filed Under [ DEV ]

view svn change log, quick and dirty

if you have a "burning" need, as some do, to view the change log for a bunch of files in svn, here's a quick way in windows to do it. just save the following as showsvnlog.cmd or whatever cmd or bat you want in your sendto folder and highlight whatever files you want and send them to it. you can also just drag and drop files onto it. this script utilizes some basic looping, shift, and alternate data streams. nothing revolutionary, but it does the job. here's the code: ::showsvnlog.cmd::royashbrook - execute svn log for files and show the output@echo offset...

posted @ Friday, March 30, 2007 5:22 AM | Feedback (0) | Filed Under [ DEV ]

basic sql load testing with a multithreaded c# console app

this is a very basic load tester. it basicaly lets you from the command line specify what command to run, how many times, against what connection string and whether you want to see any results. obviously, you can tweak it to print the results differently as you see fit, currently it just spits out field numbers and a value. here's the code: using System; using System.Threading; using System.Data.SqlClient; using System.IO; namespace TestSQL {     class Program     {         private static string s;         private static string cs;         private static int m;         private static int a;         private static int n;     ...

posted @ Tuesday, March 20, 2007 8:58 AM | Feedback (0) | Filed Under [ DEV ]

nopatchforstupid #1

stupid 123456789101112131415161718192021222324252627282930313233343536 public bool CleanUpTable(decimal id) { bool bRet = true; try { ...

posted @ Friday, March 9, 2007 2:12 PM | Feedback (0) | Filed Under [ DEV ]

css and microformats

53 css techniques you couldn't live without cool railsish site. addictedtonew microformats are cool microformat related blog post cssplay this site is always awesome and i'm gonna link it just because of the sheer amount of times i've had it open when i was posting something. =P

posted @ Monday, January 22, 2007 2:09 PM | Feedback (0) | Filed Under [ DEV ]

rotating testimonials with javascript

Very simple text rotator. No blending, just rotation. the quotes array could be dynamically grabbed from somewhere, or you could simply have the rotate function grab it randomly from somewhere instead of from the array. since these are just testimonials that i'm rotating over, i don't think anyone will have the page up for like 100 hours, and if they do, they can just see the same ones cached in js memory. you could also simply build the array included here dynamically when you are writing out your page. this is really just here for the logical example. of course, modify the...

posted @ Thursday, December 7, 2006 5:49 PM | Feedback (0) | Filed Under [ DEV ]

Recursion and File Enumeration

Very simple app that just shows how to traverse files and folders. Note that you can also utilize the FileSystemInfo class, however if you do that you have to write your own file filter checking etc. Not that the default is super robust, but it does end up being less code. Just for a change, I short cut the class references with using statements up top =P I didn't just do this randomly, I was actually looking at using the c++ glob app shown here in my c# project and maybe just cycling through a glob instead of traversing the tree,...

posted @ Tuesday, December 5, 2006 9:02 PM | Feedback (0) | Filed Under [ DEV ]

TODO and more to RSS

reposted from my other blog inspired by this article, i decided to write a .net version. i thought this could be something useful for searching our code base at work. kind of the same as this guy has setup for his single machine, but i figured i could search a whole subversion tree and pipe it to our dev intranet site. Since I was at it, I figured I would make it a little more flexible. You can set all the options through the querystring. if you don't like that, feel free to just set them manually. i didn't want to pass...

posted @ Tuesday, December 5, 2006 5:53 AM | Feedback (0) | Filed Under [ DEV ]

tables for layout... boo

reposted from my personal blog this post is re: this article. the author makes tons of great points for reasons to use tables for ease of layout. the problem is that the point of not using tables is so that your content is not tied to your layout in any way. while i agree that for simple easy formatting, tables are FAR superior to css in many ways, the problem is that you probably will want to modify the formatting at some point. why not be able to completely customize your entire site with one file rather than modifying all of your...

posted @ Wednesday, November 1, 2006 12:33 PM | Feedback (0) | Filed Under [ DEV ]

replacing carriage return

nothing fancy here, we're just doing a regex replace on \r and replacing it with nothing. this is a different way of doing the same thing dennis already posted here. =P using System.IO; using System.Text.RegularExpressions; namespace StripCR {     class Program     {         static void Main(string[] args)         {             nocr(args[0]);         }         public static void nocr(string f)         {             string t;             using (StreamReader r = new StreamReader(f))             t = Regex.Replace(r.ReadToEnd(), "\r", "");             using (StreamWriter w = new StreamWriter(f))             w.Write(t);         }     } } and because i know you want to know, here's...

posted @ Tuesday, October 31, 2006 12:08 PM | Feedback (0) | Filed Under [ DEV ]

parsing eml files with ruby

This is essentially the same thing, just with ruby code. Again, note that you can change that URL regular expression to match what you want to find in the email. i also split the file in half after the header and only searched the header for from/to/subject and the body for urls in this one. a slightly different approach. The point of this is really just to show how simple it is to setup the logic and where you can easily configure your regular expressions to tweak your results. As with most ruby code I write, there is probably a...

posted @ Thursday, October 26, 2006 11:18 AM | Feedback (0) | Filed Under [ DEV ]

parsing eml files with c#

here's a short code snippet showing how to parse the from/to/subject from an eml file as well as any urls located in the message. the regex for urls isn't perfect. there are a million ways to do url regex, so pick your poison from the web. this is just for example. reposted from here. 123456789101112131415161718192021222324252627282930313233343536373839404142434445 using System;using System.IO;using System.Text.RegularExpressions;namespace parse.eml{ class Email { string _path,_to,_from,_subject,_urls; public Email(string path) { ...

posted @ Wednesday, October 25, 2006 12:43 AM | Feedback (0) | Filed Under [ DEV ]

Powered by: