Skip to content

Instantly share code, notes, and snippets.

View winminsoe's full-sized avatar

Win Min Soe winminsoe

View GitHub Profile
#!/bin/bash
read -p "Turn on Log?" yn
case $yn in
[Yy]* )
mysql -uroot -e "SET GLOBAL general_log = 'ON'"
mysql -uroot -e "SELECT @@GLOBAL.general_log_file" | tail -n +2 | xargs tail -f
break;;
[Nn]* )
mysql -uroot -e "SET GLOBAL general_log = 'OFF'"
break;;
@winminsoe
winminsoe / mysql-db-size.md
Last active July 7, 2020 04:24
MySQL DB size
SELECT table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size (MB)` 
FROM information_schema.TABLES 
WHERE table_schema = "$your_database";
@winminsoe
winminsoe / git-clearHistory.md
Last active July 7, 2020 04:24 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
-- Remove the history from 
rm -rf .git

-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"

-- push to the github remote repos ensuring you overwrite history
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+---------------------------------------+
| Variable_name    | Value                                 |
+------------------+---------------------------------------+
| general_log      | OFF                                   |
| general_log_file | /usr/local/var/mysql/zsea20180011.log |
+------------------+---------------------------------------+
2 rows in set (0.11 sec)
@winminsoe
winminsoe / remove-gpg-user.sh
Created September 25, 2019 07:31
Git-crypt remove user.
#!/usr/bin/env bash
#
# Script to remove GPG key from git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@winminsoe
winminsoe / php_object_to_array.php
Created July 9, 2018 06:57 — forked from victorbstan/php_object_to_array.php
recursively cast a PHP object to array
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);