Tuesday, November 19, 2013

What is a good code snippet, knowledge base note taking tool?


I have been storing my programming notes for years in folders with individual txt, pdf, zip files.
For years I have been looking for a great tool to organize my notes.

I develop in both OSX and Windows so looking for tools in both environments.

For non programming I used to use MyInfo from Milenix but there is no code highlightning

There is a thread here on How do you manage your knowledge base but I didn't get much wiser after reading that, but there is a lot of suggestions.

I recently came across Snippetmanager that has code highlighting. If I could combine this with MyInfo and sync with a Mac version it could be perfect. I might give it a try. UPDATE: This app haven't been updated for 1-2 years.

For Mac I found Snippetsapp but it doesn't support C# and haven't been updated for one year.


Snippets  (Mac+Windows)
CodeBox (Mac) but I'm missing a trial here before I pay 10USD



So far I'm still hunting for the perfect tool.

Friday, January 13, 2012

How to assign unique id to WCF with NLog

I want to add a unique id for each session request in WCF using NLog so I can identify to what session
I have not found a clear way to do this but here is a few pointers:



  • How to do this using log4net: http://www.catchblock.com/blog/post/2011/12/02/WCF-Web-API-and-logging-unique-request-id-with-log4net.aspx
  • Further discussion about log4net: http://wcf.codeplex.com/discussions/281421
  • NLog's way of adding context: http://nlog-project.org/wiki/Event-context_layout_renderer

Tuesday, January 25, 2011

Unrecognized Tag Prefix or Device Filter ‘asp’

Have problems with the above error when using nested MasterPages?

I found out the problem in my case was that I had the tag in a nested masterPage. I solved it by simply moving the tag to the first MasterPage.

Monday, September 20, 2010

Entity Framework (CTP4) links

I thought I wanted to share some of my EF CTP4 links

http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4piwalkthrough.aspx
http://romiller.com/2010/07/18/ef-ctp4-tips-tricks-mapping-to-an-existing-database/
http://blogs.iis.net/shanselman/archive/2010/07/14/simple-code-first-with-entity-framework-4-magic-unicorn-feature-ctp-4.aspx
http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx
http://huyrua.wordpress.com/tag/poco/
http://code.msdn.microsoft.com/EFDocSamples2010
http://romiller.com/2010/07/19/ef-ctp4-tips-tricks-wcf-data-service-on-dbcontext/
http://csharpbits.notaclue.net/2010/07/using-entity-framework-code-first-ctp4.html
http://romiller.com/2009/06/26/ntier-with-ef4-beta-1/
http://romiller.com/2010/07/31/ef-ctp4-tips-tricks-running-additional-ddl/
http://blogs.msdn.com/b/adonet/archive/2009/12/22/poco-proxies-part-1.aspx
http://msdn.microsoft.com/en-us/library/ee705457.aspx
http://blogs.msdn.com/b/efdesign/archive/2010/06/21/productivity-improvements-for-the-entity-framework.aspx
http://buildstarted.com/2010/08/27/entity-framework-with-many-to-many-one-to-many-and-one-to-one-relationships/
LINQ samples
ADO.NET Entity Framework Overview)

http://blogs.msdn.com/b/efdesign/archive/2008/11/20/n-tier-improvements-for-entity-framework.aspx
http://blogs.msdn.com/b/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx
http://romiller.com/2010/07/19/ef-ctp4-tips-tricks-wcf-data-service-on-dbcontext/

Problem with STA and WCF when using COM-objects

Scott Seely have a good post about how to solve calling STA COM Object from a WCF operation. In my case I had an old COM object that required STA.

Look here for Scott Seely's post

Friday, August 6, 2010

Entity Framework (CTP4)

Playing with the new Entity Framework I had a need to store files.


Simply add Byte[] to your CLR

public class Product
{
public int ProductId { get; set; }
[StringLength(40)]
public string Name { get; set; }
public Byte[] ProductImage { get; set; } //Maps to VARBINARY(MAX)
public string CategoryId { get; set; }

public virtual Category Category { get; set; }
}

Automapper

Just found Automapper which takes the boring part out of mapping by doing it automatically

Tuesday, January 13, 2009

ConfigurationManager.AppSettings avoid null errors

I found a smart way how to avoid checking for null by using AppSettings.Get or to get an 'Object reference not set to an instance of an object' if not checking for null

Classic method:
string notsmart = String.Empty;
if (ConfigurationManager.AppSettings["test"] != null)
notsmart = ConfigurationManager.AppSettings["test"].ToString();

One-step method:
string keyvalue = ConfigurationManager.AppSettings.Get("test");

Monday, January 12, 2009

MySQL Documentation Tool

I have for long time been looking for a good program to document my MySQL databases. I even tried various Wiki's but found it taking to long time as I manually had to enter all data.

Recently I tested two products:
EMS SQL Manager for MySQL
MySQL Workbench SE

My requirements
  • Nice and easy GUI
  • Reverse engineer tables
  • Make virtual relations between fields
  • Relationship notation that can connect to columns
  • Comments on table and columns
  • pdf/html report with comments

Conclusion
I choose MySQL Workbench SE because its GUI were really nice and easy to work with. It can however at times be slow and it for sure needs some more development time to make it the best. Documenting on table/fields was easy and I can also export to various formats. It do lack the virtual relationship which I hope will come in near future - until then I will create real relationships and then simply not committing back to database. Not the optimal solution but it will do for now.

EMS had the virtual relation but the GUI were not easy to work with. If EMS had a better GUI with the options to add layers and more options then perhaps it would have been my preferred app.

Friday, May 2, 2008

Convert HTML <a href/> tags to <asp:HyperLink/>

Search:
<a\s{1}href="(?<url>.*?)"(\s?target="(?<target>_(blank|new|parent|self|top))")?(\s?class="(?<class>.*?)")?(\s?style="(?<style>.*?)")?>(?<title>.*?)</a>

Replace:
<asp:HyperLink ID="HyperLink1" runat="server" Target="${target}" CssClass="${class}"
NavigateUrl="${url}">${title}</asp:HyperLink>

There is room for improvement but it will do the job. You may want to use another editor than Visual Studio as it doesn't like this regex