SQL Coding Standards
A Sample of My Coding Functions, for Quick Reference.Updated 1 year ago
Coding and Naming Standards:
On every project I've worked on, people have discussed coding & Naming Standards, but we always eventually realize that nobody has written these things down. So I have started these proposed standards:
- Names: like_this
- ID: Must be (INT) Named like: table_id
Coding Analogies
- Variable- Cooking ingredient
- Switch - Train switching station. or a choose your own adventure
- If - For in the road
- Break - Exit out of current Loop
- Exit (or Die)- Quit IMMEDIATELY, and print something to the screen
Regex GEdit:
Delete every other line.([^\n]*\n)[^\n]*\n\1
Regex tester for Search AND Replace:
RegExe.comMake all Links open in a New Window jquery.
<script>$("#content a[href^='http://']").attr("target","_blank");</script><script>$("#content a[href^='https://']").attr("target","_blank");</script>
SQL Queries
Count all Table Rows
SELECT TABLE_NAME, TABLE_ROWS FROM `information_schema`.`tables` WHERE `table_schema` = "adamwith_main";Hwo to assign an array to two variables
I always forget :Plist($first, $second)=array(1,2);
Geo IP Location:
You are in: Columbus, United StatesMy Commonly Used Functions:
View Function: hideemail
function hideEmail($email,$width=null){/*
Hey.
I LOVED your YouTube video, and am considering buying your drill.
But I wanted to tell you about your "click here for phone number" button.
I assume you did this to avoid spam / telemarketers.
I have been a web programmer for 20 years.
I just wanted you to know that "bots" (which steal your sites info and spam you) won't be fooled by this, as they read the HTML, and your phone number is clearly "scrape" -able.
If you'd like something they can't read, that is SUPER simple to do. Just link a pictures (img tag) to something like this:
https://adamwithers.ca/includes/testToImage.php?size=4&color=blue&bgcolor=lightBlue&width=400&text=250-888-1416
This one is mine, but you can gladly use it, or I will send you the code (free of course).
I'll even make it bigger / smaller / colors whatever (super simple)
Anyways :) Love to site
-Adam
*/
if($width!==null){
$width='&width='.$width;
}
return '';
//https://adamwithers.ca/includes/testToImage.php?size=2&color=red&bgcolor=lightBlue&text=adam@adamwithers.ca
}
***Declared In:/home4/adamwith/public_html/includes/functions/adamwithers.ca.php
Add a hyphen to lists when Copying & Pasting
const prependChar = "-"; document.addEventListener("copy", function(e) { const selected = getSelectionHtml(); if (selected.html.includes("
- ${html}