Skip to content

Instantly share code, notes, and snippets.

😒
Nothing. Just me.

Taufik Nurrohman tovic

View GitHub Profile
@tovic
tovic / git.php
Last active Dec 29, 2018
GitHub Repository Browser API
View git.php
<?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
@tovic
tovic / ckeditor5-image-upload.js
Last active Mar 14, 2019
Enable image upload in CKEditor 5 without using the Easy Image service.
View ckeditor5-image-upload.js
/**
* 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;
@tovic
tovic / easings.js
Created Apr 28, 2018 — forked from rezoner/easings.js
One argument easing equations
View easings.js
/*
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) {
@tovic
tovic / compose-function.js
Last active Mar 27, 2017
Compose Function
View compose-function.js
// 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;
@tovic
tovic / foobar.md
Created Jan 16, 2017 — forked from t32k/foobar.md
foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud
View foobar.md
@tovic
tovic / codemirror-0.js
Last active Feb 15, 2018
CodeMirror Hotkeys for Bold and Italic
View codemirror-0.js
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(),
@tovic
tovic / module-pattern.js
Last active May 12, 2017
JavaScript Module Pattern
View module-pattern.js
/*! 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)
@tovic
tovic / gist:04c1b879f7423027615c4f45e2f716df
Created Sep 4, 2016 — forked from hiddentao/gist:5946053
Generate overridable getters and setters in Javascript
View gist:04c1b879f7423027615c4f45e2f716df
// 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?
@tovic
tovic / keyboard-event._key.js
Last active Sep 1, 2016
Just another polyfill for that `KeyboardEvent.key` property (lower-cased)
View keyboard-event._key.js
(function() {
// Key maps for the deprecated `KeyboardEvent.keyCode`
var keys = {
// control
8: 'backspace',
9: 'tab',
13: 'enter',
16: 'shift',
17: 'control',
@tovic
tovic / simplest-markdown-parser.php
Last active Aug 2, 2017
The Simplest PHP Markdown Parser
View simplest-markdown-parser.php
<?php
/*!
* =======================================================
* Author : Taufik Nurrohman
* URL : https://github.com/tovic
* License : MIT
* =======================================================
*
* -- CODE: ----------------------------------------------
You can’t perform that action at this time.