Skip to content

Instantly share code, notes, and snippets.

View dkrnl's full-sized avatar

Dmitri Pyatkov dkrnl

View GitHub Profile
@dkrnl
dkrnl / selectize-optgroup_checkbox.js
Last active December 6, 2023 10:52
Selectize optgroup checkbox
/**
* Plugin: "optgroup_checkbox" (selectize.js)
* Copyright (c) 2015 Dmitri Piatkov & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
@dkrnl
dkrnl / git-last-commit-files-changed.sh
Created September 15, 2022 07:22
git last commit files changed
git diff --name-only HEAD@{1} HEAD
@dkrnl
dkrnl / find-duplicate.sh
Created July 5, 2022 12:23
find duplicate files
find . -mindepth 1 -printf '%h %f\n' | sort -t ' ' -k 2,2 | uniq -f 1 --all-repeated=separate | tr ' ' '/'
@dkrnl
dkrnl / mysql-optimize-innodb.sh
Created April 15, 2016 02:31
mysql optimize innodb
#!/bin/sh
set -x
for i in `mysql --batch --execute 'SELECT CONCAT("\`", REPLACE(table_schema, "\`", "\`\`"), "\`.\`", REPLACE(table_name, "\`", "\`\`"), "\`") as \`mysql.db\` FROM information_schema.tables where ENGINE="MyISAM" and table_schema!="information_schema"'`; do mysql --execute "OPTIMIZE NO_WRITE_TO_BINLOG table $i;"; done
for i in `mysql --batch --execute 'SELECT CONCAT("\`", REPLACE(table_schema, "\`", "\`\`"), "\`.\`", REPLACE(table_name, "\`", "\`\`"), "\`") as \`mysql.db\` FROM information_schema.tables where ENGINE="InnoDB" and table_schema!="information_schema"'`; do mysql --execute "ALTER TABLE $i ENGINE=InnoDB; ANALYZE NO_WRITE_TO_BINLOG TABLE $i;"; done
mysql --execute 'PURGE BINARY LOGS BEFORE NOW();'
mysql --execute 'FLUSH TABLES;'
@dkrnl
dkrnl / what-forces-layout.md
Created June 21, 2022 04:10 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@dkrnl
dkrnl / gist:95f9d1809368c3c3a07b
Last active March 2, 2020 09:57
Mysql Optimize Table InnoDB
#!/usr/bin/env php
<?php
$server = "localhost";
$username = "***";
$password = "****";
$connection = mysql_connect($server, $username, $password);
if (!$connection) {
die("Connection error: " . mysql_error());
U+0000
U+0002
U+000D
U+0020
U+0021
U+0022
U+0023
U+0024
U+0025
U+0026
#!/bin/sh
find -name '*.png' -print0 | xargs -0 optipng -o7
/* eslint global-require: "off" */
const fs = require('fs');
const path = require('path');
const postcss = require('postcss');
const { URLSearchParams } = require('url');
const DEBUG = ('DEBUG' in process.env && parseInt(process.env.DEBUG, 10) > 0);
const PROD = ('NODE_ENV' in process.env && process.env.NODE_ENV === 'production') || process.argv.indexOf('-p') !== -1;
const { browserslist: BROWSERS } = require('./package.json');
@dkrnl
dkrnl / root-backup.sh
Created August 16, 2016 05:03
Backup root directory + tar gzip
#!/usr/bin/env bash
cd /var/backups/root
# backup root folders
tar -cvzf root.$(date +%F).tgz /bin/ /boot/ /etc/ /home/ /lib/ /lib64/ /opt/ /root/ /sbin/ /usr/
# remove older backups
find /var/backups/root -type f -name '*.tgz' -mtime +30 -delete