foobar, foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud
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
// see blog post: http://www.hiddentao.com/archives/2013/07/08/generate-overridable-getters-and-setters-in-javascript/ | |
Function.prototype.generateProperty = function(name, options) { | |
// internal member variable name | |
var privateName = '__' + name; | |
options = options || {}; | |
options.get = ('undefined' === typeof options.get ? true : options.get ); | |
options.set = ('undefined' === typeof options.set ? true : options.set ); | |
// pre-initialise the internal variable? |
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
/*! JavaScript Module Pattern by Taufik Nurrohman <https://github.com/tovic> */ | |
(function(win, doc, NS) { | |
(function($) { | |
// module version | |
$.version = '1.0.0'; | |
// collect all instance(s) |
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
editor.addKeyMap({ | |
// bold | |
'Ctrl-B': function(cm) { | |
var s = cm.getSelection(), | |
t = s.slice(0, 2) === '**' && s.slice(-2) === '**'; | |
cm.replaceSelection(t ? s.slice(2, -2) : '**' + s + '**', 'around'); | |
}, | |
// italic | |
'Ctrl-I': function(cm) { | |
var s = cm.getSelection(), |
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
// Reply for <https://medium.com/@Dewey92/cleaner-code-dengan-function-composition-137f30d928e4> | |
function compose() { | |
var i, arg = arguments, | |
output = arg.pop(); | |
for (i = 0; i < arg.length; ++i) { | |
if (typeof arg[i] !== "function") continue; | |
output = arg[i](output); | |
} | |
return output; |
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
/* | |
A full list of simple easing equations inspired by GIST from greweb - https://gist.github.com/gre/1650294 | |
Equations source - http://gsgd.co.uk/sandbox/jquery/easing/ | |
*/ | |
{ | |
linear: function(t) { | |
return t | |
}, | |
inQuad: function(t) { |
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 code is based on <https://github.com/pourquoi/ckeditor5-simple-upload> | |
* and will be implemented by <https://github.com/mecha-cms/extend.c-k-editor> in the future! | |
*/ | |
// The upload adapter | |
var Adapter = function(loader, urlOrObject, t) { | |
var $ = this; |
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
<?php | |
if (!isset($_GET['r'])) { | |
echo '<p style="color:red;">Missing `r` parameter.</p>'; | |
exit; | |
} | |
// <https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app> | |
$user = '03d2df6cd302*******'; // client ID |
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 magicMethods (clazz) { | |
// A toggle switch for the __isset method | |
// Needed to control "prop in instance" inside of getters | |
let issetEnabled = true | |
const classHandler = Object.create(null) | |
// Trap for class instantiation | |
classHandler.construct = (target, args) => { | |
// Wrapped class instance |