Skip to content

Instantly share code, notes, and snippets.

View waimea-cpy's full-sized avatar
🤔
Slightly confused

Steve Copley waimea-cpy

🤔
Slightly confused
View GitHub Profile
@waimea-cpy
waimea-cpy / reset.css
Last active March 20, 2024 08:00
CSS Reset - Basic CSS reset for a clean start
/*------------------------------------------------------------
Basic CSS Reset to give us a clean starting point
Referencing:
- https://github.com/jgthms/minireset.css
- https://www.joshwcomeau.com/css/custom-css-reset/
- https://github.com/sindresorhus/modern-normalize
------------------------------------------------------------*/
/* Size blocks logically */
html {
@waimea-cpy
waimea-cpy / random-filename.php
Last active March 20, 2024 06:45
PHP Random Filename - PHP function to generate random filename with same extension as given filename, e.g. to avoid filename collisions when uploading
<?php
/*-------------------------------------------------------------
* Generate a random 32 character filename with same extension
* (including no extension) as the filename provided
*-------------------------------------------------------------*/
function randomFilename( $originalFilename ) {
$filenameParts = explode( '.', $originalFilename ); // Break apart the filename
$fileExtension = $filenameParts[sizeof($filenameParts) - 1]; // To get the file extension
@waimea-cpy
waimea-cpy / debug.php
Last active March 20, 2024 06:44
PHP Debug - PHP function to show debug global array debug info in small sidebar
<?php
/*-------------------------------------------------------------
* Display debug info at bottom right of window (shows on hover)
* for the standard PHP arrays: GET / POST / FILE / SESSION, as
* well as the contents of a global $DEBUG variable which can
* be set to any value when debugging code.
*-------------------------------------------------------------*/
function showDebugInfo() {
global $DEBUG;
@waimea-cpy
waimea-cpy / add-like.php
Last active March 20, 2024 06:43
PHP AJAX - Simple example of AJAX requests handled by PHP
<?php
require_once 'common-functions.php';
// Values supplied via the POST request
$id = $_POST['id'];
// Do the data update
$sql = 'UPDATE people
SET likes = likes + 1
@waimea-cpy
waimea-cpy / index.html
Last active March 28, 2024 09:14
Responsive Nav - A clean and simple responsive web page nav setup using a little JS and some CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Navigation</title>
<link rel="stylesheet" href="styles.css">
</head>