Skip to content

Instantly share code, notes, and snippets.

View nicklasos's full-sized avatar
💭
😅

Olkhovyk Mykyta nicklasos

💭
😅
View GitHub Profile
apt-get install percona-toolkit
pt-online-schema-change --print --progress time,5 --max-load Threads_running=500 --critical-load Threads_running=5000 --chunk-time 5 --set-vars "innodb_lock_wait_timeout=600" --nocheck-plan --execute -h {localhost} -u {user} --p "{password}" --alter "ADD {column} varchar(32) DEFAULT NULL" D={database},t={table}
@nicklasos
nicklasos / nginx.conf
Created November 11, 2017 12:18 — forked from AysadKozanoglu/jail.conf
fail2ban nginx 404 400 403 444 filter /etc/fail2ban/filter.d/nginx-4xx.conf
# nano /etc/fail2ban/filter.d/nginx-4xx.conf
#
[Definition]
failregex = ^<HOST>.*"(GET|POST).*" (404|444|403|400) .*$
ignoreregex =
@nicklasos
nicklasos / proxy.php
Last active October 12, 2017 09:55
php
<?php
if (($_SERVER['HTTP_PASSWORD'] ?? null) !== 'ProxyPassword') {
http_response_code(401);
exit();
}
$response = file_get_contents(urldecode($_GET['url']), false, stream_context_create([
'http' => [
'ignore_errors' => true,
<?php
$set = [
[1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5],
[6, 6],
[6, 6],
@nicklasos
nicklasos / Permissions.php
Last active October 12, 2017 09:57
Laravel
<?php
namespace App\Services\Roles;
use App\User;
use Illuminate\Contracts\Auth\Access\Gate;
/**
* Class Permissions
* @package App\Services\Roles
*
@nicklasos
nicklasos / translations.php
Created November 1, 2016 10:42
Translation php
<?php
function csv_to_array($filename)
{
if (!file_exists($filename) || !is_readable($filename)) {
throw new InvalidArgumentException('File does not exists or not readable');
}
$headers = null;
$data = [];
@nicklasos
nicklasos / Client.php
Last active June 2, 2017 12:02
PHP HTTP Client
<?php
namespace App\Http;
/**
* <code>
* $client = new \Http\Client();
*
* $response = $client->get('http://google.com');
*
* $response->content(); // text response
@nicklasos
nicklasos / pre-commit.sh
Created August 29, 2016 10:07
GIT, git
#!/usr/bin/env bash
REGEX="\sdd\((.*)\);|\/\/\sREMOVE"
DD=$(egrep -r ${REGEX} ./app)
if [[ ${DD} ]]
then
echo "$DD"
exit 1
This is what worked for me on OS X Yosemite running MySql v5.7 (installed from the .dmg).
cd /usr/local/mysql/bin
mysql -u root -p --connect-expired-password
(Enter the temporary password generated by the installer.)
This gets you into sandbox mode and mysql> prompt. Then set desired root password with SET PASSWORD:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mySuperSecretPassword');
@nicklasos
nicklasos / client.websockets.js
Last active March 7, 2016 12:04
Websockets. Who else editing this page.
(function () {
var socket = io($('#ws-url').val());
var email = $('#user-name').val();
var editUrls = [
'filemanager/edit',
'media/update',
'courses/show',
'screenshot/index',
'card/update',
'skin/update',