Skip to content

Instantly share code, notes, and snippets.

View mmuruev's full-sized avatar
🤨

Maksim Muruev mmuruev

🤨
  • One Touch
  • Estonia
View GitHub Profile
@mmuruev
mmuruev / detectScriptPlaceDir.sh
Created May 17, 2020 15:22
Bash detection script dir place.
#!/bin/bash
### CURENCT SCRIPT DIR DETECTION
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
/* CREATE output SQL for safe delete TABLES FK_KEYS even if on target DB some are missing*/
SELECT
/* TABLE_NAME,
COLUMN_NAME,
CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME,*/
concat(
'set @var=if((SELECT true FROM information_schema.TABLE_CONSTRAINTS WHERE
CONSTRAINT_SCHEMA = DATABASE() AND
// ==UserScript==
// @name Tinder Like Clicker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://tinder.com/app/recs
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==
#!/usr/bin/env bash
# WD Cloud repair script will destroy all data and system partitions!!!
# based on http://anionix.ddns.net/WDMyCloud/WDMyCloud-Gen1/Replace%20HDD.txt
DEVICE=/dev/sdd
MOUNT_DIR=/mnt/wdcloud
echo 'WD Cloud repair script will destroy all data and system partitions!!!'
echo 'Formating device: ' ${DEVICE}
function compareAges(a,b) {
if (a.age < b.age)
return -1;
if (a.age > b.age)
return 1;
return 0;
}
let people = [{ name: 'John', age: '21' } , { name: 'Nick', age: 12 }, { name: 'Old' , age: 99 }];
people.sort(compareAges);
@mmuruev
mmuruev / mysql_remove_tables_by_database_or_tables_prefix.sql
Created December 27, 2016 10:00
Script for remove in one command all tables in databases, by given template
SET GROUP_CONCAT_MAX_LEN=10000;
SET @del = (
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(CONCAT('`' , TABLE_SCHEMA , '`.`',table_name,'`')) , ';' )
AS statement FROM information_schema.tables
WHERE
TABLE_SCHEMA LIKE 'MY_DB_PREFIX_%' /* Criteria for selection */
OR TABLES.TABLE_NAME LIKE 'MY_TABLE_PREFIX_%';
);
@mmuruev
mmuruev / pre-commit
Created July 1, 2016 14:11
Limit commits in git local repo to 5mb for file. (Preventing accidental commits DB_DUMP.sql fiels and so on...)
#!/usr/bin/env bash
# make it chmod a+x ./git/hooks/pre-commit
GITCMD=$(which git) # "/usr/bin/git"
NULLSHA="0000000000000000000000000000000000000000"
MAXSIZE="5242880" # 5MB limit on file size
EXIT=0
echo 'START PRECOMMIT CHECKING...'
bbswitch, 0.7, 3.5.0-39-generic, x86_64: installed
bbswitch, 0.7, 3.5.0-40-generic, x86_64: installed
vboxhost, 4.2.16, 3.5.0-39-generic, x86_64: installed
vboxhost, 4.2.16, 3.5.0-40-generic, x86_64: installed
$ dpkg -l | grep nvidia
ii bumblebee-nvidia 3.2.1-1~quantalppa4 amd64 NVIDIA Optimus support using the proprietary NVIDIA driver
ii libkwinnvidiahack4 4:4.10.5-0ubuntu0.1~ubuntu12.10~ppa2 amd64 library used by nvidia cards for the KDE window manager
ii nvidia-common 1:0.2.71.1 amd64 transitional package for ubuntu-drivers-common
ii nvidia-current 304.88-0ubuntu0.1 amd64 NVIDIA binary Xorg driver, kernel module and VDPAU library
ii nvidia-settings 304.88-0ubuntu0.2 amd64 Tool for configuring the NVIDIA graphics driver
@mmuruev
mmuruev / gist:3799868
Created September 28, 2012 13:30
ExtJS 4 combobox problem.js
Ext.define('Writer.Form', {
extend:'Ext.form.Panel',
alias:'widget.writerform',
requires:['Ext.form.field.Text'],
initComponent:function () {
this.addEvents('create');
Ext.apply(this, {
activeRecord:null,