Skip to content

Instantly share code, notes, and snippets.

View edbentinck's full-sized avatar

Ed Bentinck edbentinck

View GitHub Profile
@edbentinck
edbentinck / color_luminance.php
Created January 13, 2017 12:12 — forked from stephenharris/color_luminance.php
Lighten or darken a given colour
<?php
/**
* Lightens/darkens a given colour (hex format), returning the altered colour in hex format.7
* @param str $hex Colour as hexadecimal (with or without hash);
* @percent float $percent Decimal ( 0.2 = lighten by 20%(), -0.4 = darken by 40%() )
* @return str Lightened/Darkend colour as hexadecimal (with hash);
*/
function color_luminance( $hex, $percent ) {
// validate hex string
@edbentinck
edbentinck / gist:d241377b8fef3608f0e6bfc9db55603a
Created February 15, 2020 17:51
Curl request to debug CORS – grep is optional
curl -I \
-H "Origin: https://origin.domain.com" \
-H 'Access-Control-Request-Method: GET' \
https://api.domain.com/example-endpoint 2>&1 | grep 'access-control-allow-origin'
@edbentinck
edbentinck / validate-urls.sh
Created February 20, 2021 23:28
A bash script to validate a given list of URLs
#!/bin/bash
# Use: sh validate-urls.sh urls.txt
if [[ $# -eq 0 ]] ; then
echo 'You must pass the name of a valid text file, containing a list of URLs to be validated.'
exit 0
fi
while read url
@edbentinck
edbentinck / change_instance.sh
Created October 16, 2021 12:57 — forked from nicosnyman/change_instance.sh
Easily change instance types on AWS EC2 with a bash script
#!/bin/bash
# Nico Snyman, [email protected], 14/05/2015
# Change an instance type, while keeping snapshots
# This script will stop an instance identified by instance ID,
# take snapshots of all atached volumes, and restart it
# Use:
# -i instance ID - REQUIRED - stored in instance_id
# -t instance new instance type - REQUIRED - stored in instance_type
# -s if set to 0, no snapshot will be taken, dafault is 1
# (take snapshot of attached volumes) - stored in snapshot