Categories
Personal

The Continuous Sabotage in Bangladesh

It hurts. Really it does. It’s not been long after the BDR massacre, now the largest shopping mall of the country. What the hell is up with this new government?

The effect of BDR mutiny has not died away yet. The loses of so many of our trained and talented army officers have definitely thwarted us. What really triggered this deadly event? What, really? Is it the revenge of the Roumari incident when our brave border guards shot 14 BSF dead when the bloody BSF tried to ambush our land? India has been trying to captivate us for a long time. What this govt is playing at deciding to give them transit? Can’t they see the obvious intention of the Indian Govt? Why did they not allow Army to jump into action when even the killing was not started? What was behind their decision of killing time under cover of political solution? Should we assume that what the army officers said in Shena Kunja was true? Should we assume that the Govt has a hand in it?

Now the Basundhora City has been burnt out. What made it happen? Because Mahmudur Rahman was speaking for Bangladesh, against the Indian loby? Because the Govt is not happy with the truth Mahmudur Rahman is bringing to lime light?

Should we assume that India is going to make us a sub state of itself during the reign of this govt? Why is this govt so silent when it comes to answering questions that concern India in a guilty sort of way? Why was youtube banned the other day?

I am really dying to know the answers. If somebody can, please please let me know. I love my country and would do anything to uphold its independence and sovereignty.

Categories
PHP

Duplicating WordPress Blog: “The Hasin Vai” Method

Hasin Hayder, a ZCE and Open Source enthusiast shared a nice trick to duplicate your wordpress blog just using the simple combination of php and mod_rewrite of apache. Read his original blog post here. I am going to explain the mechanism step by step here.

The PHP Code:
Put this code inside the index.php on the target URL’s root directory.

<?php
$dataurl = $primaryurl = ?http://hasin.wordpress.com?;//old domain
$secondaryurl = ?http://blog.ofhas.in?; //new domain
$path =array_keys($_GET);
if(!empty($path[0])) $dataurl = ?{$primaryurl}/{$path[0]}?;
$data = file_get_contents($dataurl);
$pattern = ?~{$primaryurl}/([dS/]+)~?;
$data = preg_replace($pattern,?{$secondaryurl}/$1?,$data);
$data = str_replace(array(?<a href=?{$primaryurl}?,?<form action=?{$secondaryurl}?),array(?<a href=?{$secondaryurl}?,?<form action=?{$primaryurl}?),$data);
echo $data;
?>

The URL REWRITING:
Put the following code inside a .htaccess file or in your apache httpd conf file.

RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} (.+)

RewriteRule ^(.*)$ index.php?$1&%{QUERY_STRING}
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

Explanation:
······# The URL Rewriting portion processes the requests to index.php (with and without GET query strings) and other static directories and files (images dir and robots.txt)
······# index.php handles the incoming requests as redirected by the URL Rewriting mechanism.
······# First we define the two data source or URL.

<?php
$dataurl = $primaryurl = ?http://hasin.wordpress.com?;//old domain
$secondaryurl = ?http://blog.ofhas.in?; //new domain
These two lines define the URLs involved. The primary URL is the URL where your wordpress blog is really hosted. The secondary url is the URL of the new location where the blog will show up

······# We sort out the path to the data to display and then copy the data as string.

$path =array_keys($_GET);
if(!empty($path[0])) $dataurl = ?{$primaryurl}/{$path[0]}?;
$data = file_get_contents($dataurl);

······# We then use Regular Expression to change all referrences to our primary URL so that they point to our new location.

$pattern = ?~{$primaryurl}/([dS/]+)~?;
$data = preg_replace($pattern,?{$secondaryurl}/$1?,$data);
$data = str_replace(array(?<a href=?{$primaryurl}?,?<form action=?{$secondaryurl}?),array(?<a href=?{$secondaryurl}?,?<form action=?{$primaryurl}?),$data);
Here we change the URLs and Form Targets. But what about Images with relative URL? I think there’s something wrong with that. I will ask Hasin Vai.

······# Lets print out the modofied data. Close the php block.

echo $data;
?>

That’s all. Put the php code in index.php and the Rewriting Rules in a .htaccess. Place the files in your public_html directory to fire off the ground.

PS: I haven’t yet tested the codes myself. But I believe it would work except for relative image URL.

Categories
Uncategorized

Scripting with C

Normally scripting refers to the interpreted languages. You write a script that gets interpreted during runtime by interpreters. Python, PHP and Perl are some of the prominent scripting languages. On the other hand, with compiled languages the source code is first compiled then linked to related libraries and finally built into executables or other runtime components. C is a very good and well known example of compiled languages.

Interpreted languages are easy to debug because of their interpreted nature because code execution stops only when it encounters a bug. On the other side, with compiled languages the entire source is compiled before execution. Again, the same problem goes with prototyping. You make a change and go through the usual compile-link-build cycle over and over to reflect the changes. But with interpreted languages, changes in your scripts are immediately reflected in the next run.

C being a compiled language hardly supports scripting. Note that word, yeah, “hardly”, because we can script with C. How? Read on.

C source codes need to be compiled using compilers. You will find a good enough numbers of them to confuse you to decide which one to use. The GCC (GNU C Compiler) is one of the most popular. But the magic I am describing can be performed with a GCC like compiler that is somthing more than cool. The compiler is named TinyCC (aka TCC). It’s a hyper fast compiler. You can use it like a C interpreter to execute C codes on the fly like a script.

EXAMPLE:

How to Run?:

  1. Save the file as “hello.c”.
  2. Make sure TCC is added to your path.
  3. Run the command line tool and navigate it to the directory where hello.c is saved.
  4. Invoke TCC by typing: tcc -run hello.c.

Output: Hello World!

#!/usr/local/bin/tcc -run: Yeah, you can use it like a shell script as well (on linux).

The TCC compiler is so fast that you don’t even need to create makefiles for large projects. TCC has it’s own linker and assembler. TCC not only supports ANSI C, but also most of the new ISO C99 standard and many GNUC extensions including inline assembly. TCC can also automatically generate memory and bound checks while allowing all C pointers operations. TCC can do these checks even if non patched libraries are used. With libtcc, you can use TCC as a backend for dynamic code generation.

TCC mainly supports the i386 target on Linux and Windows. There are alpha ports for the ARM (arm-tcc) and the TMS320C67xx targets (c67-tcc). More information about the ARM port is available at http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html. But even after all these features, TCC is really small.

I am really enjoying my time with this “tiny” yet great tool 🙂

I would recommend all C programmers to give it a try 😀

Download Link: TCC Website