Skip to content

Instantly share code, notes, and snippets.

View farishan's full-sized avatar

Faris Han farishan

View GitHub Profile
@farishan
farishan / saloimex.js
Created June 24, 2021 15:18
Saloimex
/*
* Saloimex
* Faris Han, 2020
*/
class Saloimex {
/**
* Saloimex
* @constructor
*/
constructor(key) {
@farishan
farishan / join-strings.js
Last active September 11, 2021 09:01
Array of strings to a sentence
// Credits: Svelte (from Svelte's Tutorial)
function join(strings) {
if (strings.length === 1) return strings[0];
return `${strings.slice(0, -1).join(', ')} and ${strings[strings.length - 1]}`;
}
@farishan
farishan / tailwind.config.js
Last active October 5, 2021 12:38
farishan tailwind custom breakpoints | farishan tailwind custom container plugin
/**
* Custom Breakpoints
*/
const screens = {
sm: '375px',
md: '768px',
mdp: '900px',
lg: '1024px',
xl: '1280px',
'2xl': '1440px',
// [JS - serialize form]
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;
}
define(() => {
function objectToTable(object = {}, header = {}, orientation = 'landscape') {
const $table = document.createElement('table')
let $thead
if (orientation === 'landscape') {
$thead = document.createElement('thead')
$table.appendChild($thead)
}
@farishan
farishan / terminal.js
Created September 6, 2022 16:43
Fake terminal for my future text-based RPG game
define(function () {
function Terminal($root, options = {}) {
if (!document) {
console.error("Cannot find HTML document.")
return
}
this.$root = $root || document.body
this.debug = options.debug || false
this.nodeMap = {
@farishan
farishan / pubsub.js
Created September 6, 2022 16:48
Basic pubsub pattern
/* AMD Module for RequireJS */
define(function () {
function PubSub() {
const self = this
let subscriberCount = 0
this.eventMap = {}
this.subscribe = function (key, callback) {
const token = `${generateUID()}_${++subscriberCount}`
const fs = require('fs')
/* Configuration */
const INPUT_PATH = './disciplines.txt'
const OUTPUT_PATH = './disciplines.json'
const ENCODING = 'utf-8'
const MINIFIED = false
const SPACE = 2
const REPLACER = undefined
const fs = require('fs')
/* Configuration */
const INPUT_PATH = './disciplines.txt'
const OUTPUT_PATH = './disciplines.mermaid.txt'
const ENCODING = 'utf-8'
const MINIFIED = false
const SPACE = 2
const REPLACER = undefined
@farishan
farishan / disciplines.txt
Last active February 13, 2023 12:05
A list of unique knowledge branches, sorted alphabetically, separated with comma. | Convert to JSON with this script: https://gist.github.com/farishan/6ac3cc654a9b58af71ac49de64e9f18a | Convert to https://mermaid.live/ with this script: https://gist.github.com/farishan/cffb456e8b7365442ec0ab11f45e8bc7
Aerospace Engineering,Aesthetics,Agricultural Science,Algebra,Anatomy,Anthropology,Archeology,Architectural Engineering,Architecture,Art History,Astronomy,Astrophysics,Biochemistry,Bioinformatics,Biology,Biomedical Engineering,Biotechnology,Botany,Business,Business Administration,Calculus,Cancer Biology,Cell Biology,Ceramics,Chemical Engineering,Chemistry,Civics,Civil Engineering,Classical Studies,Climate Science,Cognitive Science,Commerce,Commercial Law,Communication Studies,Comparative Literature,Comparative Religion,Computer Science,Creative Writing,Criminology,Cultural Studies,Dance,Dental Science,Development Studies,Earth Science,Ecology,Econometrics,Economics,Education,Education Studies,Electrical Engineering,Electronic Engineering,Emergency Medicine,Energy Engineering,Engineering,English Literature,Environmental Economics,Environmental Engineering,Environmental Science,Ethics,Fashion Design,Film Studies,Finance,Gender Studies,Genetics,Geography,Geology,Geometry,Gerontology,Global Studies,Graphic Design