Skip to content

Instantly share code, notes, and snippets.

View taufik-nurrohman's full-sized avatar
🍁
I ❤ U

Taufik Nurrohman taufik-nurrohman

🍁
I ❤ U
View GitHub Profile
@taufik-nurrohman
taufik-nurrohman / lexer.js
Created October 11, 2020 14:28 — forked from pepasflo/lexer.js
A regex-based javascript lexer / scanner / tokenizer
#!/usr/bin/env node
var assert = require('assert');
// Each lexed token is a array of three integers:
// 1. the "token type": an index into the list of token patterns.
// 2. the index into the input string marking the start of this token.
// 3. the length of the token.
// The list of "token types" which our lexer understands:
@taufik-nurrohman
taufik-nurrohman / mecha.nginxconf
Last active April 23, 2022 16:01
Using Mecha under Nginx instead of Apache web server.
server {
listen 443 ssl;
root /path/to/www;
index index.php index.html;
server_name mecha-cms.com;
@taufik-nurrohman
taufik-nurrohman / liquid-template-list-sentence-from-array.liquid
Created July 7, 2019 15:57
Generate text “foo, bar, baz and qux” from array input in Liquid by https://github.com/mecha-cms
{% assign total_items = items.size %}
{% for item in items %}
{% if forloop.index > 1 %}
{% if forloop.index != total_items %}, {% else %} and {% endif %}
{% endif %}
{{ item }}
{% endfor %}
<style>
div {
width: 200px;
height: 200px;
background: lime;
border-radius: 100%;
position: relative;
}
span {
position: absolute;
<style>
nav {
position: relative;
background: orange;
color: black;
}
nav ul,
nav li {
margin: 0;
padding: 0;
@taufik-nurrohman
taufik-nurrohman / magic-methods.js
Created May 6, 2019 10:37 — forked from loilo/magic-methods.js
PHP Magic Methods in JavaScript
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
@taufik-nurrohman
taufik-nurrohman / git.php
Last active December 29, 2018 04:30
GitHub Repository Browser API
<?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
@taufik-nurrohman
taufik-nurrohman / ckeditor5-image-upload.js
Last active February 6, 2023 17:04
Enable image upload in CKEditor 5 without using the Easy Image service.
/**
* 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;
@taufik-nurrohman
taufik-nurrohman / easings.js
Created April 28, 2018 12:37 — forked from rezoner/easings.js
One argument easing equations
/*
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) {
@taufik-nurrohman
taufik-nurrohman / compose-function.js
Last active March 27, 2017 04:17
Compose Function
// 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;