Skip to content

Instantly share code, notes, and snippets.

@thejohn
thejohn / mysql - kill all sleeping connections
Created March 3, 2021 05:40 — forked from lucashungaro/mysql - kill all sleeping connections
MySQL - kill command for all idle queries
SELECT GROUP_CONCAT('kill ',id SEPARATOR '; ') AS kill_list
FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE command='Sleep';
@thejohn
thejohn / massInsertOrUpdate.php
Created February 23, 2021 11:16 — forked from RuGa/massInsertOrUpdate.php
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@thejohn
thejohn / Simple php encryption
Last active October 25, 2018 03:58
Simple PHP Encrypt, Decrypt
function encrypt($data, $salt='!kQm*fF3pXe1Kbm%9') {
$key = hash('SHA256', $salt, true);
srand(); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22){
return false;
}
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data . md5($data), MCRYPT_MODE_CBC, $iv));
return $iv_base64 . $encrypted;
}
@thejohn
thejohn / Font Awesome web application icons array
Last active August 29, 2015 14:19
Font Awesome web application icons array, this was a pain but someone has to do it.
$list = array(
"adjust", "anchor", "archive",
"area-chart", "arrows", "arrows-h",
"arrows-v", "asterisk", "at",
"automobile", "ban", "bank",
"bar-chart", "bar-chart-o", "barcode",
"bars", "bed", "beer", "bell", "bell-o",
"bell-slash", "bell-slash-o", "bicycle",
"binoculars", "birthday-cake", "bolt",
"bomb", "book", "bookmark", "bookmark-o",
<select id="yy" name="yy">
<option value="">--Year--</option>
<?php
$startYear = 1920; /*Start counting from the year 1920*/
$endYear = date('Y'); /*End count in the current year*/
foreach (range($startYear, $endYear) as $year) {
?>
<option value="<?php echo $year;?>"><?php echo $year;?></option>
<?php