Friday, October 11, 2013

Upgrade ASP .NET MVC 5 default layout to bootstrap 3

If you have started developing web applications with ASP .NET MVC 5 you might have noticed that it comes with bootstrap version 2 and the latest version 3. In order to upgrade the default template for version 3, you can use these files as a reference.


Right click solution -> Manage NuGet packages Updates -> Update bootstrap to version 3

***
Views/Shared/_Layout.cshtml
***
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    <div class="navbar navbar-default navbar-static-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" 
                    data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Application name", "Index", "Home", null, 
                    new { @class = "navbar-brand" })
            </div>
                
            @Html.Partial("_LoginPartial")

            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li class="active">
                        @Html.ActionLink("Home", "Index", "Home")
                    </li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            Dropdown <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="#">Action</a></li>
                            <li><a href="#">Another action</a></li>
                            <li><a href="#">Something else here</a></li>
                            <li class="divider"></li>
                            <li class="dropdown-header">Nav header</li>
                            <li><a href="#">Separated link</a></li>
                            <li><a href="#">One more separated link</a></li>
                        </ul>
                    </li>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </div>
    <div class="container">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>
***
Views/Shared/_LoginPartial.cshtml
***

@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, 
          new { id = "logoutForm", @class = "navbar-form pull-right" }))
    {
    @Html.AntiForgeryToken()
    <ul class="nav navbar-nav navbar-right">
        <li>
            @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", 
                 "Manage", "Account", routeValues: null, 
                 htmlAttributes: new { title = "Manage" })
        </li>
        <li><a href="javascript:document.getElementById('logoutForm').submit()">
            Log off</a></li>
    </ul>
    }
}
else
{
    <ul class="nav navbar-nav navbar-right">
        <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, 
            htmlAttributes: new { id = "registerLink" })</li>
        <li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, 
            htmlAttributes: new { id = "loginLink" })</li>
    </ul>
}
*** Content/Site.css *** Remove padding-top from body

Monday, February 4, 2013

Add Twitter Bootstrap to MVC4

Unzip bootstrap files into the /Content directory.

Add the following lines to App_Start/BundleConfig.cs


bundles.Add(new StyleBundle("~/Content/bootstrap/css/bundle")
.Include("~/Content/bootstrap/css/bootstrap.css"));
bundles.Add(new ScriptBundle("~/Content/bootstrap/js/bundle")
.Include("~/Content/bootstrap/js/bootstrap.js"));


Add the following lines to View/Shared/_Layout.cshtml

@Styles.Render("~/Content/bootstrap/css/bundle")
@Scripts.Render("~/Content/bootstrap/js/bundle")

Note that jQuery must be included before the Bootstrap js-bundle.

Thursday, April 19, 2012

Using Thunderbird in Linux with Office 365

My company is using Office 365, but as a software developer with a passion for *nix I really can't live inside a windows environment. So for email use Thunderbird and the splendid Lightning addon together with a calendar provider for office 2010. It works great!

Thunderbird Lightning Calendar Office 2010
http://www.1st-setup.nl/wordpress/?page_id=133

Using calendars from Office 365
http://www.1st-setup.nl/wordpress/?wp_super_faq=add-a-microsoft-office-365-calendar

Wednesday, April 27, 2011

Installing rmagick on ubuntu 10.04

I just installed ruby and rmagick on an ubuntu 10.4 server. Got some errors during the installation and thought i should summarize the procedure here:

Install ruby

sudo apt-get install ruby1.9.1 rubygems1.9.1


Install imagemagick


sudo apt-get install imagemagick


Tried to install rmagick

sudo gem install rmagick


Got this error:

ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1:in `
'


Found this page, which pointed med to install ruby1.9.1-dev package.


sudo apt-get install ruby1.9.1-dev


Ok, trying again to install rmagick

sudo gem install rmagick


Got this error:

ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.


Found this question on superuser.com which pointed me to install the libmagickwand-dev-package.

sudo apt-get install libmagickwand-dev


Finally, another attempt to install rmagick

sudo gem install rmagick




Building native extensions. This could take a while...
Successfully installed rmagick-2.13.1
1 gem installed
Installing ri documentation for rmagick-2.13.1...
Updating class cache with 0 classes...
Installing RDoc documentation for rmagick-2.13.1...


Success!

Thursday, April 7, 2011

DavMail and microsoft online exchange

DavMail

URL: https://red002.mail.emea.microsoftonline.com/EWS/Exchange.asmx
Enable EWS - check

IMAP
Server name: localhost
Port: 1143
User name: username@domain.com

SMTP
Server name: localhost
Port: 1035
Connection security: none
Authentication method: Password, transmitted insecurely
User Name: username@domain.com

LDAP
Hostname: localhost
Base DN: ou=people
Port number: 1389
Bind DN: username@domain.com

Wednesday, February 23, 2011

Wireless streaming from Spotify to PS3


After many hours trying to get wireless streaming from Spotify to Playstation 3, I finally found a working solution on Linux (ubuntu).

My setup:


I used the solution described in this blog.

But I failed miserable with only streaming the echoes of silence...

Then I found another Spotify streaming blog post, only this time for squeezebox.

This inspired me to try the same trick creating a PulseAudio null-sink.

pactl load-module module-null-sink sink_name=spotify


Setting the sound output to the new sink:



install the lame encoding library to be able to stream mp3:


sudo aptitude install gstreamer10.0-plugins-ugly-multiverse


make sure icecast is running

/etc/init.d/icecast2 start


and then fire up a mp3 stream:

gst-launch-0.10 pulsesrc device=spotify.monitor ! audioconvert ! lame bitrate=320 mode=stereo ! shout2send ip=localhost port=8000 password=PASSWORD mount=spotify.mp3


I then added the following line to my WEB.conf in the ps3mediaserver root folder:

audiostream.Web=Spotify,http://localhost:8000/spotify.mp3


Now start up your PS3 and PS3 Media Server. On your PS3 go to the 'Audio' section, select 'PS3 Media Server', Web-folder and Spotify. Be patient it takes a couple of seconds before it starts.