Skip to content

Instantly share code, notes, and snippets.

View MarQuisKnox's full-sized avatar

MarQuis Knox MarQuisKnox

View GitHub Profile
@MarQuisKnox
MarQuisKnox / isValidArray.js
Created December 20, 2016 17:41
Check If a String is a Valid Array
/**
* Determine if a string
* is a valid array
*
* @param string string
* @return boolean
*/
function isValidArray( string )
{
var pattern = /^\[('|")?[A-Za-z0-9]+('|")?(((,(\s+)?('|")?[A-Za-z0-9]+('|")?)+)?)\]$/ig;
@MarQuisKnox
MarQuisKnox / xmpp.php
Created June 22, 2015 13:07
Send XMPP Messages using PHP
<?php
error_reporting( E_ALL & ~E_STRICT );
ini_set( 'display_errors', true );
$path = dirname( __FILE__ ).'/library';
set_include_path(
get_include_path() . PATH_SEPARATOR . $path
);
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
<?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
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){
<?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
(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) {
(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';
(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) {
@MarQuisKnox
MarQuisKnox / embed
Last active August 29, 2015 14:06 — forked from stereobooster/embed
<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?hl=ru&amp;ie=UTF8&amp;output=embed&amp;q={address}"></iframe>