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 / elastic_import_data_bulk.py
Created May 22, 2019
Bulk insert data from file to elasticsearch (python)
View elastic_import_data_bulk.py
import json
from elasticsearch import Elasticsearch
from elasticsearch.helpers import streaming_bulk
filename = '/tmp/data.json'
es = Elasticsearch("http://localhost:9200", http_auth=('username', 'password'))
def gendata():
@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)
View ip4_perf.sql
-- Performance test
-- Comparing ip address as bigint and as ip4 (ip4r extension)
DROP TABLE IF EXISTS test_perf_ip_bigint;
CREATE TABLE IF NOT EXISTS test_perf_ip_bigint (
ip bigint
);
INSERT INTO test_perf_ip_bigint
SELECT ip
@icamys
icamys / inet_perf_gist.sql
Last active Dec 12, 2018
Postgres inet performance test
View inet_perf_gist.sql
DROP TABLE IF EXISTS test_perf_ip_bigint;
CREATE TABLE IF NOT EXISTS test_perf_ip_bigint (
ip bigint
);
INSERT INTO test_perf_ip_bigint
SELECT ip
FROM dns_a_record
LIMIT 100000000;
@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);
@icamys
icamys / DuskServeCommand.php
Created Apr 12, 2018
Serve the laravel application and run Dusk tests
View DuskServeCommand.php
<?php
namespace App\Console\Commands;
use RuntimeException;
use Laravel\Dusk\Console\DuskCommand;
use Symfony\Component\Process\Process;
class DuskServeCommand extends DuskCommand
{
View wp_rest_create_post.sh
# 1. Install this plugin in wordpress:
# https://github.com/WP-API/Basic-Auth
# 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" \
You can’t perform that action at this time.