Skip to content

Instantly share code, notes, and snippets.

Prisacari Dmitrii icamys

View GitHub Profile
@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" \
@icamys
icamys / recursive-staircase.go
Created Jan 2, 2018
recursive-staircase solution
View recursive-staircase.go
package main
import (
"fmt"
"bufio"
"os"
"strings"
"strconv"
)
View gist:a44e681da232105ec8b8e2175c80f4c3
import json
with open('output-test.json') as data_file:
input_records = json.load(data_file)
command = 'INSERT INTO dle_post_video (player_id, post_id, code) VALUES ({values})'
player_snippet = '<iframe src="{url}" width="667" height="370" frameborder="0" allowfullscreen></iframe>'
bulk = []
max_bulk_size = 20
@icamys
icamys / tarantool_devtools.lua
Last active Aug 10, 2017
Tarantool devtools
View tarantool_devtools.lua
----------------------
-- Development tools
local fiber = require('fiber')
local source_update_fiber_name = 'source_update_fiber'
local M = {}
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
@icamys
icamys / nginx_tarantool_lua.Dockerfile
Last active Jul 6, 2017
Dockerfile: nginx + tarantool upstream module + nginx Lua module (Luajit)
View nginx_tarantool_lua.Dockerfile
# Image includes:
# - nginx
# - nginx_upstream_module (for tarantool)
# - nginx_lua_module (required by luajit)
# - nginx_devel_kit (required by luajit)
# - luajit
# - luarocks
# - lua rock "lua-cjson" (is necessary to work with tarantool response, can be extended with env variable)
FROM alpine:3.4
@icamys
icamys / selenium-php-webdriver-cheatsheet.md
Last active Feb 28, 2020 — forked from aczietlow/selenium-php-webdriver-cheatsheet.md
Cheat sheet for using php webdriver (facebook/webdriver).
View selenium-php-webdriver-cheatsheet.md

Webdriver PHP API workthough

  • Open a browser

    # start an instance of firefox with selenium-webdriver
    
    $browser_type = 'firefox'
    $host = 'http://localhost:4444/wd/hub'
    
    $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => $browser_type);
    
You can’t perform that action at this time.