Skip to content

Instantly share code, notes, and snippets.

Prisacari Dmitrii icamys

Block or report user

Report or block icamys

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@icamys
icamys / go_profiling.md
Last active Sep 18, 2019
Golang performance profiling tips with pprof
View go_profiling.md

Here are some tips on profiling golang code with pprof.

Starting profiling server

Run a profiling server in your code on port 20020:

import (
	"net/http"
	    _ "net/http/pprof"
View install_docker_compose.sh
#!/bin/bash
# Install docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
View install_docker_compose.sh
#!/bin/bash
# Install docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
@icamys
icamys / elastic_import_data_bulk.py
Last active Jul 2, 2019
Bulk insert data from file to elasticsearch (python)
View elastic_import_data_bulk.py
"""
Usage: python elastic_import_data_bulk.py data.ndjson
"""
import sys
import json
import logging
from elasticsearch import Elasticsearch
from elasticsearch.helpers import streaming_bulk
@icamys
icamys / elastic_import_data.py
Last active May 22, 2019
Import data from file to elasticsearch (python)
View elastic_import_data.py
import json
from elasticsearch import Elasticsearch
filename = './import-files/data.json'
es = Elasticsearch("http://localhost:9200", http_auth=('elastic', 'changeme'))
i = 1
f = open(filename)
@icamys
icamys / rename_db.sh
Last active Jul 25, 2018
Rename mysql database alternative
View rename_db.sh
#!/bin/bash
mysqldump old_database_name > dump.sql
mysqladmin create new_database_name
mysql new_database_name < dump.sql
mysqladmin drop old_database_name
@icamys
icamys / visit.py
Last active Jul 17, 2018
VIsit all cells in grid like a snail
View visit.py
import sys
assert len(sys.argv) == 2
width, height = sys.argv[1].split('x')
width = int(width)
height = int(height)
assert width > 0
@icamys
icamys / reverse_bin.py
Last active Jul 16, 2018
Reverse integer in binary form
View reverse_bin.py
import sys
def leading_zeros(x: int):
n = 32
y = x >> 16
if y != 0:
n = n - 16
x = y
@icamys
icamys / DuskTestCase::captureFailureFor.php
Created Jun 7, 2018
Laravel Dusk: method that makes full-size screenshot in Chrome browser of failed tests
View DuskTestCase::captureFailureFor.php
protected function captureFailuresFor($browsers)
{
$browsers->each(function (Browser $browser, $key) {
$body = $browser->driver->findElement(WebDriverBy::tagName('body'));
if (!empty($body)) {
$currentSize = $body->getSize();
$size = new WebDriverDimension($currentSize->getWidth(), $currentSize->getHeight());
$browser->driver->manage()->window()->setSize($size);
}
$browser->screenshot('failure-'.$this->getName().'-'.$key);
You can’t perform that action at this time.