This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Handlebars.js - Gravatar thumbnail | |
// Usage: {{#gravatar email size="64"}}{{/gravatar}} | |
// Thanks: @tracend | |
import crypto from 'crypto'; | |
import Handlebars from 'handlebars/runtime'; | |
Handlebars.registerHelper('gravatar', (context, options) => { | |
const email = context; | |
const size = (typeof (options.hash.size) === 'undefined') ? 32 : options.hash.size; | |
const hash = crypto.createHash('md5').update(email).digest('hex'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function serialize(form) { | |
if (!form || form.nodeName !== "FORM") { | |
return; | |
} | |
var i, j, q = []; | |
for (i = form.elements.length - 1; i >= 0; i = i - 1) { | |
if (form.elements[i].name === "") { | |
continue; | |
} | |
switch (form.elements[i].nodeName) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO']) { | |
$_SERVER['HTTPS'] = 'on'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is a maint function to recover/reorder the | |
* lft/rght columns of the aco and aro models. | |
* | |
*/ | |
public function recover_acl_tree( ) { | |
App::Import('Model', 'Aco' ); | |
App::Import('Model', 'Aro' ); | |
$Aco = new Aco; | |
$Aro = new Aro; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string.replace(/<br\s*?(\/?)>/gm, '\r\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="emojiReplaceDemo"></div> | |
<script type="text/javascript"> | |
(function($) { | |
$(document).ready(function() { | |
var content = searchEmojis("🙊", function(match) { | |
return '<img class="emojioneemoji" src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/png/'+ uni2utf32(match) +'.png" alt="'+ match +'" />'; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const execSync = require('child_process').execSync; | |
const fs = require('fs'); | |
function run(command) { | |
return execSync(command).toString().trim(); | |
} | |
console.log("Reading 'versions' file..."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$xml = simplexml_load_string($xml_string); | |
$json = json_encode($xml); | |
$array = json_decode($json,TRUE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
top -o cpu | grep --line-buffered "CPU usage:" | cut -d' ' -f3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add suspport assign method (> IE9) | |
* https://gist.github.com/icetee/fae755b7ce8f90d9d7bc8a7ece2cf3cb | |
*/ | |
if (!Object.assign && Object.hasOwnProperty('defineProperty')) { | |
Object.defineProperty(Object, 'assign', { | |
enumerable: false, | |
configurable: true, | |
writable: true, | |
value: function(target) { | |
'use strict'; |