This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ho to transform a decimal time interval (for example, 1.074 minutes) into its equivalent 'mm:ss' value. | |
| Here is some JavaScript that will do what you are asking: | |
| function minTommss(minutes){ | |
| var sign = minutes < 0 ? "-" : ""; | |
| var min = Math.floor(Math.abs(minutes)) | |
| var sec = Math.floor((Math.abs(minutes) * 60) % 60); | |
| return sign + (min < 10 ? "0" : "") + min + ":" + (sec < 10 ? "0" : "") + sec; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h1>Alert</h1> | |
| <p>Bootstrap JS</p> | |
| <div class="alert fade in"> | |
| <button type="button" class="close" data-dismiss="alert">×</button> | |
| <strong>Holy guacamole!</strong> Best check yo self, you're not looking too good. | |
| </div> | |
| <p></p><a ng-click="alert=true">Open Alert (AngularJS)</a></p> | |
| <div class="alert fade" ng-class="{in:alert}"> | |
| <button type="button" class="close" ng-click="alert=false">×</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http://stackoverflow.com/questions/1358540/how-to-count-all-the-lines-of-code-in-a-directory-recursively | |
| find . -name '*.php' | xargs wc -l | |
| ================================== | |
| If you are looking to find filenames then use "find" like this: | |
| find /directory/path/to/search -name "filename or part thereof" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rsync -avh /tmp/foo/ root@host2:/tmp/bar | |
| http://www.evbackup.com/support-commonly-used-rsync-arguments/ | |
| I am having Folder A on my computer which is constantly updated with content. | |
| Another Folder B is used for backup purpose which is on external HDD. | |
| Now what I expect is that whatever extra which is present in folder A should go to folder B. | |
| However something which is present in B and NOT in A ""shall NOT be copied to A"". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cURL | |
| Curl is a command line utility used for multi purpose, basically it is defined as the tool that can transfer data using various protocols such as DICT, FILE, FTP, FTPS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet, Gopher, TFTP and much more. Curl supports SSL certificates and HTTP PUT or HTTP POST features too. In a simple statement we can say that curl can get information and send information via one of the protocol mentioned above. How is it useful for web developers? Curl can send response headers of any website, it can be used to find out the look-up time, connect time or generally saying to check the time consumed in order to reach a website. Its uses are unlimited and it comes as a default software in most of the Linux operating systems. In case if it is not available, you can install it easily with this command. | |
| Install curl in Linux | |
| $sudo apt-get install curl | |
| $su -c "yum install curl" | |
| RSYNC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ============================================================================ | |
| printenv = print environment variables or what php calls global variables | |
| TERM=xterm | |
| SHELL=/bin/bash | |
| USER=user | |
| DEFAULTS_PATH=/usr/share/gconf/xubuntu.default.path | |
| XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg | |
| PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # apt-get install imagemagick | |
| Once installed you will have multiple image processing tools available to our disposal, such as convert, identify and etc. | |
| identify command will help you to get some image information and convert will help you to convert images between hundreds of different image formats as well as it will easily resize any image submitted as an argument. | |
| Let's suppose that our current working directory contains multiple image files with extension *.jpg . To resize all images to a half size of their original size we can combine bash for loop and convert command together in a following manner: | |
| Code: | |
| $ for i in $( ls *.jpg); do convert -resize 50% $i re_$i; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ======================= | |
| tail -f /var/log/syslog | |
| ======================= | |
| #min hour day month weekday command | |
| */1 * * * * <your command> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function createXml($posts, $format = null) | |
| { | |
| /* output in necessary format */ | |
| if ($format == 'json') { | |
| header('Content-type: application/json'); | |
| echo json_encode(array('posts' => $posts)); | |
| } else { | |
| header('Content-type: text/xml'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git remote remove origin | |
| git remote add origin git@example.com:name_of_project.git | |
| git fetch | |
| git merge ... |