Views: 664
Understanding & Using The tee Command
By pradeep on May 14, 2013 - 1:53 PM
tee command is common on Unix like systems and on Windows PowerShell. The tee command writes the input to the file specified and also to the standard output, it was named after the plumbing T-splitter used. Here's a graphical presentation of the tee command:
Source: Wikipedia.org
Usage
The usage can be better demonstrated than explained in theory, follow the few examples below:
... Read More →
Read & Update MP3 ID3 Tags in Ruby
By pradeep on May 03, 2013 - 7:35 PM
ID3 is a format to store metadata within MP3 files which might include album info, artist info, cover images, thumbnails, and so on. These tags help software like Windows Media Player, iTunes, etc. categorize music and build a library for you to browse. Also, there exists software like Easy ID3 Tag Editor, etc. which allow you to create and edit ID3 tags' all fields.
So, what's the use? There are many, you might want to create your own web-based ID3 editor/library, or you might want to create an index of MP3 files you have and so on.
In this article we'll be looking at a Ruby module called taglib-ruby which is a Ruby interface for the C++ library called taglib. We'll use the Ruby module to read & write to MP3 files' tags. TagLib also supports many other file formats like OGG, FLAC, etc, but here we will only be looking at MP3.
Installing TagLib for Ruby
You'll need to install taglib library (http://taglib.github.io/), if your system's package manager can install... Read More →
Views: 1,036
Access Amazon SQS using Python's Boto
By pradeep on Apr 30, 2013 - 3:04 PM
Amazon's Simple Queue Service is a highly scalable service to help cloud-based applications use a queuing system which is reliable & scalable. Amazon's queue has it's pros & cons, like the messages may not be received in the order they were queued, and you may receive duplicates, I had written an article on Amazon SQS where I had explained the features & limitations of the service.
In this article we'll be looking at a Python library called Boto which makes accessing AWS services really easy. We'll go through installation of Boto and using it to perform various operations on Amazon SQS.
Installing Boto
Boto's git repository makes it very easy to install, just follow the commands below:
... Read More →
Views: 1,098
Accessing SQLite Databases in PHP using PDO
By pradeep on Apr 27, 2013 - 1:51 PM
PDO or PHP Data Objects is a data abstraction layer, i.e. it provides uniform methods to access different types of databases, as a result switching between or moving to a different database system is relatively easier. So, in simple language the code to access a SQLite db will also work for MySQL db with minor changes. PDO provides a plethora of database drivers like MySQL, Oracle, Postgre SQL, SQLite, Firebird, etc. In this article we will look at accessing a SQLite db using PDO.
Installing PDO
PDO & driver for SQLite is enabled by default from PHP version 5.1.0 onwards, if not so use the following command to install PDO:
... Read More →
Views: 1,527
Introduction to HMAC & Using in Python
By pradeep on Apr 23, 2013 - 5:46 PM
HMAC stands for Hash-base Message Authentication Code, it is key based message digest algorithm which can be used for verifying the integrity of the message (i.e. the original message from which the hash is generated) or to verify the authenticity of the sender of the message or both. Nowadays, HMAC is being widely used in various systems & domains, like server-to-server communications, Web Service APIs, etc. A well known use of HMAC is in Amazon's AWS API calls where the signature is generated using HMAC.
HMAC can use a variety of hashing algorithms, like MD5, SHA1, SHA256, etc. HMAC function is not very processing intensive, so it has been widely accepted, and it is relatively easy to implement in mobile & embedded devices too while maintaining decent security.
Using HMAC in Python
Since Python version 2.2 the HMAC module comes with Python installation, and the hashing library hashlib comes with the Python installation from version 2.5 onwards, in case you are having... Read More →
Views: 1,328
Access Web Services & Remote URLs with Ruby's HTTParty
By pradeep on Apr 22, 2013 - 7:11 PM
As programmers most of us today are writing programs/scripts that consume data from web services or APIs, like the Facebook Graph API, etc. Writing your own subroutines from open socket and making request and the likes are time consuming and are not worth putting effort on for all projects, so Ruby has a gem called HTTParty which will help you concentrate on the business logic instead of mundane HTTP request tasks.
HTTParty is a very neat gem, it combined with the power of Ruby creates a lucid and free flowing code. HTTParty can automatically parse JSON/XML type responses on the basis of the Content-Type header. In this article we'll look at the installation of the HTTParty gem and basic usage to get you started.
Installing The HTTParty Gem
Installation is pretty simple, issue the following command as a root user:
... Read More →
Views: 2,392
Access Remote URLs in Python With urllib2
By pradeep on Apr 17, 2013 - 4:44 PM
Python urllib2 library contains functions with enables programmers to access remote URLs by helping out in the operations like HTTP Basic Authentication, cookies, redirects etc. It's Python's equivalent to Perl's LWP or ASP's XMLHttpRequest etc.
The library allows you to add HTTP headers to requests, read response data & headers, error handling etc. Although urllib2 is not limited to HTTP we'll only be covering HTTP in this article. I'll try to explain and demonstrate the usage of urllib2 with a few examples so I am assuming that the reader has basic understanding of URLs or simply put how the web works.
Using urllib To Fetch Remote URLs
The code snippet below straightaway fetches an URL and prints out the received data nothing fancy about it, the simplest example:
... Read More →
Views: 1,779
glTest1: Intercept Opengl32 with GPA
By david_BS on Apr 09, 2013 - 10:16 PM
LEVEL: BEGINNER, Test Environment: WinXP SP3
This is a demonstration of how Opengl32 with GPA can be applied an IAT HOOK to intercept functions in a process. In this case, it is about an EXE which uses some functions from Opengl32 to create a window and render an image.
To make use out of the Opengl32 functions in an EXE like in this case, it can be done by dynamic linking (with .DLL) or with static linking (with .LIB)
Here I give a few links where to get... Read More →
Views: 1,830
Dll Wrapper: Making our own psapi.dll with .DEF
By david_BS on Apr 09, 2013 - 8:32 PM
Level: Beginner, Test environment: WinXP SP3
This tutorial is going to teach you how to make a 'DLL wrapper'. Wrappers are own versions of known DLL's. In this case we're going to make a wrapper of a very known DLL known as PSAPI.DLL. If you don't know it then find the information somewhere XD. But it is about a DLL that is very common to find it loaded in some processes.
The technique of building wrappers has at least 2 objectives:
Hooking: Because our own version of the DLL is going to contain our own versions of the original functions, and at the same time we need to call the originals within ours. What we can do is to execute our code before it gets executed the original code.
Loading a DLL: What we are doing when we create our own version of the known DLL is making the target program to be loaded our DLL in place of the original DLL. This loading it's not made by the target program but by the operating system. The OS detects our DLL in the same location than the... Read More →
Views: 2,176
How to Stop vBulletin Spam Registration
By shabbir on Apr 09, 2013 - 4:19 PM
Captcha, reCaptcha as well as Question and Answer does not stop vBulletin Spam registrations and so I have come up with yet another solution to stop vBulletin Spam for Registration. This works with any kind of site and is based on Cookies for Comments Wordpress Plugin.
The idea and implementation is completely based on the plugin and so the credit completely goes to the Authors of the above plugin. I have just used it for vBulletin and shared it here so you can apply the same for your forums. It is very simple and yet so effective that it can be applied to almost any website.
Step 1
Download the above plugin and extract into a folder. Upload css.php file to your forum root directory. Browse to the css.php file in your browser and copy the link to the css.php file.
Step 2
Now add the following lines to your headinclude template in each of your vBulletin style.
... Read More →
Views: 3,951
The Pros and Cons of Marketing
By coderzone on Apr 08, 2013 - 8:44 PM
Marketing is something all businesses today swear by creating interest among potential customers for a product or service is important in today’s fast-paced world. There are several marketing mediums available. However, what is important to know is that there are both advantages and disadvantages of marketing. This article will explain in brief the pros and cons of marketing.
ProsThe most obvious advantage of marketing is that a general interest is created about the product or service that is being offered by its promotion. This may mean promoting for the general public or a specific market. Brand recognition over time is another important advantage attributed to marketing. Because of this, people will start associating the name of the concerned business and its logo with the actual business. This means the enhancement of brand value over time. However, this is more of a long-term effect of marketing.
No business will make money without spending any. So when a business starts... Read More →
Views: 1,863
Difference between Views and Materialized Views
By bashamsc on Apr 04, 2013 - 6:12 PM
Materialized ViewsStores results not queries
Requires Physical memory
No auto updates
Execution time is less
ViewsStores queries not data
No physical memory required
Auto Updates
Execution time is more
Now we will try to learn the difference by looking into below the examples.
1. Stores queries not data vs Stores results not queries
Let us suppose the view v_emplyee and it stores query as shown below
... Read More →
Views: 1,916
Create A Super Fast Search with Sphinx
By pradeep on Apr 01, 2013 - 7:30 PM
Sphinx (acronym for SQL Phrase Index) is a full-text search engine, it runs as a daemon and serves to requests of client applications. Client applications need to access Sphinx daemon via the native SphinxAPI, for which libraries are available in almost all popular languages like PHP, Perl, Ruby, Java, C# etc. The client can also access the search daemon via Sphinx's own MySQL network protocol called SphinxQL or via a MySQL storage engine called SphinxSE.
Sphinx can load data from various sources like MySQL, PgSQL, ODBC, XML file, etc. and then it creates indexes, you can also update indexes from time to time from the data source. In this article we'll see how to install and setup Sphinx and then use it from a PHP script.
Installing Sphinx
Get the latest release of Sphinx from from http://sphinxsearch.com/downloads/release/ and extract everything from the tarball, and run configure:
... Read More →
Views: 2,660
Add Spell Check in PHP With PSpell
By pradeep on Mar 28, 2013 - 7:38 PM
Most applications like browsers, text editors, etc. come built in with spelling suggestions, they highlight a possible incorrect English word (any language for that matter) and offers a list of suggestions when clicked or selected. Even, search engines provide spelling suggestions.
Even you might want to provide spelling corrections to your web application, with PHP and it's Pspell extension it wouldn't be very hard to implement. Pspell extension uses the Aspell library (http://aspell.sourceforge.net/). In this article we will look at installing & using the Pspell extension for spelling suggestions.
Pspell Installation
You need to have Aspell library to compile PHP with Pspell extension, add the following option with path Aspell source to configure:
... Read More →
Views: 2,168