An introduction to CSS @counter-style

The characters that indicate items in a list are called counters — they can be bullets or numbers. They are defined using the list-style-type CSS property. CSS1 introduced a list of predefined styles to be used as counter markers. The initial list was then slightly extended with addition of more predefined counter styles in CSS2.1. Even with 14 predefined counter styles, it still failed to address use cases from around the world.

Now, the CSS Counter Styles Level 3 specification, which reached Candidate Recommendation last week, adds new predefined counter styles to the existing list that should address most common counter use cases.

In addition to the new predefined styles, the spec also offers an open-ended solution for the needs of worldwide typography by introducing the @counter-style at-rule — which lets us define custom counter styles or even extend existing ones — and the symbols() function. The latter is a shorthand for defining inline styles and is useful when the fine-grained control that @counter-style offers is not needed.

This is the excerpt from an article I wrote in the hacks.mozilla.org blog when @counter-style was shipped in Firefox. The article provides a guide to using the new counter features of CSS Level 3. Please read the full article here. See a demo of various @counter-style usages here (works only in Firefox).


Cultural Learnings of China for Make Benefit Glorious People Everywhere

Excuse the title 😛 I just wanted to share a few things that might be helpful to know if you are visiting China for the first time.

  1. Food! – Food in China is definitely not the ‘Chinese’ you eat in your country. I found real Chinese food much more tastier (and healthier, coz they eat it every day). Also the variety in food is overwhelming. Do try everything you can get your hands on.
  2. No tipping in restaurants.
  3. China is not cheap. I, like many others, assumed that since most of the goods we use are made in China, I could get stuff for cheap from there. But this proved a myth. My Nike shoes (made in China) costs the same, if not more, in China, as it is at home. This is especially true if you are visiting only the big cities. The places that manufacture these goods are in the more remote places.
  4. Haggle – don’t be ashamed to haggle when you go around buying from local vendors. You can often negotiate and bring the price down much lower than what was offered first.
  5. Get a guide who speaks Chinese. Unless you or someone traveling with you know Chinese, make sure you get a guide who can speak Chinese. English is of no help in China, especially if you are traveling outside of big cities like Beijing. But even in Beijing, the vast majority (save for kids) don’t speak English. Anyway, it wouldn’t hurt learning a few useful Chinese words and sentences before your trip.
  6. Be wary of counterfeit currency when you spend money and get change from someone. I don’t know how to detect counterfeit Chinese currency, so better check about it somewhere before you go.
  7. Chopsticks – People eat with chopsticks, not spoon or fork and knife. You could find it a little difficult to eat with a chopstick at first, but stick with it (pun intended) and you will get considerably better in a couple of days. And using chopsticks, instead of spoons like some lame foreigners, will earn you respect from the Chinese. (Now don’t go embarrassing yourself trying to drink soup with chopsticks; that’s what they give you the spoons for).
  8. Continue Reading


10 funny bug reports from Mozilla’s bug system

Here are some of the funniest bug repots I found in bugzilla.mozilla.org, the bug tracking system used by all Mozilla projects. I had fun compiling this list; hope you have fun reading them too.

IMPORTANT: Please do not add further comments to the bug reports. Doing so would send mails to a lot of people.

Bug 95849 – “Lack of Sex is interfering with my ability to triage bugs”

’nuff said

Bug 330884 – “This privacy flaw has caused my fiancé and I to break-up after having dated for 5 years.”

Bug 52094 – “hyatt should give ben $50”

Bug 98491 – “Vending machine on the 2nd floor has raised prices by $0.05”

Bug 665750/Comment 38 – “Export a subset of pages for offline reading”

Bug 122411 – “Mozilla does not have a kitchen sink”

Bug 216332 – “Mozilla doesn’t work during massive power outages.

Bug 125287[email protected] owes me some hot scandinavian blondes”

Bug 60455 – “Mozilla doesn’t add time to the day”

Bug 46244 – “need to go to denny’s”

Thanks to @tofumatt for bringing up some of these 🙂
Lemme know if you have come across anything that I haven’t listed.


Rants about the HTML anchor tag

Links are probably the most important of all the elements on the Web. Links are what make the Web, a WEB – of interconnected resources. Here are a couple of things you probably didn’t know or may be did, about links, aka anchor tags. Normal text, as the text content in a book is considered to be linear, as information flows from one end to the other there, linearly. HyperText is text that is not linear. HyperText can have an additional dimension, which is the meaning defined by a link. The ability of HTML to have links is why it is called HyperText Markup Language.

the download attribute

The traditional way of prompting file download is by adding a ‘Content-Disposition’ header, which is done at the server side. HTML5 introduces a download attribute to your anchor tag and it will prompt file download of the linked resource when the link is clicked.

<a href="video3482.mp4" download>Download video</a>
Providing a value for the download attribute is optional, but if you provide a value, then the download prompt will have that value as the default filename for the file to be saved.

Later versions of Firefox (v20+) requires that if download attribute is specified, then the value of href must be a resource of the same origin. And, as of now, as you would expect, IE doesn’t support the download attribute yet, but they are planning to.

#top will scroll to the top

HTML5 defines that if the value of href is not a valid element ID in the page, then if the value of href is #top, clicking on the link will scroll to the top of the page.

href stands for hypertext reference

When I first learned html, I found the href attribute hard to remember. It made no sense to me. I read it as h-r-e-f. But later I deduced that it was actually h-ref and then everything made sense. Like everyone, I also assumed that the h stood for hypertext or hyperlink. Well, today I did confirm that h is for hypertext. So href is in fact hypertext reference. Tim Berners-Lee says so.


Event Report: Firefox OS App Days Kerala – 22nd June 2013

Friends,
I’m really excited to tell you about the Firefox OS App Days we conducted at Kochi (Kerala, India) on 22nd June.

Short version:-

The event went better than we hoped for. 56 participants and 9 Mozillians attended. 14 apps were demoed. Had a remote session over video conf by Nick Desaulniers of Mozila Corp. Got 3 news paper coverages including one in a national daily. Succeeded in creating a hyper buzz about Mozilla in the state of Kerala. Getting lots of requests from colleges to conduct mini app days there – 2 mini app days already in motion. Continue Reading


12 Things That Would Make You A Better Software Developer

Disclaimer (2017): This post was written a few years ago when I was relatively new to programming, so take with a grain of salt.

12 valuable lessons I learned from my two years experience as a developer. Some are bits I picked up along the way, but some are hard learned tidbits of wisdom I learned from my own mistakes.

The 12 points discussed in the post are the following:-

1. Know your tools
2. Modularize
3. Error messages are your friends
4. Plan, Plan, Plan
5. Maintain predictability in code
6. Write beautiful code
7. Refactor
8. Central location for configuration/settings
9. Push towards automation
10. Keep the comments updated
11. Write jokes in comments
12. Choose the right team

 

1. Know your tools

Programming is no longer just typing code out of the air into your text editor and compiling it after you are done. Programming is more of an interactive process now.

Lots of tools are available now, that can boost developer efficiency. Most programming languages have rich IDE’s with features such as “intellisense”, auto-complete, realtime syntax checking, profiling and debugging assistance, source control integration etc built-in. Knowing these various tools and features are not a must to be a great programmer, but, without a question, better tools can boost your efficiency as one.
Continue Reading


‘Realtime’ Chat with WebSocket and NodeJS

Update (2017): This post is outdated and shite. Please look elsewhere for better examples of similar apps. If you insist on seeing the naive code I wrote for the demo, there is a github link in the post.

DEMO (link removed)

(Open the chat in two or more browser windows/computers and check how fast the realtime updation is!)

Gmail chat, Facebook chat etc were implemented using a technique – rather a hack – called long polling[1]. It is the technique where the client initiates a request to the server. The server rather than returning the client with a response, keeps the connection open for a longer time. The server only returns to the client with a response when it (server) has something new for the client. The advantage of long polling over normal polling are reduced latency and saving from the overhead of sending too many short http requests. Continue Reading


Web service API Specification Doc Template

Finally I got sick with the webservice spec documents we were using at my previous employer. I searched all over the web for a document template that I could use for laying out our new web service’s API specification. I found several ones – good and bad -, but none were up to my expectations. So I decided to create a document template myself. My key design goals were the following:-

  • Ease of use
  • Clear
  • Concise
  • Not boring to look at.

I finally came up with a document template that I (and my colleagues) liked. Hope you find it useful too. Its created in Google Docs and shared ‘publicly’, so you can easily copy it and use it for your own projects.

See it in action -> Web service API Specification Document Template

 

Click here to use the template

(To use the template, make sure you are logged into your Google/Gmail account and click the above link. You should see a ‘Use this template’ button on the right top corner of the page.)

Tips for use:-

  1. Be consistent
  2. Use colors, fonts, font size etc to visually distinguish and classify things.
  3. Use fixed width fonts (courier, monospace etc) for showing code.
  4. Don’t clutter it up with too many colors and fonts.
  5. Managing and updating a good document is not very easy; but remember, everything worth doing is difficult anyway!

So what do you think? Like it? Where do I need to improve it?


New Year Resolutions

New year is here and crazy people all over the world are busy making new year resolutions that they know they will stop following just a few days into the new year. Yet here is another stupid guy’s new year resolutions – as a humble tribute to all those out there crazy enough to take unrealistic decisions and follow their crazy minds.

Below are my “resolutions” for the year ahead.

1. Do at least one good thing a day.

2. Publish a blog post at least once every two weeks.

3. (and here is the usual -> ) Of course, start working out 😀

4. Do more stuff outside of the computer. Carpe diem.

Update (Feb 2013): Yeah, yeah, yeah.. Nothing worked (as usual) :p


How to geek up your web server

A screenshot of my development server

I dislike default. Default is easy, and will always work. But accept it, default is boring.

Let’s see how to spice up your web server a little bit. If you want to see how our server is going to look like after we make the changes, click the demo link below.

Demo ~ Download Source

Basically what we are going to do is to add a Header file and a ReadMe file for our directory listing page. The header file is a text file that is rendered above the content list in a directory and ReadMe is displayed at the bottom. To add the Header and ReadMe, do the following:-

 

1. Open your httpd.conf file

The httpd.conf file is usually located in the /etc/apache2 directory. Open this file, or open your virtual hosts file (usually a file called 000-default) located inside /etc/apache2/sites-enabled/

2. You should see a lot of stuff like the following:-

DocumentRoot /home/Dev/Server
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

<Directory /home/Dev/Server>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

3. Find your virtual host

(the folder where your website files are stored) and add the following two directives there.

    HeaderName /.ServerFiles/HEADER.html
    ReadmeName /.ServerFiles/NOTICE.html

.ServerFiles is a folder inside my webserver root. Notice the “.” (dot) in front of the folder name. As you know, files and folders starting with “.” are hidden in Linux.

So I just created a hidden folder inside my webserver root folder and added two files html files in it HEADER.html and NOTICE.html.

 

After adding the Header and ReadMe directives, my host defenition looks like this:-

<Directory /home/Dev/Server>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    HeaderName /.ServerFiles/HEADER.html 
    ReadmeName /.ServerFiles/NOTICE.html
</Directory>

4. And add Header and ReadMe to style your server!

You can download and use the Header and ReadMe file I’m using here or see how the server will look like if you use my Header and ReadMe.

 

You can use pretty much any kind of HTML, CSS and Javascript in these files. You can even load jQuery there and do some of that pretty fancy effects there. However, try to keep it light.


Pages:1234