Skip to content

Instantly share code, notes, and snippets.

View spectrox's full-sized avatar

Farkhad Vildanov spectrox

  • TheSoul Publishing
View GitHub Profile
# Все команды рассчитаны на мак
function dc-clear-logs {
SERVICENAME=$1
CONTAINER=$(docker-compose ps "$SERVICENAME" | grep "$SERVICENAME" | awk '{ print $1 }')
LOGPATH=$(docker inspect --format='{{.LogPath}}' "$CONTAINER")
echo 'echo "" > '"$LOGPATH" > ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
}
function git-sync-branch {
@spectrox
spectrox / docker-compose.yml
Created May 15, 2018 20:31
Selenium Hub + Selenium Chrome + Selenium Firefox + Node WebDriver
hub:
image: selenium/hub
ports:
- 4444:4444
chrome:
image: selenium/node-chrome-debug
links:
- hub:hub
ports:
@spectrox
spectrox / .htaccess
Created April 28, 2018 13:36
HTTP -> HTTPS rewrite (Apache behind nginx proxy)
RewriteCond %{HTTP:X-Forwarded-Port} !=443
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
if ($request_method = GET) {
set $test A;
}
if ($http_cookie !~* "auth_token") {
set $test "${test}B";
}
if ($test = AB) {
return 418;
@spectrox
spectrox / php-such-a-php.php
Last active December 25, 2015 14:59
PHP...
Interactive shell
php > class A { public $i = 3; public function __toString() { return $this->i; } }
php > $a = new A();
php > echo "$a" + 2;
PHP Catchable fatal error: Method A::__toString() must return a string value in php shell code on line 1
php > $a->i = '3';
php > echo "$a" + 2;
5
php >
@spectrox
spectrox / TRUE_true.php
Last active December 17, 2015 02:48
PHP: difference between true and TRUE
$ php -a
php > define('true', false);
PHP Notice: Constant true already defined in php shell code on line 1
php > define('TRUE', false);
php > echo true;
1
php > echo TRUE;
php >
$ php -r 'define("TRUE", "asd");echo TRUE;'
@spectrox
spectrox / singleton.html
Last active November 21, 2017 19:50
Singleton pattern
<!DOCTYPE html>
<html>
<head>
<title>Singleton Example</title>
</head>
<body>
<script>
// one way to create Singleton
console.log('first way:');
@spectrox
spectrox / polygon.php
Last active April 30, 2020 15:48
Polygon
<?php
class Polygon {
/**
* @var array
*/
protected $polygon = [];
/**
* Polygon itself, with basic vector-based structure