Blog

Handling Cookies in JavaScript

folder_openCoding, Snippets
commentNo Comments
Getting the Cookies: function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null;…
Click Me

MySQL – Drop all Tables from Command Line

folder_openSnippets, Coding
commentNo Comments
DROP PROCEDURE IF EXISTS `drop_all_tables`; DELIMITER $$ CREATE PROCEDURE `drop_all_tables`() BEGIN DECLARE _done INT DEFAULT FALSE; DECLARE _tableName VARCHAR(255); DECLARE _cursor CURSOR FOR SELECT table_name FROM information_schema.TABLES WHERE table_schema = SCHEMA(); DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done =…
Click Me

Check available RAM in Linux

folder_openSnippets, Coding
commentNo Comments
This will convert any kB lines to MB: awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t 1 awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t This version converts to gigabytes: awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t 1 awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t…
Click Me

Has word in String? – PHP

folder_openSnippets
commentNo Comments
function hasWord($word, $txt) { $patt = "/(?:^|[^a-zA-Z])" . preg_quote($word, '/') . "(?:$|[^a-zA-Z])/i"; return preg_match($patt, $txt); } $string = 'This is my own paragraph.'; echo hasWord('no', $string); 123456 function hasWord($word, $txt) {    $patt = "/(?:^|[^a-zA-Z])" . preg_quote($word, '/') . "(?:$|[^a-zA-Z])/i";    return preg_match($patt, $txt);}$string…
Click Me
Menu