Skip to content

Instantly share code, notes, and snippets.

View quisido's full-sized avatar
🌸
trying my best

quisi.do quisido

🌸
trying my best
View GitHub Profile
@quisido
quisido / .htaccess
Last active August 2, 2018 17:13
Creating a Dynamic Vertical Gradient in PHP
RewriteEngine On
RewriteRule ^gradients\/(\d+)\-([a-fA-F\d]{6})-([a-fA-F\d]{6})\.gif$ gradient.php?height=$1&from=$2&to=$3 [L,NC]
@quisido
quisido / dynamic-vertical-gradient.php
Created August 2, 2018 17:08
Creating a Dynamic Vertical Gradient in PHP
<?php
// Validate inputs.
if (
!array_key_exists('from', $_GET) ||
!preg_match('/^[a-fA-F\d]{6}$/', $_GET['from']) ||
!array_key_exists('to', $_GET) ||
!preg_match('/^[a-fA-F\d]{6}$/', $_GET['to']) ||
!array_key_exists('height', $_GET) ||
!is_numeric($_GET['height']) ||
@quisido
quisido / example-gradient.html
Created August 2, 2018 17:10
Creating a Dynamic Vertical Gradient in PHP
<style type="text/css">
#my-site-header {
background-color: #FFFFFF;
/* gradient: 16px height, #ffffff start, #404080 end */
background-image: url("http://i.imgur.com/4L3aj.gif");
background-position: left bottom;
background-repeat: repeat-x;
}
@quisido
quisido / calculate-steps-example.php
Created August 2, 2018 17:11
Creating a Dynamic Vertical Gradient in PHP
<?php
// gradient with 10px height
$height = 10;
// start color is #fa0000
$start = Array(250, 0, 0);
// end color is #00c864
$end = Array(0, 200, 100);
@quisido
quisido / calculate-steps.php
Last active August 30, 2018 21:16
Creating a Dynamic Vertical Gradient in PHP
<?php
// You may replace this with a static height.
$height = $_GET['height'];
// You may replace this with a static start color.
// RGB goes here, e.g. Array(255, 0, 0) for red
$start = Array();
// You may replace this with a static end color.
@quisido
quisido / validate.php
Created August 2, 2018 17:12
Creating a Dynamic Vertical Gradient in PHP
<?php
// provide a generic 404 error if...
if (
// FROM/START color does not exist
!array_key_exists('from', $_GET) ||
// FROM/START color is not valid hex
!preg_match('/^[a-fA-F\d]{6}$/', $_GET['from']) ||
@quisido
quisido / create-image.php
Created August 2, 2018 17:13
Creating a Dynamic Vertical Gradient in PHP
<?php
// Tell the browser it's a GIF image.
header('Content-Type: image/gif');
/*
Create an image with a width of 1 and height of $height.
Width only needs to be 1px because it will presumably
be tiled horizontally.
*/
@quisido
quisido / characters.js
Created August 2, 2018 22:25
Establishing a Secure Password Generator for Your User Base
var characters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789`~!@#$%^&*()_-+=[{]}|;:,.<>/?";
@quisido
quisido / password-generator.js
Last active August 2, 2018 22:45
Establishing a Secure Password Generator for Your User Base
// Valid characters.
var characters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789`~!@#$%^&*()_-+=[{]}|;:,.<>/?";
// password(X) will return a password of length X.
// password() will return a password of length 12.
var password = function(size) {
// Placeholder string, where our final password will end up.
@quisido
quisido / password-generator.php
Created August 2, 2018 22:31
Establishing a Secure Password Generator for Your User Base
<?php
$characters =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' .
'0123456789`~!@#$%^&*()_-+=[{]}|;:,.<>/?';
$strlen_characters = strlen($characters);
function password($length) {
$temp = "";