Skip to content

Instantly share code, notes, and snippets.

View pt-online-schema-change
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 Nov 11, 2017 — forked from AysadKozanoglu/jail.conf
fail2ban nginx 404 400 403 444 filter /etc/fail2ban/filter.d/nginx-4xx.conf
View nginx.conf
# nano /etc/fail2ban/filter.d/nginx-4xx.conf
#
[Definition]
failregex = ^<HOST>.*"(GET|POST).*" (404|444|403|400) .*$
ignoreregex =
View proxy.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,
View gradient_descend_one_var.php
<?php
$set = [
[1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5],
[6, 6],
[6, 6],
View Permissions.php
<?php
namespace App\Services\Roles;
use App\User;
use Illuminate\Contracts\Auth\Access\Gate;
/**
* Class Permissions
* @package App\Services\Roles
*
View translations.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 Jun 2, 2017
PHP HTTP Client
View Client.php
<?php
namespace App\Http;
/**
* <code>
* $client = new \Http\Client();
*
* $response = $client->get('http://google.com');
*
* $response->content(); // text response
View pre-commit.sh
#!/usr/bin/env bash
REGEX="\sdd\((.*)\);|\/\/\sREMOVE"
DD=$(egrep -r ${REGEX} ./app)
if [[ ${DD} ]]
then
echo "$DD"
exit 1
View tip.txt
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 Mar 7, 2016
Websockets. Who else editing this page.
View client.websockets.js
(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',