Pages

Your Ad Here

This Blog is not to read or go through

because, I have never been such a mess


Search the blog instead

Tuesday, May 14, 2013

curl post (php)

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

Sunday, March 17, 2013

Check ubuntu distribution information

$ cat /etc/lsb-release

Saturday, March 9, 2013

Mplayer and your own Theare (For Public)

$ mplayer -fs -vf mirror video.flv

Find a window with white curtain, and project from inside. Get a gang outside the window and run your own theatre .


It was COOL to see Sparrow SMS commercial blowup. wooooooooooooow

Friday, January 18, 2013

[Imagemagick] Explode Image into pieces

convert -crop 16x16 mascotsmall.png +repage mascot-%d.png

Monday, June 18, 2012

OLAP in mysql

SELECT field1, field2, count(field3), count(field4)
group by field1, field2
with rollup

Sunday, March 18, 2012

Git tags to Github

$ git tag -a TAGNAME
# -a means to annotate a tag with some description.

$ git push --tags
# push the local tags

To know more
http://gitref.org/branching/#tag

Monday, January 2, 2012

Bookmark: Regex Replace for MySQL

Reference -
 http://techras.wordpress.com/2011/06/02/regex-replace-for-mysql/

DELIMITER $$
CREATE FUNCTION  `regex_replace`(pattern VARCHAR(1000),replacement VARCHAR(1000),original VARCHAR(1000))

RETURNS VARCHAR(1000)
DETERMINISTIC
BEGIN 
 DECLARE temp VARCHAR(1000);
 DECLARE ch VARCHAR(1);
 DECLARE i INT;
 SET i = 1;
 SET temp = '';
 IF original REGEXP pattern THEN 
  loop_label: LOOP 
   IF i>CHAR_LENGTH(original) THEN
    LEAVE loop_label;
   END IF;
   SET ch = SUBSTRING(original,i,1);
   IF NOT ch REGEXP pattern THEN
    SET temp = CONCAT(temp,ch);
   ELSE
    SET temp = CONCAT(temp,replacement);
   END IF;
   SET i=i+1;
  END LOOP;
 ELSE
  SET temp = original;
 END IF;
 RETURN temp;
END$$
DELIMITER ;
Note:
If you are using MySQL version 5.0.1 or higher, make sure you set the NO_BACKSLASH_ESCAPES mode ON, before you use the above function to replace any characters which are escaped with back slash “\”, ie: \A,\B,etc… See how to set the NO_BACKSLASH_ESCAPES mode here
Example on how to use this function
mysql> select regex_replace('[^a-zA-Z0-9\-]','','2my test3_text-to. check \\ my- sql (regular) ,expressions ._,');
Happy Coding!! :)
Your Ad Here