After all this time? Always

Alan Rickman, the English actor, well known for playing Severus Snape in the Harry Potter movie series, passed away at the age of 69 today. They say he had cancer. (No I don’t know which cancer it was,nor have I got any idea about how long he had had it and how much people knew about it. )

tumblr_mu703fndEU1sk77e0o1_500 (1)
Being one of those that hate Snape during the first 6.7 books, and at the end can’t help but forgive him, and also one of those who have seen Rickman as Snape for so long that they can’t see him as anyone else, _(he did, after all, make a great Snape,) _I feel strangely sad about the news. Still, I don’t plan to write an essay. I’ve said what I had to say.

When I’m 80 years old and sitting in my rocking chair, I’ll be reading Harry Potter. And my family will say to me, “After all this time?” And I will say, “Always.” – Rickman.

Remix OS – What Google need’s to ditch Chrome OS for

I could explain here, but I’d rather you simply read The Verge’s post about it. 

Highlight menu link of the current page.

On some websites, regardless of whether or not they are wordpress or even PHP, the menu link for the page you are viewing gets highlighted or it becomes active. _An example could be the 2014 theme for WordPress (see how, in the nav bar at the top, the link for home is green?) _or css-tricks.com (link for the current page is orange.)

In static web pages, there could be more than one ways of doing this, and I’m not even gonna go there. But in dynamic websites, where there could be tons of pages with the same elements loaded, like the nav, the header, e.t.c. you can’t really change the attributes of a certain list item to suit a particular page.
Now the thing is, this isnt exactly rocket science.. Most good WordPress themes have this by default, but thanks to those few that don’t, I know that there’ll always be those who’d ditch a theme they spent ages styling on, simply because they’ll be tempted to use one that has it.

The day before I was modifying a theme, and I was almost completely done making it look like I wanted to, when I noticed that the css for :active state on the links didn’t apply. Of course that was stupid, no one really bothers with the active state anyway, they usually just define their own class.. After comparing the theme with another, and failing to find out how a general theme does it, I decided to code it in myself.

CSS-Tricks has this age old tutorial video  that shows a way to code it in yourself. Basically the idea is to parse the URL, and get the page request from the permalink. If you played the video, you can see how he got the page’s name and he applied it to the body as an id, and in his css he defined a style for body with ids matching the names of all his pages.

I however would do it slightly differently.. Just like he did, we get the request URL, get rid of slashes and question marsk (if any,) and apply it to a var ready to be echoed. But instead of applying and id to the body, and adding a comma separated “body#pagename” a number of times, we can define css for a particular class, like, for example “.current,” and add a script to the page, which gets the page’s name from the url, and finds the menu item with that name in it’s “title” attribute, and applies the “.current” class to it.

So all you gotta do is add the style for the .current _class to the css file and then add the php from that css-tricks tutorial (_the $page variable,)  to the header.php. And then you need to add a small Javascript script, that takes that $page var (don’t underestimate the power of <?php echo $page; ?>,) and applies the class to the corresponding menu link.

As a bonus, I will add below all the code you need to make this work.

<?php
$page = $\_SERVER[&#8216;REQUEST\_URI&#8217;];  
$page = str_replace(&#8220;?&#8221;,&#8221;&#8221;,$page);  
$page = str_replace(&#8220;/&#8221;,&#8221;&#8221;,$page);  
$page = str_replace(&#8220;.php&#8221;,&#8221;&#8221;,$page);  
$page = $page ? $page : &#8220;home&#8221;; 
?>

Add this PHP at the very top of the header file.. before _everything, _and then, anywhere below below the nav markup, add this JS script:

<script>  
nav = document.getElementsByClassName(&#8220;nav&#8221;)[0];  
nav = nav.getElementsByTagName(&#8220;a&#8221;);  
for(i=0;i<nav.length;i++){  
  if(nav[i].getAttribute(&#8220;title&#8221;).toLowerCase() == &#8220;<?php echo strtolower($page);?>&#8221;){  
    nav[i].setAttribute(&#8220;class&#8221;,&#8221;current&#8221;);  
  }
}  
</script>

You might have noticed that this only works if the container of the nav has a “.nav _class to it. Even if it doesn’t that can simply be added, and if there’s a different class name you are inclined to use, then simply use it, or if there’s an id, replace the “_getElementsByClassName” with_  “getElementById.” _But that wasn’t just it. Another prerequisite for it to work is for the _a _tags in the nav to have _title _attributes. So yeah maybe I’m just wasting my time posting this. But _hey! _Whatever works, works.

The Swagway (and clones) “hoverboards” suck

Am I honestly the only one who thinks that?
Reasons:

  • They don’t hover.
  • They aren’t anything like a hoverboard is supposed to be.
  • People call them hoverboards.
  • They are slow and impractical. And therefore useless for the average Marty.
  • They cost a ridiculous amount.

I understand that the fact, that we don’t have hoverboards even after the BTTF day and its almost 2016, hurts.. Hoverboards are like the thing everyone expected to just somehow arrive with 2015, and then the year started and we were no closer to getting hoverboards then we were to getting an Android-based Apple device. Even then there was a small ray of hope.. that it wasn’t October ’15 yet, and so the world waited, until we were a day from the BTTF day and that was when we knew that we weren’t getting them, but did that mean we had to go for such a bullshit substitute? The “substitute” that doesn’t even remotely come half as close to the hoverboards in the movie as the first maglev based hoverboard.. or the Lexus one, or the Hendo?

Buy them if you want people, but please don’t call them hoverboards.

Rust is to iron

what mold is to bread

Currencies

are languages

Shared Cricket Stadium for Pakistan and India.

A few days back, I was talking to a friend I picked up online, who happens to be an Indian, and as we were discussing some things loosely related to cricket, it hit me.

There’s this whole thing about Pakistan vs India matches. People, adults and teens and kids alike, all gather together some place where the live game is projected on a large screen. There’s something too exciting about this even for those who aren’t into cricket much. There’s this feeling of unity all thanks to this rivalry between the two countries. Note that this rivalry here, that I speak of,  is much more of a friendly rivalry, and there’s technically nothing wrong with it, with all those cheeky advertisements and all, it’s all about showing the other country who plays better.

The big idea is that a stadium, funded by both countries, be built, with the consent of the governments of both, where all matches involving Pakistan and India take place (tough but allow me to add “when possible”), preferably those that the two countries play against each other, and people from both the countries could come and watch them together. 

Read Full Post

Using two routers to extend a network – Part 2

The goal: Create two separate networks, each with its own router. Both routers will have different security and SSID, while the WAN settings of A are configured to connect to the internet while B, being a subnetwork of the first, will connect to the internet through it.

Now the thing is that the LAN and WAN IP addresses can not be in the same subnet, so here’s what I did. I changed the subnet of A from 255.255.255.0 to 255.255.0.0 .. Also, I changed to IP Adress to 192.168.1.1. That’s all the config you need to do in Router A, assuming it is already configured to connect to the internet.

Now get an Ethernet cable and plug one end of it into any of the LAN ports (some reccomend the first) in A, and the other end into the WAN port of B. Login to it’s portal.. yeah it’s at 192.168.0.1. Though I don’t see why dynamic shouldn’t  work, but since it didn’t for me, let’s assume it won’t work for anyone else. Select Static IP in the startup wizard and you’d be greeted by a number of blank input-boxes.  Fill them in as follows:

IP Address: 192.168.1.2

Subnet Mask: 255.255.255.0

Gateway: 192.168.1.1

Primary DNS Server: 192.168.1.1

That ought to do the trick. You might want to do a reboot, but that’s not always necessary.

Using two routers to extend a network – Part 1

Umm, yeah, so let’s get to it. What was the first interpretation? oh that’s right, Router B to act as a wireless access point for A.

So, A has an internet connection and B has to be connected to it via a cable and configured in such a manner that the connected devices automatically connect to either of the two devices with the best signal as you move about, and as B is acting as an access points, all data B receives and sends would of course need to be sent to and received from A. (Pardon me if something I’ve written doesn’t seem correct, I’m merely a noob and explaining in terms your grandma could understand.)

This was actually pretty simple, so I’d just list the steps leaving out the screenshots.

  1. Get an ethernet cable and insert one end of it into any LAN port on A, and the other end into the first LAN port of B. (actually I’m not sure if it has to be the first port or not.)
  2. Login to the web interface of B and set the SSID, i.e the name of the network, and the security settings of B to be the same as those of A. e.g. if A is called “narlges” and it’s using WPA, with passphrase “flutterwacken”, then you need to apply the same settings on B.
  3. Making sure that both A and B are in the same subnet, change the LAN IP adress of B to something other than that of A. So if the IP of A is 192.168.0.1, then you can set B to 192.168.0.X. Basically X can be any number between 0 and 255 except 1 as it is being used by A.
  4. Disable DHCP on B as it won’t be assigning IP addresses and all.
  5. Other wireless and radio settings like channel and all need to be the same too
  6. Reboot both routers?

And basically that’s it.

Using two routers to extend a network

I have recently been faced with this challenge, partly for learning, as it’s kind of an enthusiast thing and partly because I might actually need to to that in the near future. Since the title might seem a bit vague or ambigous to some, let me first make a bit clear exactly what it is I’m after. How about we start by listing interpretations? (My goal and the whole point of all this can be seen to later.)

Router A= TL-WR841N, and this one’s configured to connect to the internet using PPTP

Router B = Tenda W268R,

  1. I have two routers, and I want B to act as a wireless access point to extend it’s range.
  2. I have two routers, and I want B to have a LAN of it’s own, with A as a gateway providing access to the internet.
  3. I want to do either of the things listed above over a wireless bridge.

Let me say this much. I am a newbie. I’m not much of a networking guy, nor do I really know how this is going to work. I’m simply Google-ing and experimenting.

In the next few posts, I will explain what I have tried and what was the outcome.