Extending ls command

How to generate list of files and their size in bytes?

Comma Separated List (CSV)
$ls -l | awk '{ print $5 "," $9 }' > list.tsv

Tab Separated List (TSV)
$ls -l | awk '{ print $5 "\t" $9 }' > list.tsv

$5 – Ordinal position for Size in bytes.
$9 – Name of the file.

Posted in General, Mac | Comments Off

Cisco VPN Client for Mac

Finally, after 12 years of windows 3.x, 95, ME, 2000, XP, Vista and 7 I decided to try a Mac. Got one, setup XCode, TextWrangler, FTP client, AirPort, MS Office, IMs. Most of it went smoothly. The first major issue was with setting up VPN Client. After all the exercise, RackSpace guys suggested me to simply use Mac’s vpnclient instead of Cisco’s.

The reason behind this post is to say 1) None of the forum posts helped as they all suggested to try restarting vpn client. 2) It is a lot easier to setup mac’s vpn client.

Here is what I did or rather RackSpace guy instructed me to do ;)

Goto System Preferences then select Network (under Internet and Wireless)..
Create new session by clicking (+), and with the
Interface = VPN
VPN Type = Cisco IPsec
Service Name = [Whatever name you like]

Server address: [Your server ip.]
Account Name: [Username]

Authentication Settings:
Shared Secret: [Username]
Group name: [Your Group Name]

press Ok

and then Connect

dialogue window will pop up:

use your personal log in credentials
username: [Username]
password: [Password]

That’s it!

Posted in Mac, TechNews | Comments Off

UPDATEs without a WHERE?!

It’s quite common that programmers (non-framework) write UPDATEs without WHERE clause and cause unexpected problems. This perhaps can make their job inconsistent as well and not just the database :D

Well if you’re a programmer follow some simple techniques to save your job and database. If you forget to write the WHERE clause the query would fail leaving the data safe.

$sql = “UPDATE
“.
” SET x = ‘y’, z = ‘a’ WHERE”.
“somekey = ‘someval’”;

Posted in General | Tagged | Leave a comment

Escape from Magic Quotes for Non-Frameworks Programmers

Here is a quick thing to help you fetch clean data from GET POST COOKIE and REQUEST input variables. Of course, you need to rely on something like mysql_real_escape_string before writing this into a database. But a common function like this for the entire Web App will keep the data safe from slashes and helps you code without bothering whether magic_quotes_gpc is ON or OFF.


/**
* Use this function to safely retreive data from GET POST COOKIE and REQUEST super globals
*
* @param String $_key Name of the POST element to be retrieved
* @return String Clean value without any slashes even if magic_quotes_gpc is enabled.
*/
function getFromGpc($_key, $_source='p')
{
$_source = strtolower($_source);

if( $_source == 'p' ):
if( get_magic_quotes_gpc() ) {
return stripslashes($_POST[$_key]);
} else {
return ($_POST[$_key]);
}
elseif( $_source == 'g' ):
if( get_magic_quotes_gpc() ) {
return stripslashes($_GET[$_key]);
} else {
return ($_GET[$_key]);
}
elseif( $_source == 'c' ):
if( get_magic_quotes_gpc() ) {
return stripslashes($_COOKIE[$_key]);
} else {
return ($_COOKIE[$_key]);
}
elseif( $_source == 'r' ):
if( get_magic_quotes_gpc() ) {
return stripslashes($_REQUEST[$_key]);
} else {
return ($_REQUEST[$_key]);
}
else:
if( get_magic_quotes_gpc() ) {
return stripslashes($_REQUEST[$_key]);
} else {
return ($_REQUEST[$_key]);
}
endif;
}

Posted in PHP | Tagged , , | Leave a comment

Flexible Client-side table sorting using jQuery

I found these plugins to be very useful. Not sure if there is a new version of it. Worth trying.

tablesorter:
1) http://tablesorter.com/docs/
2) http://tablesorter.com/docs/example-pager.html

Posted in Client-Side, General | Tagged , | Leave a comment

doxentral – A CodeIgniter based Web App.

New to CodeIgniter and looking for a example that helps you learn how a Model is written? or how form_valdiation library is used? and how to integrate SWFUpload?

Here is a nice example:
doxentral

Useful links:
CodeIgniter
ColorBox jQuery Plugin
Session class does not support a change of session ID (Facebook and Flash problem)
SWFUpload

Posted in PHP | Tagged , , , , | Leave a comment

New! Google Chrome now has extensions and bookmark sync.

WoW! Google Chrome now has <a href=”https://chrome.google.com/extensions?hl=en-US”>extensions</a> and bookmark sync. New area for developers to play.

Just tried a few recent/popular extensions. They are superb. The Evernote Web Clipper, Dictionary, FireBug and Calendar extensions are worth trying…That’s not all, you can now sync your Bookmarks with Google Docs!!

Posted in TechNews | Leave a comment

Setting Upload Max Size via .htaccess

Here is an example to allow File Uploads upto 2 GB. You may also have to consider Max Execution Time.

PHP4:


<IfModule mod_php4.c>

php_value upload_max_filesize 2G

php_value post_max_size 2G

</IfModule>

PHP5:


<IfModule mod_php5.c>

php_value upload_max_filesize 2G

php_value post_max_size 2G

</IfModule>

Posted in General, PHP | Tagged , , | Leave a comment

Tip: Searching for Unread e-mail in GMail

Finally, figured out how to find those hiding unread messages in my GMail Inbox or other folders. aah! A quick relief. Always hated going down the pages and finding the mails in some 20th or 40th page.

You can just use “is:unread in:inbox” to search all unread mails in the Inbox. Without quotes though!

Posted in General | Tagged | Leave a comment

HTML to PDF from PHP Made Easy!

Finally, found two new Libraries that makes a PHP programmer’s life easy. Tested both and they seem to work pretty fine for simple requirements like PDF receipt generation or news letter download or e-Ticket/e-Cert generation.

FPDF (PHP4 and PHP5)
dompdf (PHP5 Only)

Happy PDFing!!

Posted in PHP | Tagged , , | Leave a comment