Skip to content

Instantly share code, notes, and snippets.

View HendrikEduard's full-sized avatar

Hendrik Eduard Kuiper HendrikEduard

View GitHub Profile
@HendrikEduard
HendrikEduard / cookies.js
Last active February 12, 2019 07:57
Javascript set and get cookie functions
function setcookie(name, value, expiry, path, domain) {
if (expiry) {
var now = new Date();
now.setTime(now.getTime() + Math.round(86400000 * expiry)); // in days
}
document.cookie = name + '=' + escape(value) +
(expiry ? '; expires=' + now.toGMTString() : '') +
(path ? '; path=' + path : '') +
(domain ? '; domain=' + domain : '');
}
@HendrikEduard
HendrikEduard / functions.php
Last active January 22, 2021 07:17
PHP function that creates a multiplication table / column
<?php
/**
* Creates a multiplication table / column
*
* @param [number] $by - number to multiply by
* @param [number] $begin - number to begin the column
* @param [number] $end - number to end the column
*
* @author Hendrik Eduard Kuiper
<?php
function random_passwords($length,$count,$characters) {
// $length - the length of the generated password(s)
// $count - number of passwords to be generated
// $characters - types of characters to be used in the password
// define variables used within the function
$symbols = [];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Eze_JS event listeners</title>
<script>
function addListeners() {
if(window.addEventListener) {
@HendrikEduard
HendrikEduard / admin.sql
Created September 10, 2018 14:02
MySQL "Admin" table sql
--
-- You will see several spelling errors.
-- These are intentional. Whichever language you speak/use always make spelling mistakes!!
--
CREATE DATABASE IF NOT EXISTS `8dCXCpnx!UT8U+dO=2` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `8dCXCpnx!UT8U+dO=2`;
-- Table structure for table `administators`
-- The Admin password is 7648edd7ddbd1ce2
@HendrikEduard
HendrikEduard / generator.php
Created September 10, 2018 09:58
A PHP random string generator
<?php
/*
* A random string generator to create a random string
* of any desired length.
*/
function random_string_generator($length){
$result = "";
$chars = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!$%&*()_-+=";
@HendrikEduard
HendrikEduard / a_secure_password.php
Last active September 10, 2018 07:33
PHP Generate a secure password and hash it.
<?php
/*
* Generate a secure password and hash it
* to insert into your Database.
*/
$password = bin2hex(random_bytes(8));
echo "password is => ", $password, " hash is => ";
@HendrikEduard
HendrikEduard / hashtag.php
Last active December 9, 2021 03:02
A PHP script to create hashtags.
<?php
/*
* Create Hashtags
*/
$string = 'This is the #content the user #wrote';
$explode = explode(' ', $string);
$hashtag = COUNT($explode);
@HendrikEduard
HendrikEduard / fibonacci.php
Created September 4, 2018 09:57
Create the Fibonacci Sequence in PHP
<?php
function fibonacci($n) {
$current = 1;
$previous = 0;
for ($i = 0; $i < $n; $i++) {
yield $current;
$temporary = $current;
$current = $previous + $current;
$previous = $temporary;
@HendrikEduard
HendrikEduard / functions.php
Last active August 28, 2018 10:34
A PHP function to test for non alpha-numeric characters in a form field.
<?php
function check_for_non_alpha_numeric($str) {
$reg = '/[^[:alnum:]$]/';
preg_match_all($reg, $str, $matches, PREG_SET_ORDER, 0);
if($matches) {
print "<hr>oops, try again.<pre>";
var_dump($matches);
} else {