Sorting Spaces In Lion


    I’ve made quite a few changes to how I work over the years, specifically my monitor count. I’ve tried varieties of one, two and even three monitors. But interestingly, for me, one large monitor seems perfect… well, almost…

    Obviously, you can only fit so much on a single screen before you end up with a noisy mess of windows and documents.

    This is one of the reasons why I like Spaces so much and they work even better(ish) in the most recent version of OSX Lion.

    What I’ve done is set a unique background to a desktop and then assigned related apps so that they stay with the view. This makes it easy to keep my desktop organized without needing multiple monitors.

    Some apps I don’t assign to a specific desktop (browsers). In some cases it might make sense to assign them to all desktops so they are easier to access (for example, Finder).

    The Wallpapers

    Feel free to use the wallpapers and if you can think of one that is missing, let me know (Include the text and a link to the icon use). Obviously, you can use any apps for the backgrounds but below are some suggestions.

    </tr> </table>
    </td>

    Templates With Razor


    Razor is a great way to create views with ASP.NET MVC. One feature I use quite often are custom helpers. Instead of duplicating the same few lines of markup I simply create a reusable helper to generate HTML.

    For example, you could create a helper to do something simple like render out a series of values…

    @helper tabs(params Tab[] tabs) {
    <ul>
      @foreach(var tab in tabs) {
      <li><a href="@tab.Url" >@tab.Text</a></li>
      }
    </ul>
    }

    Then use the helper by providing the parameters it needs…

    @tabs(
      new Tab { Text = "Google.com", Url = "http://google.com" },
      new Tab { Text = "Hugoware.net", Url = "http://hugoware.net" },
      new Tab { Text = "LosTechies.com", Url = "https://lostechies.com" })

    This works pretty well for the most part but it is pretty limited in what it can do. Lets look at another approach.

    Providing A ‘Template’

    In the previous example values were passed into the helper and used to generate the markup required. This time, the helper accepts slightly different arguments that will allow a bit more control.

    @helper dialog(string title, 
        Func<object, object> content) {
        <div class="dialog-box" >
          <h3>@title</h3>
          <div class="dialog-box-content" >
            @content(null)
          </div>
        </div>
        }

    This example uses a simple lambda (Func<object, object>) as an argument to provide markup to render. This allows the Razor block (@) to be passed in as an argument for the helper.

    @dialog("User Status", 
      @<strong>User is offline!</strong>
      )

    Now, the content is generated by an external source!

    Using Types With Your Templates

    So far the examples have used Func<object,object> as a template argument and then invoked the method with null as the argument. As it turns out, not only can you provide a value for that argument, if the argument type for the Func<…> is provided then it can be used from within a template.

    @helper user_status(IEnumerable<User> users, 
      Func<User, object> online, 
      Func<User, object> offline) {
       
      <div class="user-status-list" >
          <div class="user-status" >
          @foreach(var user in users) {
              <h3>@user.Username</h3>
               
              if (user.IsOnline) { @online(user); } 
              else { @offline(user); }
          }
          </div>
      </div>
    }

    The helper above passes each User into the correct template. Now, a User can be referenced by using item from within the template.

    @user_status(users, 
         
        online:@<div class="user-online" >
          User @item.Username is online!
        </div>,
         
        offline: @<div class="user-offline" >
            User @item.Username is offline!
            <a href="#" >Send a message!</a>
            </div>
            )
    

    Now, the contents of each template is unique to the User that was provided!

    Joining Los Techies!


    I’ve had a busy past couple of weeks – I’ve started a new job, packed and prepared to finalize the sale of my house – and now, I’m joining Los Techies!

    My name is Hugo Bonacci – I work for Xamarin as a designer/developer and in my spare time I write code or work on geek projects with my kids.

    It’s hard to sum up the sorts of topics you’ll see out of me but I’ll probably be mostly focused on UI and client facing interactions with web development. You’ll see a lot of JavaScript and ASP.NET MVC (maybe a hint of Ruby from time to time until I have something worth sharing :))

    I’m not particularly opinionated so I won’t be posting much about the right or wrong way to do things – just interesting tips and tricks that might help as you’re creating web sites.

    My personal site can be found at hugoware.com where you can look at some of my projects and other blog posts. You can also follow me on Twitter.

    Anyways, I’m looking forward to blogging here and I’ll have more soon!

subscribe via RSS