DNS Query Code in C with linux sockets

This article is an extension of the article : http://www.binarytides.com/blog/dns-query-code-in-c-with-winsock/ The Linux version has some changes. On Linux the dns server ips are stored in a file called /etc/resolv.conf. So the get_dns_servers function will open this file and pickup the dns server ip addresses. A typical /etc/resolv.conf file can look like this : # Generated by NetworkManager nameserver 208.67.222.222 nameserver 208.67.220.220 So the lines starting with nameserver can ...

PHP benefits of storing session data in database

PHP's session_start method stores the session data in files by default. These files are stored in the tmp directory of the OS and are cleared at intervals by the garbage collector. Alternatively the session data can be stored in database as well. Storing session data in database has certain advantages : 1. Limit the number of logins For instance if your application should ...

Check if php is running from cli (command line)

Php from command line PHP scripts are usually opened in a web browser. But they can be run from command line or terminal as well. The syntax to run a script from commandline is very much similar to python or perl. php /path/to/script/index.php Inside a script it might be necessary to test if it is being run from command line or not. For ...

Set mysql timezone at runtime via PHP

To set the timezone of mysql at runtime via php use the following code : $c = mysqli_connect($host, $username, $password); mysqli_query($c , "SET `time_zone` = '".date('P')."'"); This can be executed when the connection is established and it will set the timezone of mysql to whatever timezone php is set to. Fast and effective. ...

PHP download remote file via url

The following function will download and save a remote file , using its http url : function download_remote($url , $save_path) { $f = fopen( $save_path , 'w+'); $handle = fopen($url , "rb"); while (!feof($handle)) { $contents = fread($handle, 8192); fwrite($f , $contents); } fclose($handle); fclose($f); } The method reads 8192 bytes at a time , and not the whole file , since if the whole file is read at once , then ...

Make a racing car using Box2d in javascript

Racing car in box2d Box2d is a physics 2d simulation library and is used in game development. Apart from C/C++ it has ports for various languages like python, javascript etc. With the availability of the html5 canvas element and many other html5 apis, it becomes possible to write browser based games in javascript. So in this article we shall try to ...

Get smooth and beautiful fonts on Ubuntu

To get beautiful and smooth fonts on Ubuntu : 1. Install ttf-mscorefonts-installer from synaptic This will provide the fonts like microsoft arial , tahoma , verdana , courier etc. 2. Get the xml file by Obi Bok from https://wiki.ubuntu.com/Fonts The above xml file provides special finetuned settings for antialiasing and hinting parameters for various fonts like Arial , Tahoma , Freesans etc. It will ...

Play VCD on Ubuntu

If Totem , the default movie player does not play vcds properly , showing file permission errors , then try : 1. SMPlayer Install from synaptic : sudo apt-get install smplayer 2. mplayer Install from synaptic : sudo apt-get install mplayer 3. KPlayer Install from synaptic : sudo apt-get install kplayer To play from terminal type : desktop:~$ mplayer vcd:// MPlayer 1.0rc4-4.5.2 (C) 2000-2010 MPlayer Team mplayer: could not connect ...

Display hindi unicode fonts on Google Chrome on Ubuntu Linux

Google Chrome has problem displaying hindi/unicode and other Indian language fonts. For example bold hindi fonts might be displayed as square boxes. http://code.google.com/p/chromium/issues/detail?id=32109 http://code.google.com/p/chromium/issues/detail?id=21320 It is some kind of font selection bug. Lets try fixing it. 1. You may want to install the packages ttf-devanagari-fonts and ttf-indic-fonts. Also get that mangal.ttf thing from windows or somewhere. If that solves the problem , fine , otherwise continue. 2. Lets ...

Convert vcd dat file to mpeg on ubuntu

VCDs that are played on vcd players often contain the video in dat format. The dat format is internally mpeg only but has some additional header information attached. So the mpeg portion has to be ripped off to get the mpeg format. Once converted to mpeg format, it can be processed inside any video editor. On ubuntu there are many tools ...



Connect with us