Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • iacoware 11:06 pm on March 4, 2010 Permalink | Reply  

    Developers in Florence slides 

    The first “Developers in Florence” meeting is over and I’m really glad I went, I met some really interesting guys and learned something as well. Thanks to Open Lab and Develer for the organization. Keep rolling 😉

    Here the slide and source of my talk:

    Some .NET features we are missing in Java 6

    A brief journey into C# and its latest features, a mainstream language that tries to mix imperative and functional programming. We’ll take a look at extensions methods, lambda expression, type inference, LINQ, etc

    1. Slides pptx or pdf

    2. C# sources

     
    • Alvin 4:54 am on January 23, 2013 Permalink | Reply

      Pretty! This has been a really wonderful post.
      Thank you for providing these details.

  • iacoware 10:53 am on December 18, 2009 Permalink | Reply  

    Manage people 

    I’ve put together a list of Joel Spolsky’s posts (articles would be more appropriate) that I consider a must read   for everyone who manage people (employers, managers) that do a non-repetitive, somewhat creative, type of job like developers, graphic designers, etc. 

    They’re classic for who knows Joel but a lot of people don’t so I’ll post here for future reference. Here it is:

    1. The Joel Test: 12 steps to better code – http://www.joelonsoftware.com/articles/fog0000000043.html

    3. http://www.joelonsoftware.com/articles/FieldGuidetoDevelopers.html

    4. http://www.joelonsoftware.com/articles/HighNotes.html

    5. The Programmer’s bill of rights – http://www.codinghorror.com/blog/archives/000666.html

    Did I miss something valuable?

     
  • iacoware 10:18 pm on November 5, 2009 Permalink | Reply  

    ASP NET MVC – A Better [HandleError] exception filter 

    The standard [HandleError] action filter which comes with ASP NET MVC has a very useful feature beside its widely known standard use, which is:

    [HandleError]
    public class MyController : Controller

    Indeed, you can associate various kind of exceptions each to its own view, this gives you to your users friendly errors (a prerequisite for every post web 1.0 application):

    //More specifics exceptions come first [HandleError(ExceptionType = typeof(ResourceNotFoundException), ViewName="Error404", Order = 1)] [HandleError(Order = 2)] public class MyController : Controller

    That’s all great BUT you can’t set the http status code you want to return to the browser, it will always return a generic 500 server error. Your users really don’t care much about status code being returned but search engines really do and they will be grateful if you behave as a good web citizen and use it appropriately.

    What if you want to return a 404 to indicate that a resource is missing?

    Enter SmarterHandleError filter, which is a filter identical to [HandleError] except that you can also set up the http status code being returned:

    [SmartHandleError(ExceptionType=typeof(ResourceNotFoundException), ViewName="Error404", StatusCode=404, Order=1)] --> More specific exceptions come first [SmartHandleError(ExceptionType=typeof(Exception), ViewName="Error", StatusCode=500, Order=2)] public class MyController : Controller

    That was my first iteration. The second one transformed SmartHandleError in an abstract class from which I derive a concrete class for every type of exception I need to handle:

    [HandleError404(Order = 1)]
    [HandleError500(Order = 2)]
    public class MyController : Controller

    Moreover SmartHandleError has a template method which you can override to provide some kind of different workflow depending on the catched exception type.

    Here it is:

    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] public abstract class SmartHandleErrorAttribute : FilterAttribute, IExceptionFilter
    { Type exceptionType = typeof(Exception); int statusCode = 500; string viewName = "Error";

    public SmartHandleErrorAttribute(Type exceptionType, int statusCode, string viewName) { this.exceptionType = exceptionType; this.statusCode = statusCode; this.viewName = viewName; }
    public virtual void OnException(ExceptionContext filterContext) { Ex.Assert<ArgumentNullException>(filterContext.IsNotNull(), "filterContext"); if (filterContext.ExceptionHandled) return; if (!filterContext.HttpContext.IsCustomErrorEnabled) return; if (filterContext.Exception.IsNull()) return; var exception = filterContext.Exception; if (exception is TargetInvocationException) exception = (exception as TargetInvocationException).InnerException; if (!exceptionType.IsInstanceOfType(exception)) return; //it's not our exception
    filterContext.Result = new ViewResult { ViewData = filterContext.Controller.ViewData, TempData = filterContext.Controller.TempData, ViewName = viewName, }; filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = statusCode; filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;  

    //Template method, override this in inherited class to execute custom logic //for this exception OnExceptionHandled(filterContext); }
    //Override this to add post-processing specific to the exception thrown
    protected virtual void OnExceptionHandled(ExceptionContext filterContext) {}
    }
     
  • iacoware 10:37 am on October 2, 2009 Permalink | Reply
    Tags: svn   

    howto use svnsync to mirror a repository on windows 

    I’m in the process of (hopefully) switching SVN hosting provider from eurosvn.com to xp-dev.com. To make that happen I first have to create a dump of my existing repository and it’s not something you can do on an online repo, svnadmin dump only works on local paths (which is a good thing ;-).
    I’m going to post here the details of making a local readonly mirror repository. It’s useful for, at least, two reasons:
    1. Make a backup
    2. Make a dump 🙂
    Ready? Ok, let’s start opening your command prompt:

    I’m in the process of (hopefully) switching SVN hosting provider from eurosvn.com to xp-dev.com. To make that happen I first have to create a dump of my existing repository and it’s not something you can do on an online repo, svnadmin dump only works on local paths (which is a good thing ;-).

    I’m going to post here the details of making a local readonly mirror repository. It’s useful for, at least, two reasons:

    1. Make a backup
    2. Make a dump 🙂

    Ready? Ok, let’s start opening your command prompt:

    1. Create a local repository

    svnadmin create [YOUR NEW REPO PATH]
    eg: svnadmin create c:\svnrepo\iacoware.

    The root path must exists (c:\svnrepo). By default the repository is created as read-only

    2. Enable writing on your new repo

    Open file [PHYSICAL LOCAL REPO PATH\conf\svnserve.conf] and decomment line

    [password-db = passwd] (line 20 in my file)

    This tell to SVN which file stores user’s credentials.

    3. Add a new user

    Open file [PHYSICAL LOCAL REPO PATH\conf\passwd] and add a new user under the [users] group (mine svnsync_user = svnsync).

    4. Give your new user read/write permissions

    Open file [PHYSICAL LOCAL REPO PATH\conf\authz] and add:

    [/]
    svnsync_user = rw

    5. Enable rev propchange (revision property change)

    Look for the file “pre-revprop-change.tmpl” in [PHYSICAL LOCAL REPO PATH\hooks]. Make a copy and rename it to pre-revprop-change.bat. Open it and remove everything, be sure to leave only:

    exit 0

    6. Initialize the repository

    svnsync init [LOCAL REPO PATH using file:// protocol] [REMOTE LOCAL PATH] --sync-username [USERNAME] --sync-password [PASSWORD]
    eg: svnsync init file:///c:/svnrepo/iacoware http://your.svn.hosting.provider/your.repository --sync-username user_svnsync --sync-password svnsync

    Getting the local repo path right could be tricky. Pay close attention to the number of slash. I used the file protocol but you can also use the svnserve protocol:

    eg: svnsync init svn://iacoware ...
    (obviously svnserve must be up and running, eg: svnserve -d -r c:\svnrepo)

    7. Synchronize

    svnsync sync [LOCAL REPO PATH]. Be aware, if your repo is big, it could take a loooot of time.
    eg: svnsync sync file:///c:/svnrepo/iacoware

    From now on if you want to synchronize your local repository you have to repeat only step no.7

    HTH

    Troubleshooting

    If the synchronization process goes wrong (it happened to me) next time you’ll try to sync you’ll receive an error “failed to get lock on destination repos, currently held by…”. Run this command:

    svn propdel svn:sync-lock --revprop -r 0 [LOCAL REPO PATH]

    and life will be happy again

    References

    http://journal.paul.querna.org/articles/2006/09/14/using-svnsync/

     
    • carodriguezb 3:21 am on March 13, 2010 Permalink | Reply

      Thanks, this information help me a lot.

    • Anuzer Koavne 3:32 pm on July 27, 2010 Permalink | Reply

      Thanks for information but i want to make files and folders mirror, not database. Can you help me about that?

    • Mike 11:23 pm on February 9, 2011 Permalink | Reply

      So far so good.. Thanks!

    • Michael Ebbage 12:56 pm on February 9, 2012 Permalink | Reply

      Thanks for this guide, it made the task so much easier – there doesn’t seem to be much information on the web covering this.

    • Sathish Kumar S 12:29 pm on February 15, 2012 Permalink | Reply

      Thanks, It Helped me for my requirement.

    • Michal 9:42 pm on June 26, 2012 Permalink | Reply

      In my case it was also needed to decomment [authz-db = authz] line. Thanks!

    • MrLeV 3:20 am on January 7, 2013 Permalink | Reply

      Thanks a lot for this step-by-step guide.
      Note that if your remote svn provider requires a certificate on your side, you will have to provide it when asked (usually once per operation).

    • Mano 8:08 am on February 24, 2014 Permalink | Reply

      Thanks for the detailed steps : ) It’s useful to me.

    • Chris 6:55 pm on April 18, 2014 Permalink | Reply

      When using cygwin, pre-revprop-change.tmpl should be copied to pre-revprop-change instead of pre-revprop-change.bat.

    • Brian 8:54 pm on May 15, 2014 Permalink | Reply

      Very helpful. Thanks for listing this in a detailed step by step with gotchas. 🙂 Cheers!

    • Anbarasu 3:50 pm on March 30, 2017 Permalink | Reply

      Hai i have tried the same method but the Error on the source system shows as “svnsync: E165006: Repository has not been enabled to accept revision propch
      anges;
      ask the administrator to create a pre-revprop-change hook”

      I have tried to change the file extension as .bat and its content too..But the problem still exist.

    • armando 11:55 pm on April 4, 2017 Permalink | Reply

      i got e205000 error analized by paramteres
      and e205000 try “svnsync help” for more information

      i got stuck on step 6

    • Ken 2:15 pm on September 25, 2017 Permalink | Reply

      I just wanted to say thank you for this information, very helpful, especially the format of listing the commands and examples. This saved me a lot of time!!! Thanks again.

    • Iuri Almeida 1:10 am on July 25, 2020 Permalink | Reply

      Thank you man! You save me! Hugs from Brazil!

  • iacoware 5:34 am on September 28, 2009 Permalink | Reply  

    New books 

    I’ve just got four new books to read:
    1. Pragmatic Thinking and Learning by Andy Hunt
    2. ASP NET MVC in Action, J.Palermo-
    3. Design web interfaces, Bill Scott & Theresa Neil
    4. C# in depth, Jon skeet
    I hope to post here a review when I’ve read them.

    I’ve just got four new books to read:

    1. Pragmatic Thinking and Learning, Andy Hunt
    2. ASP.NET MVC in Action, J.Palermo & J. Boogard & B. Scheirman
    3. Design web interfaces, Bill Scott & Theresa Neil
    4. C# in depth, Jon skeet

    I hope to post here a review when I’ve read them.

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel