Categories
Linux

Sharing WiMax Through a Second Wireless Router and WiFi Issue on Ubuntu

PS: This post shall tend to be more of a self documentation than an informative technical article.

I own a Belkin N Series Wireless Modem and Router which I bought from https://router200.com/ after comparing between various models which the site showcased (which I used to use for BTCL ADSL connection). I recently (couple of months ago) took a Banglalion WiMax connection. I purchased their indoor unit which doesn’t have WiFi built in. They have another indoor device which has WiFi but my bad luck, it was out of market then, if that’s the option you are looking for than I’d suggest asking for their wi-fi for sale options.

Since I use my Notebook PC, creating a wireless home network is very important. After spending a considerable amount of time behind the Belkin device, I came to find that it can be used to route the WiMax connection. The configuration was a bit tricky (at least for me – may be because I never did this before). Now, through the Belkin device, I would directly be connected to the WiMax device. When a connection was established, it would seem that the Belkin device never existed and I am directly connected to the WiMax device via WiFi. It was cool (though I had to restart the Belkin device after the Wimax device had a stable connection after reboot). Things were good with the system and Windows 7.

However, I installed Ubuntu (completely removing Windows 7) and the WiFi connects. But it fails to reach to the WiMax device. I can reach the Belkin device but no further than that. No Internet connection, nothing! I was very disappointed. But an idea came to my mind, if Windows can handle the routing, why not try it inside VirtualBox? VirtualBox supports bridging host adapters directly with the guest os. So, If I run Windows inside virtual box, I would be able to access my WiFi hardware from Windows. I had a plan that if it worked, if I could browse the internet from inside VBox, I would create a host only network and bridge the two connections.

But life sometimes is much comfortable than you can anticipate. After I installed Windows XP inside Virtual Box and bridged my “wlan0”, Ubuntu started getting Internet connection. This is so interesting, I don’t even need to create network bridge or anything! As long as Windows XP is running inside VirtualBox, Ubuntu can reach the WiMax device like Windows used to do. I don’t know why this happens. May be Ubuntu requires some complex network configuration to connect to such multiple device scenario on the other hand Windows automatically configures the device so during that period, the connection works. Or may be the guest and host OS has some other bridges I am not aware of, so the Windows XP is sharing the connection even without my knowing it.

Whatever the fact is, I am happy. I have tested it several times. If I shut down Windows XP inside the VBox, my connection drops (though the WiFi remains connected to Belkin, it can’t reach the end). But if keep the virtual machine running, connection is perfectly okay. For more information on the wifi router and how you can fix various network issues, visit and learn about Advanced Telecom Systems.

Categories
PHP

Using Zend Framework Models and Libraries from Command Line (or Cron Job)

If you are developing web applications using the Zend Framework for PHP and you need a few cronjobs, you might be wondering if you could (re)use the existing models and libraries. Recently while working on a project, I was wondering the same thing. I have seen people asking the same thing about CodeIgniter framework before but my initial search for a suitable way to use ZF models and libs with cron was unsuccessful. It’s not like that I didn’t find any solutions, the fact is I found quite a few. Unfortunately none of them worked for me. While browsing through the search results, a post on StackOverflow caught my eyes. Someone suggested that we should take the original index.php and Bootstrap.php and hack the codes to get the core ZF running minus the views. That made sense. While running on the command line, we don’t care about the HTTP response and other stuff related with server-client communication. After half an hour of trial and error, I finally found that you can actually take the existing index.php and delete a few words off it to convert it from a web app to a command line app.

Sounds interesting? Locate these lines in the index.php file in the ZF public directory:

Here we first construct the application object, bootstrap it and then run the application. Bootstrapping automatically loads the required classes and executes them. But running the application tries to find a HTTP reuquest and process it. Since we don’t have a HTTP Request, we actually don’t need the last step. You got the hint?

Yes, after constructing the Application object, just bootstrap it, don’t run. So, take the index.php, make a duplicate copy out of it and then change the last few lines like this:

What I do, I create a another folder named “cron” parallel to the public directory, save the bootstrap file as “core.php”. Then in every cron script, I just require_once the core. php, simple, eh?

Categories
Bangla Python Series

বাংলায় পাইথন – ইন্ডেন্টেশন

অন্যান্য প্রোগ্রামিং ল্যাঙ্গুয়েজ থেকে পাইথনে আসলে প্রথম যে সমস্যাটি চোখে পড়ে তাহল পাইথনের ইন্ডেন্টেশন বেইজড কোড ব্লক । পাইথনের একই ইন্ডেন্টেশন সম্বলিত পর পর অবস্থিত লাইন গুলো একই কোড ব্লকের অন্তর্ভুক্ত । উদাহরণ না দিলে হয়ত বিষয়টি স্পষ্ট হবে না ।

এখানে আমরা ডট (.) দিয়ে স্পেইস বুঝিয়েছি । নিজে টাইপ করার সময় ডট এর পরিবর্তে স্পেইস ব্যবহার করুন না হলে প্রোগ্রাম রান করবে না । এখানে দেখুন ৩টি প্রিন্ট স্টেটমেন্ট আছে যারা একটির পর আরেকটি অবস্থিত এবং প্রত্যেকটি ৪টি স্পেইস দিয়ে ইন্ডেন্ট করা । এর ফলে এই প্রিন্ট স্টেটমেন্ট গুলো একটি কোড ব্লক হিসেবে কাজ করে । কোন স্টেটমেন্ট এ যদি একই ইন্ডেন্টেশন না থাকত সেক্ষেত্রে পাইথন এক্সেপশন (এরর) থ্রো করত ।

এখানে দেখুন প্রথম ব্লকের পর ইন্ডেন্টেশন আগের জায়গায় ফিরিয়ে নিয়ে ব্লকের সমাপ্তি টানা হয়েছে । পরে আবার ৪ স্পেইস ইন্ডেন্ট করে আরেকটি ব্লকের সূচনা করা হয়েছে । আগের ব্লক এবং এই ব্লক দুটোরই একই ইন্ডেন্টেশন কিন্তু এরা একই ব্লক নয় । কারণ এদের মাঝে else আছে ।

এবার দেখি নেস্টেড ব্লক:

এখানে আমরা স্পেইস এর পরিমান বাড়িয়ে দিয়ে নেস্টেড ব্লক তৈরি করলাম । একইভাবে স্পেইস এর পরিমান সমান পরিমানে কমিয়ে নিয়ে আগের ব্লকে ফিরে গেলাম ।

পাইথনের হোয়াইটস্পেস বেইজড ইন্ডেন্টেশন বুঝতে প্রথম প্রথম বেশ কষ্ট হয় । এজন্য দরকার অনুশীলন । নিজে নিজে ইন্ডেন্ট করার চেষ্টা করুন । গুগলে অনুসন্ধান করে দেখতে পারেন পাইথনের ইন্ডেন্টেশন নিয়ে ।