Cropper – a free, open source screenshot program for Windows

Cropper is a screen capture utility written in C#. It makes it fast and easy to grab parts of your screen. Use it to easily crop out sections of vector graphic files such as Fireworks without having to flatten the files or open in a new editor. Use it to easily capture parts of a web site, including text and images. It’s also great for writing documentation that needs images of your application or web site.

CropperUI

Get it on CodePlex: https://cropper.codeplex.com/

Cool tools for wireframing

Axure RP gives you the wireframing, prototyping and documentation tools needed to make informed design choices, persuade any skeptics, and document your design… and maybe win a few fans along the way. Choose the Standard edition for prototyping or go Pro to add documentation and collaboration features.

http://www.axure.com/

Balsamiq Mockups is a rapid wireframing tool that helps you Work Faster & Smarter. It reproduces the experience of sketching on a whiteboard, but using a computer.

Making mockups is fast. You’ll generate more ideas, so you can throw out the bad ones and discover the best solutions.

http://balsamiq.com/

My approach to comments on this blog

I don’t receive that many comments on this blog. As a result it allows me to be ruthless.

I like receiving on-topic questions or comments that add to the discussion. If your comment simply states “I came across this blog and I think it is great” whilst linking back to a website that appears to be spammy, then prepare to get blacklisted.

You will be marked as spam if you comment is off-topic and/or your comment website links to a spammy website (I have a low threshold) .

Don’t waste my time or I will waste yours. I error on the side of fuck you.

Common .htaccess Redirects

I’ve recently been redirecting one website content to another. Here are some useful common .htaccess file redirects.

#301 Redirects for .htaccess
 
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
 
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
 
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
 
#Redirect a sub folder to another site
Redirect 301 /subfolder http://www.domain.com/
 
#This will redirect any file with the .html extension to use the same filename but use the .php extension instead.
RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php
 
##
#You can also perform 301 redirects using rewriting via .htaccess.
##
 
#Redirect from old domain to new domain
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
 
#Redirect to www location
RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
 
#Redirect to www location with subdirectory
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/directory/index.html [R=301,NC]
 
#Redirect from old domain to new domain with full path and query string:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC]
 
#Redirect from old domain with subdirectory to new domain w/o subdirectory including full path and query string:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$
RewriteRule ^(.*) http://www.katcode.com/%1 [R=302,NC]
 
Rewrite and redirect URLs with query parameters (files placed in root directory)
 
Original URL:

http://www.example.com/index.php?id=1

Desired destination URL:

http://www.example.com/path-to-new-location/

.htaccess syntax:
 
RewriteEngine on
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301]
Redirect URLs with query parameters (files placed in subdirectory)
 
Original URL:

http://www.example.com/sub-dir/index.php?id=1

Desired destination URL:

http://www.example.com/path-to-new-location/

.htaccess syntax:
 
RewriteEngine on
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]
Redirect one clean URL to a new clean URL
 
Original URL:

http://www.example.com/old-page/

Desired destination URL:

http://www.example.com/new-page/

.htaccess syntax:
 
RewriteEngine On
RewriteRule ^old-page/?$ $1/new-page$2 [R=301,L]
Rewrite and redirect URLs with query parameter to directory based structure, retaining query string in URL root level
 
Original URL:

http://www.example.com/index.php?id=100

Desired destination URL:

http://www.example.com/100/

.htaccess syntax:
 
RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
Rewrite URLs with query parameter to directory based structure, retaining query string parameter in URL subdirectory
 
Original URL:

http://www.example.com/index.php?category=fish

Desired destination URL:

http://www.example.com/category/fish/

.htaccess syntax:
 
RewriteEngine On
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA]
Domain change – redirect all incoming request from old to new domain (retain path)
 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC]
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L]
If you do not want to pass the path in the request to the new domain, change the last row to:
 
RewriteRule ^(.*)$ http://www.example-new.com/ [R=301,L]
 
#From blog.oldsite.com -> www.somewhere.com/blog/
retains path and query, and eliminates xtra blog path if domain is blog.oldsite.com/blog/
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI}/ blog
RewriteRule ^(.*) http://www.somewhere.com/%{REQUEST_URI} [R=302,NC]
RewriteRule ^(.*) http://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC]

Source: https://gist.github.com/ScottPhillips/1721489

Google Material Design Bootstrap Theme

Material Design for Bootstrap is a theme for Bootstrap 3 which let you use the new Google Material Design in your favourite front-end framework.

material_design_bootstrap

Read more about Material Design for Bootstrap visiting the Github page.

Via Material Design for Bootstrap Theme

Bing Code Search for C# in Visual Studio

Ask a C# related question and get snippets inside your IDE.

Write your question as a special comment starting with three slashes ///. Your question may mention variables.Press the Tab key on the same line to get answers; press Enter to insert selected snippet.

via Bing Code Search for C# in Visual Studio.

An introduction to the MEAN developer’s stack

Welcome to get MEAN (MongoDb, ExpressJS, Angular.js and Node.js). Here’s a few great tutorials and resources to get you started with MEAN on Windows. Best of all, you can use Webmatrix 3 from Microsoft, which is entirely free.

First, What is MEAN? Valerbi Karpos of MongoDB’s post on MEAN here defining the stack.  I believe he’s credited with being the originator of the phrase -http://thecodebarbarian.wordpress.com/2013/04/29/easy-web-prototyping-with-mongodb-and-nodejs/ . Basically MEAN is a pure JavaScript stack conglomeration for full spectrum development.  Components areof MongoDB, ExpressJS (sometimes BackboneJS), AngularJS, and Node.Js. M-E-A-N. Valerbi does a good job of spelling out some of the synergies present.

So here’s my favorite links in each of the MEAN categories.  Enjoy.  Got extras talking about Azure + MEAN?  Post them in the comments and lets build the article base.

Via Azure – Why you gotta be so MEAN?

WebMatrix ships with site templates that make it easy to get started. The WebMatrix Node.js starter template is a starting point for a full Node.js application—it shows examples of routing, middleware, custom errors, and more. The WebMatrix Node.js starter template is built on express, a flexible framework for building web applications. For more information on express, visit http://expressjs.com.

Note: A full explanation of Node.js or express is beyond the scope of this article. For information on Node.js and express, see http://nodejs.org/ and http://expressjs.com.

via How to Use the Node.js Starter Template in WebMatrix

This article will guide you to start building up a website using Node.js using the MEAN stack. I will try to also help you with setting up your basic tools/infrastructure for developing the application like setting up node.js, mongodb etc. I am assuming you have some basic knowledge about Node.js and Javascript along with HTML etc. However even if you are new to node.js or the other technologies involved don’t worry, as the article involves a couple of different technologies, I’ll just try to scratch the surface.

What does the MEAN acronym stand for?

  • M – MongoDB (NoSQL document store database)
  • E – Express (Web framework for use in Node.js)
  • A – Angular.js (Client side Javascript MVC framework)
  • N – Node.js

The advantage of using this MEAN stack is all the components are very robust and popular and Javascript is used as the common language on both the client and server side. Also Node.js and MongoDB couple together very well.

I will define the popular technology stack below by category which is popularly used. I might not be using all the technology stated below in details but knowing the entire stack would help know what fits where.

Technology Stack Classified

  • Client
    • HTML5/CSS3
    • Angular.js as MVC framework
    • Javascript/Jquery
    • Bootstrap for responsive design
  • Server
    • Node.js
  • Data Access and ORM
    • Mongoose
  • Database
    • MongoDB

Keep in mind that although we are using the term ORM above in Data access, these NoSQL databases doesn’t define any schema so Mongoose might be a bit different than the other Object Relational Mappers like NHibernate or Entity Framework.

Via Node.js introduction using MEAN stack with WebMatrix

In this blog post, I will demonstrate how to build a web app with Node.js and MongoDB, and will deploy it on Windows Azure as a Windows Azure Web Site. Firstly, I will create a web site with Node.js, Express.js, Mongoose and MongoDB. Then I will create a MongoDB database on MongoLab, which is a MongoDB as a service hosted on Cloud, and finally deploy the web app to Windows Azure Web Site. The source code for the demo app is available on Github at https://github.com/shijuvar/NodeExpressMongo

About the Demo Web App

This is a simple Task management application which provide the functionality for add, edit, delete and list out the Tasks. The home page will list out the uncompleted  Tasks and List page will list out all tasks.

Node.js modules for the web app

The following NPM modules will be used for this demo web app.

  1. Express.js – A light-weight web application framework for Node.js
  2. Mongoose – MongoDB object modeling framework for node.js
  3. Jade – A server-side view engine for Node.js web apps, which will be used with Express application

Via Building and Deploying Windows Azure Web Site with Node.js and MongoDB by using Microsoft WebMatrix

The empty site provides a very basic example of using an http server – the same sample that’s available on nodejs.org. The Express Site is a basic application generated using the scaffolding tool in the Node.js framework express. The Node Starter Site is where things start to get interesting. This boilerplate is hosted on GitHub, and shows how to implement sites that include parent/child layouts with jade, LESS css, logins with Twitter and Facebook, mobile layouts, and captcha. When you create a new application using any of these templates, WebMatrix 2 is going to ensure node, npm, and IISNode are installed on your system. If not, it will automatically install any missing dependencies. This feature is also particularly useful if you are building PHP/MySQL applications on Windows.

Via NODE.JS MEET WEBMATRIX 2

 

Great tips on SEO for business blogging

The key takeaway is that you shouldn’t split your domains (even subdomains like blog.domain.com). Ideally use a directory structure such as domain.com/blog/.

Think about your blog site directory structure. Make it easier to navigate for both users and search engine robots.

http://www.airpair.com/seo/seo-focused-wordpress-infrastructure

FluentMigrator timeout when adding a new column to a large table

I recently had the requirement to add a new column to a large but not massive table, which had over 12 million rows. I needed to allow logical deletes, so I needed to add a boolean (BIT) column to that table. Arguably, I should have created the table originally with such a column, but hindsight is always 20-20.

My FluentMigrator scripts was simple:

[Migration(201407221626)]
public class LogicalDeleteMyTable : Migration
{
	public override void Up()
	{
		// new column mimetype
		this.Alter.Table("MyTable")
			.AddColumn("IsDeleted")
			.AsBoolean()
			.NotNullable()
			.WithDefaultValue(0);
	}

	public override void Down()
	{
		this.Delete.Column("IsDeleted").FromTable("MyTable");
	}
}

We have a number of automatic deployments for database migration using FluentMigrator.NET. The first few deployments were running against small test databases. Our test database has a bit of data in it, but nothing like the volume in production.

Luckily we had decided to pull back a copy of production to our UAT environment for this deployment. I was also working on a few anonymization and data archiving scripts, so I had needed a copy of production anyway. This turned out to be our saving grace.

As I said earlier, the production table had just over 12.5 million rows in it. When the FluentMigrator process step kicked off in Octopus Deploy, the script eventually timed out. Rather than immediately try and rework the script, I decided to up the timeout. Digging around in the FluentMigrator.NET settings wiki, I found that Paul Stovell had very smartly added a SQL command timeout override (in seconds) as a command line runner option/flag/parameter:

migrate --conn "server=.\SQLEXPRESS;uid=testfm;pwd=test;Trusted_Connection=yes;database=FluentMigrator" --provider sqlserver2008 --assembly "..\Migrations\bin\Debug\Migrations.dll" --task migrate --timeout 300

I tried a few more times whilst continually extending the timeout value, but the runner still timed out. Finally I extended the timeout to 10 minutes (600 seconds) and the script completely successfully. Wheeew!

In a future post I intend to cover ways in which you can add new columns to extremely large columns without such a performance hit.

Ben Powell is Microsoft .NET developer providing innovative solutions to common business to business integration problems. He has worked on projects for companies such as Dell Computer Corp, Visteon, British Gas, BP Amoco and Aviva Plc. He originates from Wales and now lives in Germany. He finds it odd to speak about himself in the third person.

%d bloggers like this: