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 | |
/** | |
* Проверяет наличие строковых ключей в массиве | |
* @param array $arr | |
* @return bool | |
* @link http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential | |
*/ | |
function is_assoc($arr) | |
{ | |
if(!is_array($arr)) { |
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 | |
/** | |
* pre() | |
* выводит обернутый в <pre>: print_r для массивов и объектов или var_dump для простых | |
* если включен error_reporting и display_errors | |
* | |
* @param mixed $expression | |
* @param bool $return | |
* @return bool || html | |
*/ |
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 | |
//http://stackoverflow.com/questions/6750531/using-a-php-file-to-generate-a-mysql-dump | |
//error_reporting(E_ALL); ini_set('display_errors', 'on'); | |
$DBUSER = "root"; | |
$DBPASSWD = "pass"; | |
$DATABASE = "mydb"; | |
header('Content-Type: text/plain'); | |
header('Content-Disposition: attachment; filename="backup-' . date("Y-m-d-His") . '.sql"'); |
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 | |
/** | |
* Отличительной чертой именно этой функции является высокая скорость работы, по сравнению с аналогами. | |
* @param string $format - The format of the outputted date string. | |
* F Полное наименование месяца, например Января или Марта от Января до Декабря | |
* M Сокращенное наименование месяца, 3 символа От Янв до Дек | |
* l (строчная 'L') Полное наименование дня недели От Воскресенье до Суббота | |
* D Сокращенное наименование дня недели, 2 символа от Вс до Сб | |
* остальные варианты форматирования см. функцию date() в мануале. | |
* @param mixed $timestamp is optional and defaults to the value of time() |
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
.table .btn-group { | |
white-space: nowrap; | |
} | |
.table .btn-group .btn { | |
display: inline-block; | |
float: none; | |
} | |
.table .btn-group .btn + .btn { | |
margin-left: -5px; | |
} |
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 sameOrigin($url1, $url2, $level = 2) | |
{ | |
$host1 = strpos($url1, '://') ? parse_url($url1, PHP_URL_HOST) : $url1; | |
$host2 = strpos($url2, '://') ? parse_url($url2, PHP_URL_HOST) : $url2; | |
return host2origin($host1, $level) == host2origin($host2, $level); | |
} | |
function host2origin($host, $level = 2) | |
{ |
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
#!/bin/sh | |
# Usage: | |
# ./backup-repo.sh /path/to/reponame | |
# | |
# Result: | |
# /backup/reponame/reponame.YYYY-MM-DD.HHMMSS.tar | |
if [ ! -d "$1" ]; then | |
echo "'$1' is not a directory!" |
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
#!/bin/sh | |
# Usage: | |
# ./clean-branches.sh /path/to/reponanme | |
if [ ! -d "$1" ]; then | |
echo "'$1' is not a directory!" | |
echo "Usage:" | |
echo "$0 /path/to/reponame" | |
exit 1 |
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
#!/bin/sh | |
while read oldrev newrev refname | |
do | |
#echo post-receive: $oldrev $newrev $refname >> ~/post-receive.log | |
if [ "$oldrev" != "$newrev" ]; then | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [ "master" == "$branch" ]; then | |
echo Deploying $branch branch to production |
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
#!/bin/sh | |
# Usage: | |
# ./pull-repo.sh /path/to/reponame [branchname =master] | |
# | |
# Logs: | |
# /var/log/gitbot/reponame.log | |
if [ ! -d "$1" ]; then | |
echo "'$1' is not a directory!" |
OlderNewer