Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍🎓
Master's thesis has been defended

Dmitry Balabka dbalabka

👨‍🎓
Master's thesis has been defended
View GitHub Profile
@dbalabka
dbalabka / ttfb.sh
Last active Jun 2, 2020 — forked from sandeepraju/ttfb.sh
cURL command to check the request timing (including TTFB)
View ttfb.sh
#!/bin/bash
# file: ttfb.sh
# curl command to check the time to first byte
# ** usage **
# 1. ./ttfb.sh "https://google.com"
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com"
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
@dbalabka
dbalabka / main.dart
Created Oct 1, 2019
Bidirectional type inference in dart
View main.dart
void main() {
print(foo('bar'));
// will rise an error
foo(1);
}
foo ($s) {
return 'foo' + $s;
}
@dbalabka
dbalabka / ignore_notices_warning_selectively_test.php
Created Jul 22, 2019
iddqd for PHP to ignore notices and warning selectively, while using Symfony ErrorHandler. Helps to upgrade PHP smoothly.
View ignore_notices_warning_selectively_test.php
<?php
use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Debug\ErrorHandler;
$loader = require_once __DIR__ . '/vendor/autoload.php';
class ConfigurableErrorHandler extends ErrorHandler
{
@dbalabka
dbalabka / gist:f8c19044282db049e71ca143dd3e0680
Created Mar 23, 2018 — forked from trongthanh/gist:2779392
How to move a folder from one repo to another
View gist:f8c19044282db049e71ca143dd3e0680
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- --all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
@dbalabka
dbalabka / generator.php
Last active Jul 31, 2017
Inteteresting PHP generators behavior
View generator.php
<?php
class TestGenerator {
public function task1($doGenerate = true)
{
echo "Enter generator\n";
if ($doGenerate) {
echo "Generate values\n";
yield 1;
yield 2;
@dbalabka
dbalabka / constructor-arguments.php
Created May 19, 2017
Using new PHP7 operator "..." to provide variable number of arguments into constructor we can easier manage child classes constructor interfaces.
View constructor-arguments.php
<?php
class ParentClass
{
public $a;
public $b;
public function __construct($a, $b)
{
$this->a = $a;
@dbalabka
dbalabka / remove-all-cookies.js
Created Jan 7, 2016
Removes all cookies on current page
View remove-all-cookies.js
(function () {
var cookie = document.cookie.split(';');
for (var i = 0; i < cookie.length; i++) {
var chip = cookie[i],
entry = chip.split("="),
name = entry[0],
domain = window.location.hostname;
document.cookie = name + '=; domain=' + domain + '; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/;';
View check_realpath_cache_usage.php
<?php
$size = 0;
foreach (realpath_cache_get() as $pathInfo) {
$size += strlen($pathInfo['realpath']) + 1 + 56;
}
var_dump($size, ini_get('realpath_cache_size'));
@dbalabka
dbalabka / api.js
Last active Aug 18, 2016
Google Experiment Client
View api.js
(function () {
var d, f = this, k = function (a, c, b) {
a = a.split(".");
b = b || f;
a[0] in b || !b.execScript || b.execScript("var " + a[0]);
for (var e; a.length && (e = a.shift());)a.length || void 0 === c ? b = b[e] ? b[e] : b[e] = {} : b[e] = c
}, l = Date.now || function () {
return +new Date
};
var p = function (a) {
@dbalabka
dbalabka / ghost-upgrade.sh
Created Jul 16, 2015
Ghost blog upgrade with full backup
View ghost-upgrade.sh
#!/bin/sh
cd /var/www &&
service ghost stop &&
now=$(date +"%Y%m%d_%H%M%S") &&
tar -zcvf "ghost_${now}.tar.gz" ./ghost &&
wget http://ghost.org/zip/ghost-latest.zip -O ghost-latest.zip &&
rm -rf ghost/core &&
unzip -uo ghost-latest.zip -d ghost &&
chown -R ghost:ghost ghost/* &&
cd ghost &&
You can’t perform that action at this time.