Browse by Tags

All Tags » C# (RSS)
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...
Posted by royashbrook | with no comments
Filed under: ,
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 by royashbrook | with no comments
Filed under: ,
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...
Posted by royashbrook | with no comments
Filed under: ,
foreach ( IPAddress ip in Dns .GetHostEntry( Dns .GetHostName()).AddressList) Console .WriteLine(ip.ToString());
Posted by royashbrook | with no comments
Filed under: ,
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...
Posted by royashbrook | with no comments
Filed under: , ,
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...
Posted by royashbrook | with no comments
Filed under: ,
//reference this metholodogy justification at // http://www.lacoude.com/Docs/public/public.aspx?doc=SQL90XML.PDF int bufferSize = 0; byte [] buffer = new byte [ 8040 ]; string update_sql = @"update tablewithblobs set blobcolumn .write(@a,null,0)...
Posted by royashbrook | with no comments
Filed under: ,
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...
Posted by royashbrook | with no comments
Filed under: , , ,
using System ; using System.Data ; using System.Data.SqlClient ; using System.Web.Services ; namespace IamSimple.Service.WebServices { [WebService(Namespace = "http://royashbrook.com/ns" )] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1...
Posted by royashbrook | with no comments
Filed under: , ,
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...
Posted by royashbrook | with no comments
Filed under:
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...
Posted by royashbrook | with no comments
Filed under: ,
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...
Posted by royashbrook | 9 comment(s)
Filed under: , ,
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...
Posted by royashbrook | with no comments
Filed under: , , ,
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...
Posted by royashbrook | with no comments
Filed under:
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...
Posted by royashbrook | with no comments
Filed under: ,
More Posts Next page »