Skip to content

Instantly share code, notes, and snippets.

View MarQuisKnox's full-sized avatar

MarQuis Knox MarQuisKnox

View GitHub Profile
@kohnmd
kohnmd / flatten.php
Last active September 20, 2021 12:48
Function to recursively flatten multidimensional PHP array.
<?php
// Requires PHP 5.3+
// Found here: http://stackoverflow.com/a/1320156
function flatten_array(array $array) {
$flattened_array = array();
array_walk_recursive($array, function($a) use (&$flattened_array) { $flattened_array[] = $a; });
return $flattened_array;
}
@turret-io
turret-io / aes_enc_dec.php
Last active March 26, 2025 08:04
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well
@chadsmith
chadsmith / FaviconAwesome.js
Last active January 11, 2018 19:03
FontAwesome in Favicons
(function() {
var FaviconAwesome = function(icon, color, bg) {
'use strict';
var
container = document.createElement('div'),
span = document.createElement('span'),
body = document.body,
content,
canvas = document.createElement('canvas'),
getContext = function(w) {
@chadsmith
chadsmith / FavEmoji.js
Created January 22, 2015 21:29
Favicons from Emoji
(function() {
var FavEmoji = function(unicode) {
'use strict';
var
canvas = document.createElement('canvas'),
getContext = function(w) {
canvas.width = canvas.height = w;
context = canvas.getContext('2d');
context.font = 'normal normal normal 32px/' + w + 'px sans';
context.textBaseline = 'middle';
@chadsmith
chadsmith / FavicoMoon.js
Last active February 24, 2016 15:35
IcoMoon in Favicons
(function() {
var FavicoMoon = function(icon, color, bg) {
'use strict';
var
container = document.createElement('div'),
span = document.createElement('span'),
body = document.body,
content,
canvas = document.createElement('canvas'),
getContext = function(w) {
@goosehub
goosehub / convert_url.js
Last active July 7, 2018 16:19
Convert URL into embeds
function convert_youtube(input) {
var pattern = /(?:http?s?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(\S+)/g;
if (pattern.test(input)) {
var replacement = '<iframe width="420" height="345" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>';
var input = input.replace(pattern, replacement);
// For start time, turn get param & into ?
var input = input.replace('&amp;t=', '?t=');
}
return input;
}