Category Archives: Coding

All kinds of Programming.

Parse MVC style urls in PHP

By | November 9, 2011

If you have used codeigniter or some mvc php framework then you might be aware of urls like www.yoursite.com/index.php/class/method/param1/param2?a=b&c=d or www.yoursite.com/class/method/param1/param2?a=b&c=d if you use mod rewrite to add the index.php The htaccess code could be like this : <IfModule mod_rewrite.c> #Start the rewrite engine RewriteEngine on #If requested thing is not a file or directory… Read More »

Quick Tip: Installing Ruby Gems in the user’s Home Directory

By | April 19, 2016

Note: The Operating System in use is Ubuntu Linux (11.04) My Gem Environment – $ gem env RubyGems Environment: – RUBYGEMS VERSION: 1.8.11 – RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux] – INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1 – RUBY EXECUTABLE: /usr/local/bin/ruby – EXECUTABLE DIRECTORY: /usr/local/bin – RUBYGEMS PLATFORMS: – ruby – x86_64-linux – GEM PATHS: – /usr/local/lib/ruby/gems/1.9.1… Read More »

How to Code a TCP Connect Port Scanner in PHP

By | August 11, 2020

A port scanner is a program designed to probe a server or host for open ports. Looking at open ports, one can tell what services might be running on the remote server. We earlier made a TCP Connect port scanner in C here – https://www.binarytides.com/tcp-connect-port-scanner-code-c-winsock/ and here – https://www.binarytides.com/tcp-connect-port-scanner-c-code-linux-sockets/ Now we shall try making the… Read More »

PHP strtotime in 64 bit environment

By | October 23, 2011

The strtotime function is used to convert a date in various formats to a timestamp. However its behaviour is different based on architecture it is running on, whether 32bit or 64bit. Lets take a few examples : In 64 bit environment desktop:~$ php -a Interactive shell php > echo strtotime("0000-00-00 00:00:00"); -62170005200 php > echo… Read More »

Mysql autoincrement column that resets every month

By | July 26, 2020

The autoincrement feature in mysql allows us to create numeric fields that automatically increment by 1 for every row inserted. It does it atomically so we don’t have to worry about any duplicates or collision. However, there are situations when we need an autoincrement field to reset at regular intervals like every month or so…. Read More »