jQuery onhashchange
Posted by thorsteinsson in Uncategorized on March 11th, 2010
When I was working on improving my jQuery onhashchange plugin I found a better one online. Ben Alman wrote a jQuery plugin for the onhashchange event so you can use jQuery bind function to bind your event. I have decided to drop my plugin and use that one instead.
I am still working on jQuery routes and will share more information about it soon. It will now use the hashchange plugin from Ben Alman.
Mix 10 in Las Vegas
Posted by thorsteinsson in Programming on March 5th, 2010
Only one week until I go to Las Vegas to attend Mix 10. This conference is held by Microsoft and is targeted at web designers and developers. I have wanted to go to Mix for a long time and finally I am going.
I am going behalf of my company and will be focusing on HTML 5, jQuery and ASP.NET AJAX. I will also attend few ASP.NET MVC and MVVM presentations. There is a lot of great names on the speakers list and I look forward to meet all the clever people.
You can check out the sessions at http://live.visitmix.com. I am planning on blogging here about the stuff I learn at Mix, so if you have any questions for the speakers or want to learn more about something specific then please leave a comment.
C# string format in JS
Posted by thorsteinsson in Programming on March 1st, 2010
The string format function in C# can be handy in JavaScript.
String.prototype.format = function() {
var regex = /\{(\d)}/g;
var text = this;
while (match = regex.exec(text)) {
text = text.replace(match[0], arguments[match[1]]);
}
return text;
};
I use regular expressions to match numbers with curly braces and then loop through the matches and call string replace.
Usage:
var color = 'blue';
'{0} is {1}'.format('the sky', color);
Using EF with MySql and Visual Studio 2010 RC
Posted by thorsteinsson in Programming on February 20th, 2010
So you just downloaded Visual Studio 2010 RC and want to connect to your MySql database and have the powers of the Entity Framework (EF)?
Your problem is probably that you can’t find the MySql connector when you add data source in Visual Studio 2010 RC. MySql just got VS 2010 support 15th feb 2010, but the connector is not stable yet. Go to the Development releases tab to download the latest connector. You must get MySql Connector /NET 6.3.0 alpha or later.
After installing the MySql Connector /NET 6.3.0 alpha you can open the Server Explorer, press Connect to Database and there you should see MySql in the list of data sources.
Note: Entity Framework does not support ODBC drivers and that is why you need the ADO.NET connector from MySql.
Titler – javascript game in the titlebar
Posted by thorsteinsson in Uncategorized on February 7th, 2010
Play the game now – See the source on Github
I had an idea the other day about creating a game using only the window title bar. Afterwards I just needed to try it out and see if I could do it, so here is my game. It is really simple but can be extended.
The controls are up and down arrow and you have to watch out for flying objects. On the left side you see what level you are on and how many lives are left.
The “magic” behind the game is setInterval to call a function every x milliseconds and window.title to change the text in the title bar. For more detail, look at the source on Github.
14 Days of jQuery
Posted by thorsteinsson in Uncategorized on January 25th, 2010
The jQuery team is releasing a new version of jQuery, version 1.4. They have improved the performance a lot and I am specially happy with the performance increase in remove() and data(). Check out jquery14.com for more info about this new version.
Mediatemple hosts the jQuery sites and has a jQuery competition during the 14 days of jQuery. I decided to submit a site I made where I used a lot of custom jQuery to get fancy effects. The website is for an Icelandic travel agency named VIP Iceland. Check out the site at vipiceland.is.
I am the daily winner on day 11!!
That is great news for me and because I won, I will be releasing the plugins I created for this website. My pageflow plugin is used to scroll between pages and slideshow plugin to view the photos. More info here soon.
jQuery onhashchange
Posted by thorsteinsson in Programming on October 15th, 2009
I implemented window.onhashchange for older browsers using jQuery Address. Check it out here.
I am currently working on a jQuery routing plugin to be able to define routes to javascript functions. Routes are friendly urls with variables in location.hash. It is built on top of window.onhashchange and will be released soon.
Having fun with Powershell
Posted by thorsteinsson in Programming on June 14th, 2009
It is awesome that you can use the .NET framework in Powershell. I am working on a website that contains a gallery. I got a lot of pictures sent in different sizes. At the moment I am only interested in pictures in a certain size. I used Powershell to find pictures in a folder with a specified height. Take a look.
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
foreach ($file in get-childitem c:\web\photos -Filter "*.jpg" | where {[System.Drawing.Image]::FromFile($_.fullname).Height -eq 425 })
{
cp c:\web\photos\$file c:\web\photos\chosen\$file
}


Comments