Named CSS Grid areas with Stylus

I recently started learning the new CSS Grids, and I love it! If you don’t know what CSS Grids are yet, you have to watch this talk by Morten Rand Hendriksen and this one by Rachel Andrew. They’re great, and I found them to be enough to start experimenting with grids.
More

Download a complete single page with wget

A simple way to download a complete page

Very much inspired by Guy Rutenberg,
I only modified the snippet slightly with -N, which validates timestamps and doesn’t download duplicated ( but does overwrite local files with the new changes ) and robots=off, so I wouldn’t download the robots.txt

A simple one-liner to convert all JavaScript to CoffeeScript

A simple one-liner to convert all JavaScript in a folder to CoffeeScript

First, make sure you have installed “js2coffee” ( and js2coffee.org is real cool for single files too ):

And then just paste this:

-it options modifies the spaces to tabs, remove it if you prefer spaces.

Enjoy!

CoffeeScript Blows. Minds.

Was looking for a simple way to write an alternative of PHP’s in_array() function in JavaScript, and since I’m using actually writing CoffeeScript, decided to look there as well. And sure enough. Mind Blown.

 

Turns into

 

 

 

How to clean an URL with Regex

A regex pattern to fix 1st level domains. Useful for when data is submitted from users:

Turns this:

google.com
www.google.com
google.com/
http://google.com
http://www.google.com
http://www.google.com/

Into This:

http://www.google.com
http://www.google.com
http://www.google.com
http://www.google.com
http://www.google.com
http://www.google.com

Expression:

PHP Usage:

Danish ZIP Codes (PHP Array)

Just in case someone needs this some day.

Usage: [0] => Region Title, [1] => Min ZIP Number, [2] => Max ZIP Number

Trouble replacing an ampersand ( & ) in PHP with str_replace – Solution

Now this took about a half an hour until I figured this out. Posting this, just in case someone finds it – I hope I save you 30 minutes.
I fetched a link from HTML content with preg_match(), and I had to replace some data in that link.

For some reason – the ampersand ( & ) wasn’t found and so the string wasn’t replacing it. At the end I figured it’s the ampersand problem, and here is the fix (sometimes the simplest things…)

Update:
I had to use this method, because the ampersand was extracted from HTML document with preg_match. To avoid issues like this – use

Pseudo Class Fix in IE

CSS Pseudo Classes are just plain awesome.

Unfortenatley Internet Explorer 6 and 7 doesn’t support them. I am very thankful that I found a Javascript Fix for that, so I wanted to share.

This little awesome JavaScript not only fixes that, but a whole bunch of unsupported things in IE.

[info]List of fixes: http://ie7-js.googlecode.com/svn/test/index.html [/info]

[download]http://code.google.com/p/ie7-js/[/download]

WordPress archive title display switch

While creating my Blankwork I was looking for different examples of archives pages, since I never used them much. In the end, I was pretty disapointed with all of them.

For example, an else if statement list with opening PHP tags every time, repeating same text and adding comments in between. In my code editor it looked like one big rainbow. An example (which is short and a bit more readable):

I like when everything is clear and easy readable even in code. of course you can dig-through anything, but I made this little snippet just for those, who want a little more clean archives code.

So, I made my own little snippet, which is a bit more Designer friendly, here you go: