Smitty's Home Of Leaky Abstractions
A techie blog covering practical programming topics and helping to explain the occasionally nonsensical, and personal. In short whatever I feel like.
Tuesday, April 16, 2013
Simple Tables styling in CSS
Note to self, To style a table with alternating row colors and 0 cell spacing and 5 cell padding and 100% width in CSS3
References for learning Linq
A question I was asked the other day let to an email that led to this post.
List of Language Integrated Query learning resources.
- Linq Video (an explanation from Anders Hejlsberg inventor of C# among other things)
- Microsoft’s Linq Links for all the stuff you can “Linq” to
- 101 linq samples
- Use LinqPad,Comparison of SQL vs Linq
- Take the Linqpad Challenge. (This helped me alot)
- The author of LinqPad's website
- Stackoverflow's Linq entry
- List of Linq learning refs
- Linq Wiki
- I hear “Linq In Action” is a good book on Linq and bonus LinqPad examples are available to play with
- I also wrote an app for windows phone 7
In case you didn't notice, I really dig LinqPad. Totally worth the money for me.
Wednesday, January 23, 2013
Preforming a Git Checkout on a Directory
Description
A script I wrote to to run a checkout on each file the current directory. Not the fastest thing in the world as I do not know bash all that well , that being said I'd love to hear about ways to improve it.
What does git checkout -- yourfilename.txt do?
Well in short it checks out the file passed.
What does that mean? In git land checkout holds a different meaning than that of other Version Repository Software. In my personal exp in TFS i known checkout to mean something like Tell the server I want to edit this file and mark that file as writeable in my file system.However in git you are essentially saying I want to remove any changes since the last commit.
More Resources
Tuesday, January 22, 2013
A we bit o' reflection to brighten up your life
A couple of diagnostic extensions that make my life easier when debugging things. Enjoy.
public static class DiagnositcObjectExtensions
{
public static string ToDiagnosticInfoString<T>(this IEnumerable<T> items)
{
var retval = String.Empty;
if(items.Count<T>()>0)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("-----BEGIN DIAGNOSTIC-------");
foreach(var item in items)
{
sb.AppendLine(item.ToDebugString<T>());
}
sb.AppendLine("-----END DIAGNOSTIC---------");
retval = sb.ToString();
}
return retval;
}
public static string ToDebugString<T>(this T obj)
{
StringBuilder sb = new StringBuilder();
Type _type = obj.GetType();
PropertyInfo[] pi = _type.GetProperties();
sb.AppendFormat("Type={0}\r\n",typeof(T).ToString());
sb.AppendLine("Properties");
foreach (var item in pi)
{
sb.AppendFormat("{0} {1} = {2}\r\n",item.PropertyType.ToString(),
item.Name,
item.GetValue(obj));
}
return sb.ToString();
}
}
{
public static string ToDiagnosticInfoString<T>(this IEnumerable<T> items)
{
var retval = String.Empty;
if(items.Count<T>()>0)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("-----BEGIN DIAGNOSTIC-------");
foreach(var item in items)
{
sb.AppendLine(item.ToDebugString<T>());
}
sb.AppendLine("-----END DIAGNOSTIC---------");
retval = sb.ToString();
}
return retval;
}
public static string ToDebugString<T>(this T obj)
{
StringBuilder sb = new StringBuilder();
Type _type = obj.GetType();
PropertyInfo[] pi = _type.GetProperties();
sb.AppendFormat("Type={0}\r\n",typeof(T).ToString());
sb.AppendLine("Properties");
foreach (var item in pi)
{
sb.AppendFormat("{0} {1} = {2}\r\n",item.PropertyType.ToString(),
item.Name,
item.GetValue(obj));
}
return sb.ToString();
}
}
Saturday, January 19, 2013
Making a Remote Repo via bsh
Making a Remote Repo via bsh
Make the directory you want your remote repo to be in
Go into that directory
Init with bare
Go to local git repo directory
Adds a new remote location to your local git repo named origin
>MyRemoteComputerName/MyRemoteGitDir *
//push the content of your master branch to remote repo named origin
//check yourself
congrats you have made a remote repo
*note* the syntax for a git or ssh is different for this
Make the directory you want your remote repo to be in
mkdir MyRemoteGitDirGo into that directory
cd MyRemoteGitDir Init with bare
git init --bare Go to local git repo directory
cd MyLocalGitDirAdds a new remote location to your local git repo named origin
git remote add origin
Your output should look something like this.>MyRemoteComputerName/MyRemoteGitDir *
//push the content of your master branch to remote repo named origin
git push origin master //check yourself
git remote>origincongrats you have made a remote repo
*note* the syntax for a git or ssh is different for this
Saturday, September 1, 2012
About Windows 8 style (Formerly Metro) for WPF Devs
CodeProject
This post is a list of resources I've used, for those Wpf devs out there who want
to emulate the Windows 8 (Formerly Metro) Style. I shall post more when i find more.
MahApps Metro
MahApps.Metro is a pretty nice open source lib that, while not all encompassing, is very much a viable way to go. It has most of the metro versions of the wpf controls styled available, is regularly updated battle tested, has pretty good bit of documentation and examples and is free under the MS-PL licence. However, there is a good bit of ceremony required to set your xaml up properly if you are looking to tweek your existing projects. UI customizable out of the box is pretty limited to the predefined out of the box styles. Unless you roll your own set. Can be brittle due to the specific requirements of setup. Not a bad way to go if you don't need to tweak the UI or modify a preexisting ui.(your better off starting from scratch and using their guidelines )
RadControls for WPF
For the WPF RadControls in the Telerik offerings, Metro is a predefined theme that works in getting you most of the way metro out of the box. Granted, its not perfect, but there is definitely a good bit of bang for your buck there. (as you do have to pay for it.) Additional, if your company has a Telerik licence you as a developer are free to use it for your personal, non work related coding goodness.)
Don't take my word for it, Check out their licencing
Developer Licenses are perpetual and have NO deployment limitations - they allow the use of our controls for an unlimited number of applications spanning various servers and domains.
So yeah bonus for you if your company has provided you with one. If it is available to you and yours, then it is probably the easier way to go.
Additional Resources on Metro
- Small set of helpful bits such as the borderless window which looks pretty sweet for most any app. http://metrotoolkit.codeplex.com/
- Tutorial on emulating metro design in wpf by(Sacha Barber of Codeproject and Mvvm Cinch http://www.codeproject.com/Articles/370650/Simple-Metro-Style-Panorama-Control-for-WPF
- Great but not TLDR resource on groking metro
- New Ref for metro styling: Specifically Button, Listbox, Menu, Scrollbar, TabControl and Textboxes http://www.codeproject.com/Articles/442856/Visual-Studio-2012-Metro-Styles-for-WPF
LURK MOAR HEIR
Monday, August 27, 2012
ToObservableCollection
CodeProject
I've found myself writing this bit over several times and though to myself. "Self you should put this somewhere."
And so I answer back....OK. As an added bonus you can use it too.
using System.Collections.Generic; using System.Collections.ObjectModel; namespace Example.Extensions { public static class Extensions { public static ObservableCollectionToObservableCollection (this IEnumerable enumerable) { var col = new ObservableCollection (); foreach (var cur in enumerable) { col.Add(cur); } return col; } } }
Subscribe to:
Posts (Atom)
