Tag: How-To

How to automate FTP-ing file to another FTP account?

We will be using shell script to automate the transfer between two FTP accounts. You’ll need shell access to the source FTP account. #!/bin/bash directory=”/home/raisya/public_html” filename=”test.txt” hostname=”ftp.destination.com” username=”dest” password=”qwerty” logfile=”ftpf.log” ftp -uni $hostname <>$logfile quote USER $username quote PASS $password lcd $directory put $filename quit EOF Explanation: directory=”/home/raisya/public_html” Assigning “/home/raisya/public_html” to directory. filename=”test.txt” Assigning “test.txt” to filename. hostname=”ftp.destination.com” Assigning “ftp.destination.com”…

Read More »

How to grab BCA USD buy/sell rate with cURL?

This will grab current rate of USD rate from BCA using cURL. function delAttr($tagSource) { $stripAttrib = “‘ (style|class)=\”(.*?)\”‘i”; $tagSource = stripslashes($tagSource); $tagSource = preg_replace($stripAttrib, ”, $tagSource); return $tagSource; } function delTags($source) { $allowedTags=”; $source = strip_tags($source, $allowedTags); return preg_replace(‘/<(.*?)>/ie’, “‘<‘.delAttr(‘\\1′).’>'”, $source); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, “http://www.klikbca.com/individual/silver/ind/rates.html”); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,…

Read More »

How to create a jump to link

Jump link is used for jumping between part of a page. Wonder how to create a jump link? Ie: jump from the top of the page to the bottom? This will comes handy if you have a very long page. Or jump to top from the bottom of a page? Jump link consist two “HTML a” tags, the link &…

Read More »

PHP function to cut string into a specific length

PHP function to cut string into a specific length. Very useful for “Read More” links. function wCut($str, $maxLength = 40) { $strToCount = html_entity_decode($str); if (strlen($strToCount) <= $maxLength) { return $str; } $s2 = substr($strToCount, 0, $maxLength – 3); $s2 .= “…”; return htmlentities($s2); } $str = ‘Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nunc risus, euismod ac,…

Read More »

How to disable Windows Vista 64 bit hibernate?

Hibernate is a feature seen in many operating systems where the contents of RAM is written to non-volatile storage, such as the hard disk (as either a file or on a separate partition) before powering off the system. Later the system can be restored to the state it was in when hibernation was invoked, so that programs can continue executing…

Read More »