For the last decade javascript has been a language that has almost exclusively been run on the client side, in the web browser. But during the past year it seems like Javascript has found its way to the server side as well, to the joy of some developers while others wrinkle their nose and wonders why you would ever use Javascript for something more advanced than client side processing.
Last week i had a discussion with a friend about C# and passing parameters to methods. My friend asked why it is possible to use the ‘ref’ keyword for a reference type in C# when passing it to a method, he was under the impression that reference types are passed by reference to methods. This seems to be a quite common misunderstanding about C#, to make it clear:
Reference types are always passed to methods by value (unless you use the ‘ref’ keyword)
Last week I posted the source code to a small program I wrote in Java to merge images into a sprite. This week I present the same application but in C#, pretty much translated line by line
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
namespace NSpriteGenerator
{
class Program
{
staticvoid Main(string[] args)
{
if(args.Length != 2)
{
Console.WriteLine("Usage: NSpriteGenerator {path to images} {output file}");
return;
}
var imagePath = args[0];
var outputFile = args[1];
var imageFolder = new DirectoryInfo(imagePath);
// Read images
var imageList = imageFolder.GetFiles("*.png")
.Select(file => Image.FromFile(file.FullName));
// Find max width and total height
var maxWidth = 0;
var totalHeight = 0;
foreach(var image in imageList)
{
totalHeight += image.Height;
if(image.Width > maxWidth)
maxWidth = image.Width;
}
Console.WriteLine(string.Format("Number of images: {0}, total height: {1}px, width: {2}", imageList.Count(), totalHeight, maxWidth));
// Create the actual sprite
var currentY = 0;
using (var bitmap = new Bitmap(maxWidth, totalHeight))
First we need to install the htpasswd application, it is located in the apache2-utils package. This package has no dependencies on apache, so it is safe to install it – it will not download the full apache for you
To install it on ubuntu type:
sudo apt-get install apache2-utils
Once installed we can use it to create an htaccess file.
For some time I have been playing around with writing games for Android. The game loads the graphics in form of image sprites, so I needed a way to easily stick several png images into one image. I though there would be tons of free applications available for this purpose, but I didn’t find any, so I decided to create my own sprite generator.
The code is short and simple. Please feel free to use it as you please!
I have been reading about this new startup that offers a service called AppHarbor. It seems very much as the same idea as Heroku for Ruby, but for .NET. The basic idea is that you deploy your code by pushing your code onto the server using Git, the server then builds, runs unit tests and deploys your application. Super simple!
When I first read about AppHarbor I got the impression that is was running ontop of Microsoft Azure, which turned out to be all wrong. AppHarbor is running in the Amazon Cloud on EC2 instances. When it comes to databases AppHarbor provides access to MySQL and MSSQL. Interestingly they recommend users to use MySQL:
A few weeks ago I posted a video where Windows was upgraded all the way from Windows 1.0 to Windows 7. This week I found a video of a guy who compared all versions of Internet Explorer, from version 1 to the recently released version 9. Quite hillarious to see that IE5 actually scored better than IE8 in the Acid 3 test
Yesterday I installed Visual Studio 2010 SP1 on my home computer. After the installation I wanted to upgrade MVC3 to the RTM version (I had the RC version installed), so i uninstalled the RC and downloaded the new version. The installation came half way, then stopped, in the log file i found this:
Installation failed with error code: (0×80070643)
Not very helpful, but at least something to google. Then I found this blog post. The author describes pretty much the same issue that I had, so I did what he suggested, unpacked the installer using 7-Zip and installed the MSI packages in the following order:
1. aspnetwebpages.msi
2. aspnetwebpagesvs2010tools.msi
3. aspnetmvc3.msi
4. aspnetmvc3vs2010tools.msi
5. nuget.msi
This happily installed MVC3 without complaining. Thanks Michael!
ReSharper is the absolut must have for Visual Studio. It provides very improved navigation and search, refactoring, code generation, code cleanup and unit testing. I have gotten so used to having ReSharper installed so today I have a really hard time using Visual Studio without it.
PowerCommands 10.0 is a set of useful extensions for the Visual Studio 2010 adding additional functionality to various areas Visual Studio. This is some of the commands I find must useful:
Productivity Power Tools from the Microsoft Visual Studio team contains a lot of great extensions
Very much improved dialog for add reference
Solution Naigator – a enhanced Solution Explorer
Improved tab system for editor
Highlight current line (isn’t it weird that VS is missing this feature?)
One annoying ‘feature’ is the triple click to navigate to source, never got it to work properly so I disabled it. Some shortcuts also colide with ReSharper so some tweaking is needed to make it work perfectly.
Really impressive to see that it actually is possible to upgrade all the way from Windows 1.0 (DOS 5.0) to Windows 7 and keep some of the applications and user settings. The only OS I missed was Windows ME (not that any sane person used that OS but anyway), Andy explains that Windows ME did not provide an upgrade path to Windows 2000 and that is why he left it out. Read more details on his blog.
It would be fun so see someone do the same with for example Ubuntu or Redhat, upgrade from the earliest version to a current version.
Joe:
It looks like IceCoffee Script may provide the 'await' keyword to JavaScript. http://maxtaco.github.com/coffee-script/
Florian:
Dealing with events has two primary fashions: imperative (synchronous) code, and callback (asynchronous) code.
Both are legitimate styles, for some
Joe:
I think we haven't seen true PaaS offering yet in Azure. If you use a webrole you're still running on your own VM. This is still not true multi-tena
Welcome to source code bean! On this site I post stuff that I encounter in my job and spare time. The content is mostly related to .NET development, but my interest in techonology is very broad, so often you will find posts on totally different subjects!