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 / codemirror-0.js
Last active March 6, 2026 09:03
CodeMirror Hotkeys for Bold and Italic
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(),
@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active March 20, 2025 17:17
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');
@taufik-nurrohman
taufik-nurrohman / mecha.nginxconf
Last active January 15, 2025 03:52
Using Mecha under Nginx instead of Apache web server.
server {
listen 443 ssl;
root /path/to/www;
index index.php index.html;
server_name your-site-domain.tld;
@taufik-nurrohman
taufik-nurrohman / simplest-markdown-parser.php
Last active October 9, 2024 00:37
The Simplest PHP Markdown Parser
<?php
/*!
* =======================================================
* Author : Taufik Nurrohman
* URL : https://github.com/taufik-nurrohman
* License : MIT
* =======================================================
*
* -- CODE: ----------------------------------------------
@taufik-nurrohman
taufik-nurrohman / slugify.php
Created January 14, 2015 01:00
Slug URL Generator
<?php
function do_slug($text, $lower = true, $strip_underscores_and_dots = true, $connector = '-') {
$text_accents = array(
// Numeric characters
'¹' => 1,
'²' => 2,
'³' => 3,
// Latin
'°' => 0,
@taufik-nurrohman
taufik-nurrohman / extract-html-attributes.php
Created January 17, 2015 00:45
Regex to Extract HTML Attributes
<?php
/*! Based on <https://github.com/mecha-cms/cms/blob/master/system/kernel/converter.php> */
function extract_html_attributes($input) {
if( ! preg_match('#^(<)([a-z0-9\-._:]+)((\s)+(.*?))?((>)([\s\S]*?)((<)\/\2(>))|(\s)*\/?(>))$#im', $input, $matches)) return false;
$matches[5] = preg_replace('#(^|(\s)+)([a-z0-9\-]+)(=)(")(")#i', '$1$2$3$4$5<attr:value>$6', $matches[5]);
$results = array(
'element' => $matches[2],
'attributes' => null,
'content' => isset($matches[8]) && $matches[9] == '</' . $matches[2] . '>' ? $matches[8] : null
We couldn’t find that file to show.
@taufik-nurrohman
taufik-nurrohman / arch-linux-installation-on-mbr-system.md
Created May 2, 2023 12:06 — forked from xbns/arch-linux-installation-on-mbr-system.md
Arch Linux Installation Process for a Legacy/BIOS/MBR System #arch-linux

Arch Linux Installation Process for a Legacy/BIOS/MBR System

We will tackle this process in 10 steps listed below.

I didn't want to repeat some sections well explained in the UEFI Process. You can refer there and follow due process.

Namely;

  • Connecting to WiFi.
@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 / toko.mysql
Last active May 25, 2022 11:47
Dummy database.
-- Tabel Daftar Transaksi
CREATE TABLE "inventory" (
"product" INTEGER, -- `product.id`
"price" INTEGER, -- Harga satuan produk
"quantity" INTEGER,
"store" INTEGER, -- `store.id`
"time" TEXT, -- Waktu terjadi transaksi
"type" INTEGER, -- Tipe transaksi
"user" INTEGER
);