This file contains 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
app.filter['sprintf'] = function () { | |
return function (str, number) { | |
function parse(str) { | |
var args = [].slice.call(arguments, 1), | |
i = 0; | |
str = str.replace(/{(\d+)}/g, function (a, number) { | |
return typeof args[number] != 'undefined' | |
? args[number] |
This file contains 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
/** | |
* @return bool|string | |
*/ | |
function detectMobileDevice() { | |
$mobile_browser = false; | |
$user_agent = $_SERVER['HTTP_USER_AGENT']; | |
$accept = $_SERVER['HTTP_ACCEPT']; | |
switch(true) { |
This file contains 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
class StemmerEnglish{ | |
function pluralize($word) { | |
$pos = strlen($word)-1; | |
// Check last letter | |
switch ($word{$pos}) { | |
case 's': // Maby already plural | |
if ($word{$pos-1} == 's') | |
return $word.'es'; |
This file contains 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
function win1251_utf8($s){ | |
$t=''; | |
for($i=0, $m=strlen($s); $i<$m; $i++) | |
{ | |
$c=ord($s[$i]); | |
if ($c<=127) {$t.=chr($c); continue; } | |
if ($c>=192 && $c<=207) {$t.=chr(208).chr($c-48); continue; } | |
if ($c>=208 && $c<=239) {$t.=chr(208).chr($c-48); continue; } | |
if ($c>=240 && $c<=255) {$t.=chr(209).chr($c-112); continue; } |
This file contains 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
function Translit_iso($str) { | |
$str=strtr($str,"абвгдезиклмнопрстуфцъыь","abvgdeziklmnoprstufс\"y’"); | |
$str=strtr($str,"АБВГДЕЗИКЛМНОПРСТУФЦЪЫЬ", "ABVGDEZIKLMNOPRSTUFС\"Y’"); | |
$str=strtr($str, array( "э"=>"eh", "х"=>"kh", "й"=>"jj", "ё"=>"jo", "ж"=>"zh", "ч"=>"ch", "ш"=>"sh", "щ"=>"shh", "ю"=>"yu", "я"=>"ya", "э"=>"eh", "х"=>"kh", "й"=>"jj", "ё"=>"jo", "ж"=>"zh", "ч"=>"ch", "ш"=>"sh", "щ"=>"shh", "ю"=>"yu", "я"=>"ya", "ї"=>"i", "ї"=>"yi", "є"=>"ie", "є"=>"ye" )); | |
return $str; | |
} | |
function toTranslit($text, $type = 'translit') { | |
$data = explode(" ", $text); | |
if (count($data) == '') { |
This file contains 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
function num2MultipleRus($int){ | |
$str=strval($int); | |
$fin=$str[strlen($str)-1]; | |
if ($fin==1) return 1; | |
elseif ($fin>1 && $fin<5) return 2; | |
elseif ($fin>4) return 3; | |
} |
This file contains 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
function htmlDiff($old, $new, $exceptions = array()) { | |
$ret = ''; | |
$diff = diff(explode(' ', $old), explode(' ', $new), $exceptions); | |
foreach ($diff as $k) { | |
if (is_array($k)) { | |
$ret .= (!empty($k['d']) ? "<del style='background:#FFFF00;'>" . implode(' ', $k['d']) . "</del> " : '') . (!empty($k['i']) ? "<ins style='background:#00FF00;'>" . implode(' ', $k['i']) . "</ins> " : ''); | |
} | |
else { | |
$ret .= $k . ' '; |
This file contains 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
/* repeat X times to get (table cardinality)^X number of rows in it */ | |
INSERT IGNORE INTO table_to_flood (a,b) SELECT FLOOR(RAND()*100000), UUID() FROM table_to_flood; |
This file contains 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
function php_highlight($source, $classes = true) { | |
$r1 = $r2 = '##'; | |
// adds required PHP tags (at least with vers. 5.0.5 this is required) | |
if (strpos($source, ' ?>') === false) // xml is not THAT important ;-) | |
{ | |
$source = "<?php " . $source . " ?>"; | |
$r1 = '#<\?.*?(php)?.*? #s'; | |
$r2 = '#\?>#s'; | |
} |
This file contains 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
cd /var/www/html | |
git clean -f | |
git fetch --all | |
#git pull origin master | |
git reset --hard origin/master |
OlderNewer