Skip to content

Instantly share code, notes, and snippets.

View MarQuisKnox's full-sized avatar

MarQuis Knox MarQuisKnox

View GitHub Profile
@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;
}
@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) {
@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 / 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) {
@turret-io
turret-io / aes_enc_dec.php
Last active September 4, 2023 00:10
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
@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;
}
@iqbalhasnan
iqbalhasnan / index.html
Last active July 7, 2016 00:53
Bootstrap 3 + Salvattore - A jQuery Masonry/Isotope alternative with CSS-driven configuration. See it live here : http://codepen.io/tobsn/pen/EPdejY
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap 3 + Salvattore Example, A 'jQuery Masonry' alternative with CSS-driven configuration.</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="salvattore.css">
</head>
<body>
@k3karthic
k3karthic / truncate_dynamodb.sh
Last active July 12, 2022 18:56
Truncate all keys in a dynamodb table
#!/bin/bash
TABLE_NAME=$1
# Get id list
aws dynamodb scan --table-name $TABLE_NAME | grep ID | awk '{ print $2 }' > /tmp/truncate.list
# Delete from id list
cat /tmp/truncate.list | xargs -IID aws dynamodb delete-item --table-name $TABLE_NAME --key '{ "id": { "S": "ID" }}'
function public_encrypt($plaintext){
$fp=fopen("./mykey.pub","r");
$pub_key=fread($fp,8192);
fclose($fp);
openssl_get_publickey($pub_key);
openssl_public_encrypt($plaintext,$crypttext, $pub_key );
return(base64_encode($crypttext));
}
function private_decrypt($encryptedext){
@sgmurphy
sgmurphy / url_slug.php
Created July 12, 2012 15:52
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.