Skip to content

Instantly share code, notes, and snippets.

View KarelWintersky's full-sized avatar

Karel Wintersky KarelWintersky

View GitHub Profile
@KarelWintersky
KarelWintersky / csv2sql.php
Last active August 19, 2017 16:24
CSV to SQL converter (insert and update)
<?php
/**
* (c) Karel Wintersky, 13 Sept. 2016
*/
$content = '';
if ($_POST["ref"] === "csv2sql") {
$table_name = $_POST["table_name"];
$csv_delimeter = @isset($_POST['DELIMETER']) ?: ',';
$csv_enclosure = @isset($_POST['ENCLOSURE']) ?: '"';
$csv_data = $_POST["csv_data"];
@KarelWintersky
KarelWintersky / banner.php
Created September 5, 2017 11:49
Пример реализации баннера для тестового задания
<?php
// здесь id_banner всегда 1
function getRealIP()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
@KarelWintersky
KarelWintersky / osslcrypt.php
Last active September 20, 2017 23:49
openssl_encrypt() cyphers testing comparsion
<?php
/**
* User: Arris
* Date: 21.09.2017, time: 0:35
*/
const TEST_COUNT = 100000;
const SOURCE = 'Тестируем обратимое шифрование на php';
const KEY = "password";
function TESTER( $testing_function, $argument )
@KarelWintersky
KarelWintersky / hash.php
Created September 26, 2017 02:48
PHP HASH algorithms comparsion
<?php
/**
* User: Arris
* Date: 21.09.2017, time: 0:35
*/
const TEST_COUNT = 1000000;
const SOURCE = 'Тестируем построение хэша php с помощью стандартной библиотеки HASH::';
function TESTER( $testing_function, $argument )
{
@KarelWintersky
KarelWintersky / bootstrap-vertical-grid.css
Created September 28, 2017 22:55 — forked from cmcraducu/bootstrap-vertical-grid.css
Bootstrap vertical grid. For laying out full-screen fixed height webapps.
.container-fixed {
bottom: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
}
.container-fixed .col {
height: 100%;
@KarelWintersky
KarelWintersky / two middleware calls.md
Created October 2, 2017 16:20
Two middleware calls

routes/web.php

use App\Http\Middleware\CheckAge;

Route::get('users/{id}', function($id) {

})->middleware(CheckAge::class);
@KarelWintersky
KarelWintersky / standalone_counter.php
Created January 10, 2018 21:18
Standalone simple hit counter
<?php
// вызывается как standalone_counter.php?id=N
// по умолчанию (если id опущен) - принимается равным 1
function getRealIP() {
$ip = '127.0.0.1';
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@KarelWintersky
KarelWintersky / mysql_dbu_create.sh
Created October 9, 2018 00:33
Script to create MySQL db + user
#!/usr/bin/env bash
#
# Script to create MySQL db + user
#
# @author Karel Wintersky <karel.wintersky@gmail.com>
# @version 0.2
# mysql_config_editor set --login-path=proftpd --host=localhost --user=proftpd --password
@KarelWintersky
KarelWintersky / gist:620390b5c1a83893d4e525c112b6e595
Created July 14, 2017 14:30
Backup MySQL to YandexDisk (OAuth)
#!/bin/bash
#
# # # # # # # # # # НАСТРОЙКИ ДОСТУПА К MYSQL # # # # # # # # # #
MYSQL_SERVER=localhost
MYSQL_USER=root
MYSQL_PASSWORD=password
MYSQL_DATABASES="--all-databases"
# Yandex.Disk настройки (как получить - см. https://oauth.yandex.ru/ и https://oauth.yandex.ru/authorize?response_type=token&client_id=?)