Node.JS module install behind a corporate proxy

If you happen to be behind a corporate firewall like me, chances are you have tons of problems with Node’s package manager,npm.

So here are some steps which might help you.

1. Setup NPM to use your proxy configuration

sudo npm config set proxy http://proxy.mycompany.comg:3128
sudo npm config set https-proxy https://proxy.mycompany.com:3128

2. Force your npm to use HTTP over HTTPS
You could do this by doing :


sudo npm config set registry http://registry.npmjs.org/

 

The above steps should work for majority of modules but it may not work for some.

3. If the module has a HTTPS reference explicitly in its package.json dependencies
Some modules specify the full URL in their dependencies other than just the name. If that is the case NPM would go and fetch the module from that URL . If the URL contains HHTPS although you have specified to use HHTP only but it would try to access HTTPS, so it would freeze there specially if your proxy server blocks that.

In this case:
3.1 Clone the repository to your local machine

3.2 Modify the package.json file and replace any HTTPS with HTTP

3.3 Install the local module
To install the module located in your local hard drive, use NPM and instead of module’s name, specify the path:


npm install module/

 

This should fix most of the issues with installing a module behind a corporate proxy.

Advertisements

Extending VirtualBoxes Virtual hard Drive

I usually have one Windows available in hand in a VM. Knowing windows, it would eat all the hard drive you dedicate to it. So at the setup time I decided to give it a flexible size but maximum of 25GB, which seemed fair for Windows 7. But now that I have had it for a while it got quite big and when I wanted to install a new application, I was running out of space.

Extending an existing drive is not possible, but the whole process to achieve what’s needed is very very simple. All you need to is:

  1. Go to VM’s setting / storage and create a new bigger storage, which would be your only HDD
  2. clone the hard drive from the old one to the new one. Here is the VirtualBox’s command:
    $VBoxManage  clonehd /Path/to/old/Windows7.vdi  /path/to/new/Win7_30GB.vdi --existing
  3. Now remove the HDD from your existing VM. (VM/Setting/Storage)
  4. Add your new HDD to the VM.
  5. Boot the VM
  6. In the guest OS, go to “Control Panel/ Administrative Tools/ Computer Management/ Storage”   and you should be able to see the extra space as unallocated. Just extend the existing drive to the maximum to use it

Enjoy your extended HDD.

Why I believe “Coursera, blocking access from sanctioned countries” is bad? Really bad!

Today my country’s name was on home page of Hacker News. Wow! It feels great to see your country’s being mentioned. For a country that even on many websites’ forms it is not even listed to choose as your country. Has it ever happened to you to fill a form and choose your country as “Other…” in a list of over a 180 countries? It’s really painful, you feel like are not even being seen.

But today, “Iran” was on home page of Hacker news. It felt good on the first sight. But only on the first sight. It was the news that Coursera is blocking access for students from Iran, Cuba, Sudan and Syria. [link]

This is what they mention as the main reason:

Certain aspects of Coursera’s course offerings are considered services and are therefore subject to restrictions in sanctioned countries

I understand that is the US law and they want to be safe. But I always had the impression that Coursera has a very ambitious goal in its heart: “Best courses, for free, for everyone!”. Well the later is not applicable anymore. It won’t be for “everyone”.

I don’t support the Iranian government and their behaviours which are causing all these sanctions, but a sanction like this is terrible. Who is paying the price for such a sanction? Isn’t the purpose of all these sanctions to prevent the government from continuing their nuclear program? I think on the contrary, this one works completely in their favour:

Sanction on Education!

What could be possibly worse than this?

Sanction on food? It is very harsh, the poor would starve, but it’s possible to work around it.

Sanction on medication? Yes it is terrible and people are struggling with it by paying with their lives. But even that is not as horrible as “Sanction on Education”.

I believe if something is going to change in Iran, it will be through education, through a very slow process of an ancient nation educating itself to take better care of itself. To grow. To live and to live freely. To learn the democracy.

In a society which all the education is controlled by government, this will never happen. Government’s golden age relies on ignorance of people. They censor the books and the movies. They filter the internet. They decide what you can or can not read, watch or even think.
In such situation having access to education without any burden and with no charge, is like finding the Treasure box. Or maybe even more valuable.

One may think, what Coursera was offering couldn’t lead to any of these. I should oppose you.

If i learn about “Drugs and Brain”, I would never go close to the drugs, and will educate my acquaintances about it as well.
If I attend a course on “World music”, I might have few words to say, which could be interesting for some.
If i will be more informed about “How to change the world”, I might really do something that does.
and if I learn more about “Global Sustainable Energy”, I may eventually realize that my country doesn’t need nuclear energy, there are plenty of other resources.

Those are the baby steps that takes for change. Indeed, it is slow. But that’s the only way. No revolution has ever worked for the benefit of the revolutionaries. Change will never happen over night.

If there is a way to the future for Iran, it is through education, period.

And today Coursera just blocked access for Students in Cuba, Iran, Sudan, and Syria.

yum behind a proxy

If you happen to be behind a corporate proxy and need to get “yum” working you could easily set your proxy settings in the “yum.conf” file. The file is usually located here:

/etc/yum.conf

And all you need to do is to set the following variables:

proxy=http://proxy.mydomain.com:3128
# If your proxy server happen to need user/pass credentials for Authentication
proxy_username=proxy_user
proxy_password=proxy_pass

“True North PHP” Talk + Slides

The first day of TrueNorthPHP 2013 is over and there were quite interesting talks to listen and amazing people to meet.

My talk was at 11:00 AM and it went well. It was an honor for me to speak at this conference.

In case you’re interested, you can take a look at the slides on slideshare.

I submited a Talk for Confoo

I submitted a talk for Confoo 2014. The title is:

SQL or NoSQL that’s the question

With the emerge of new NoSQL databases, it’s very important to understand their abilities and the use-cases for a scalable web application. Understanding what they provide and what sort of problems they can solve is vital to successful usage of NoSQL databases in the web architectures and infra structures.

The key is that Relational Databases are not dead and they won’t be. They have specific abilities which would facilitate implementing a lot of ideas in the data modelling.

By experience, we realized that using a Hybrid system is the best solution. While you benefit from bests of the both worlds, you can improve the quality of product and availability of service to the customers.

In this presentation, an example from game-industry would be provided. A UbiSoft, Montreal game which was fully based on Relational databases, has been restructured to a Hybrid system to benefit from both Relational database and a NoSQL database.

The major design decisions, and the benefits of each would be discussed in details to give audience a perspective of what could be achieved within a Hybrid system.

The process of migrating the previous architecture to the new one in a live system, without having any downtime would be explained as well, to show how approachable and easy is this new Hybrid design.

The new architecture has been beneficial for the community of players and also for the development team, which they will be explained.

The Hybrid system has been on Production since October.2012 with no downtime since.

 

ConFoo. February 26 - February 28, 2014 | Montreal, Canada

JavaScript Date Object Chrome vs. Firefox

There is a very tiny yet important difference between how Chrome and Firefox treats “Date” object, when you are creating one from a String:

new Date("1980-03-14T00:00:00.0000000");

The difference is that Firefox (tested on v23.0.1) considers the passed string is on the local timezone so the output is:

new Date("1980-03-14T00:00:00.0000000").toString();
"Fri Mar 14 1980 00:00:00 GMT-0400 (Eastern Standard Time)"

While Chrome, considers the passed string in UTC/GMT timezone and then converts it to a local timezone:

new Date("1980-03-14T00:00:00.0000000").toString();
"Thu Mar 13 1980 20:00:00 GMT-0400 (Eastern Daylight Time)"

As you can see, that would be a potential for some Front-End Date/Time processing.

If you are using the Date object just for showing, using the UTC format would be very useful and would avoid any discrepancies.


var my_time =  new Date("1980-03-14T00:00:00.0000000");
my_time.getUTCFullYear();
my_time.getUTCMonth();
my_time.getUTCDate()