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
/** | |
* Simple AJAX call helper, with lock mechanism to prevent duplicated concurrent connections. | |
* It sends data in JSON format, you can easily adapt it to to your need. | |
* Dependencies: jQuery ($.ajax) and UnderscoreJS. You can easily remove UnderscoreJS code. | |
*/ | |
var API = new function() { | |
var self = this; | |
// Lock to prevent duplicated concurrent API calls. | |
self.locks = {}; |
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
Show hidden characters
/** | |
* Create a custom [build system](http://bit.ly/17IKkU9) to provide PHP syntax checking. | |
* Save this file as ~/.config/sublime-text-2/Packages/User/PHP.sublime-build | |
* | |
* Usage | |
* - In the editor, select a tab with PHP source code. | |
* - Press F7 or CTRL + B to run PHP syntax check. | |
* - The status will be be displayed in the console at the bottom. | |
* - If it shows error, press F4, and the editor cursor will be brought to the relevant line in the source code. | |
*/ |
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 hexToStr($hex){ | |
$string=''; | |
for ($i=0; $i < strlen($hex)-1; $i+=2){ | |
$string .= chr(hexdec($hex[$i].$hex[$i+1])); | |
} | |
return $string; | |
} | |
$s = '6df157335e0253575c71533a53576d7759279053003100300037003953f7002000200068007400740070003a002f002f007700770077002e006700700073002e0063006f006d002f006d00610070002e0061007300700078003f006c00610074003d00320033002e0031003200330026006c006e0067003d003100310033002e003100320033'; |
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 strToHex($string){ | |
$hex = ''; | |
for ($i=0; $i<strlen($string); $i++){ | |
$ord = ord($string[$i]); | |
$hexCode = dechex($ord); | |
$hex .= substr('0'.$hexCode, -2); | |
} | |
return $hex; | |
} |
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 randomPassword($length = 6) { | |
// Non-ambiguous chars | |
$alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; | |
$alphamax = strlen($alphabet) - 1; | |
$password = ''; | |
for ($i = 0; $i < $length; $i++) { | |
$password .= $alphabet[mt_rand(0, $alphamax)]; | |
} |
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
alias ..='cd ..' | |
alias grep='grep --color=auto' | |
alias mkdir='mkdir -p -v' | |
alias more='less' | |
alias ping='ping -c 5' | |
alias view='vim -R' | |
alias scat='sudo cat' | |
alias sudo='sudo ' | |
alias svim='sudo vim' |
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 | |
/** | |
* Generate random password of given length. | |
* | |
* @param int $length | |
* @return string | |
*/ | |
private function randomPassword($length = 6) { | |
// Non-ambiguous chars | |
$alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; |
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 | |
/** | |
* Generate a build number based on Git commit count and current branch. | |
* @return string Format: "{$branch}.{$commitCount}" | |
*/ | |
public function buildNumber() | |
{ | |
$branch = exec('git rev-parse --abbrev-ref HEAD'); | |
$commitCount = exec('git rev-list HEAD --count'); |
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
<?xml version="1.0" encoding="utf-8"?> | |
<service> | |
<short>RabbitMQ Server</short> | |
<description>Robust messaging for applications</description> | |
<port protocol="tcp" port="5671"/> | |
<port protocol="tcp" port="5672"/> | |
</service> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<service> | |
<short>RabbitMQ Management Console</short> | |
<description>Web interface for managing RabbitMQ</description> | |
<port protocol="tcp" port="15672"/> | |
</service> |
OlderNewer