Skip to content

Instantly share code, notes, and snippets.

View ThomasPickering's full-sized avatar
🏠
Working from home

Thomas Pickering ThomasPickering

🏠
Working from home
View GitHub Profile
@ThomasPickering
ThomasPickering / test_input($data)
Last active November 13, 2020 13:18
Test Post Input #function #php
// vim: syntax=PHP
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
@ThomasPickering
ThomasPickering / FolderSize SizeFilter
Created November 13, 2020 13:24
FolderSize SizeFilter #php "function
function folderSize($dir){
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
return $size;
}
@ThomasPickering
ThomasPickering / Pure_CSS_badges_tags
Last active December 31, 2020 09:12
Pure CSS badges/tags #css
<style>
.tag {
border-radius: 4px;
display: inline-block;
height: 13px;
line-height: 13px;
padding: 2px 3px 2px 3px;
font-size: 11px;
@ThomasPickering
ThomasPickering / BootstrapAlert.php
Last active January 18, 2022 13:27 — forked from rpmahoney/BootstrapAlert.php
PHP functions to create Bootstrap 3 Alerts
<?php
/**
* Create a bootstrap
* @param String $bold - First words in the alert. Will be put inside <strong> html tag for emphasis
* @param String $level - second words in the alert. Will be put inside <class> html tag for alert severity
* @param String $message - What will be used for the main description in the alert
*/
function Alert($bold, $level, $message)
{
@ThomasPickering
ThomasPickering / ajax-form.js
Created September 27, 2022 09:54 — forked from havvg/ajax-form.js
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@ThomasPickering
ThomasPickering / cli_menu.py
Last active April 13, 2023 05:42
Python : Simple CLI Menu
def main_menu():
while True:
print("Main menu:")
print(" 1. Submenu 1")
print(" 2. Submenu 2")
print(" 3. Exit")
choice = input("Enter your choice: ")
if choice == "1":