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 /
Last active Jul 2, 2019
Bulk insert data from file to elasticsearch (python)
Usage: python data.ndjson
import sys
import json
import logging
from elasticsearch import Elasticsearch
from elasticsearch.helpers import streaming_bulk
icamys /
Last active May 22, 2019
Import data from file to elasticsearch (python)
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 /
Last active Jul 25, 2018
Rename mysql database alternative
mysqldump old_database_name > dump.sql
mysqladmin create new_database_name
mysql new_database_name < dump.sql
mysqladmin drop old_database_name
icamys /
Last active Jul 17, 2018
VIsit all cells in grid like a snail
import sys
assert len(sys.argv) == 2
width, height = sys.argv[1].split('x')
width = int(width)
height = int(height)
assert width > 0
icamys /
Last active Jul 16, 2018
Reverse integer in binary form
import sys
def leading_zeros(x: int):
n = 32
y = x >> 16
if y != 0:
n = n - 16
x = y
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());
icamys / DuskServeCommand.php
Created Apr 12, 2018
Serve the laravel application and run Dusk tests
View DuskServeCommand.php
namespace App\Console\Commands;
use RuntimeException;
use Laravel\Dusk\Console\DuskCommand;
use Symfony\Component\Process\Process;
class DuskServeCommand extends DuskCommand
# 1. Install this plugin in wordpress:
# 2. Create wordpress user with username 'admin' and password 'admin'
# 3. Download an image and save it as 'google.jpg'
# 4. Upload image to wordpress REST API
curl \
-H "cache-control: no-cache" \
icamys / recursive-staircase.go
Created Jan 2, 2018
recursive-staircase solution
View recursive-staircase.go
package main
import (
You can’t perform that action at this time.