Skip to content

Instantly share code, notes, and snippets.

View onurkerimov's full-sized avatar

Onur Kerimov onurkerimov

View GitHub Profile
@onurkerimov
onurkerimov / Math-alias.js
Last active October 9, 2018 11:34
A template for using the functions and variables in native Math object, without writing "Math." at the beginning, also "print" is the alias for "console.log"
(function(print, abs, acos, acosh, asin, asinh, atan, atanh,
atan2, ceil, cbrt, expm1, clz32, cos, cosh, exp, floor,
fround, hypot, imul, log, log1p, log2, log10, max, min,
pow, random, round, sign, sin, sinh, sqrt, tan, tanh,
trunc, E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2) {
// Function Body
})(console.log, Math["abs"], Math["acos"], Math["acosh"], Math["asin"],
Math["asinh"], Math["atan"], Math["atanh"], Math["atan2"], Math["ceil"],
@onurkerimov
onurkerimov / setInterval-wrapper.js
Last active October 9, 2018 11:58
A practical setInterval function wrapper that I oftenly use, in which the interval is cleared when the callback function returns true.
(function() {
$.setInterval = function(int, fn) {
var returnValue
var interval = setInterval(function() {
if (returnValue === true) {
clearInterval(interval);
} else {
returnValue = fn()
}
}, int)
@onurkerimov
onurkerimov / Beautiful_GUI_Fonts.css
Last active November 4, 2018 16:38
Note to self
html {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font: 400 16px/1.5 system-ui,-apple-system,BlinkMacSystemFont,"Helvetica Neue",Helvetica,Arial,sans-serif;
text-rendering: optimizeLegibility;
}
var cnv = $('canvas')[0];
var ctx = cnv.getContext('2d');
var ratio = window.devicePixelRatio
if (ratio) {
ratio *= 1.5;
var w = $(cnv).attr('width');
var h = $(cnv).attr('height');
window.addEventListener("mousemove", function(e) {
debounce(200, fn.bind(this,e))
});
var waitFlag = false
function debounce(time,fn) {
if (!waitFlag) {
fn()
waitFlag = true
@onurkerimov
onurkerimov / DA UI SublimeText Theme Settings
Created November 27, 2018 21:07
DA UI SublimeText Theme Settings
{
"accent_color": "#00bcab",
"background_color": "#394145",
"font_face": "Segoe UI",
"tab_font_size": ["subtract", "$font_size", 1],
"show_tab_dropdown_button": false,
"panel_border_width": [0, 0, 0, 0],
"scrollbar_flavor": "square",
"sidebar_heading_font_size": ["subtract", "$font_size", 2],
@onurkerimov
onurkerimov / simple-javascript-css-html-tokenizer.js
Created May 28, 2019 23:58
A simple javascript, css, html tokenizer/lexer. Taken from @lrsjng/lolight - Lightweight tokenizer and syntax highlighter. https://larsjung.de/lolight/
/**
* Code taken from @lrsjng/lolight - Lightweight tokenizer and syntax highlighter.
* https://larsjung.de/lolight/
*/
var KEYWORD_RE = /^(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing
@onurkerimov
onurkerimov / openFolderAsVSCodeProject.reg
Last active August 11, 2019 10:04
Open Folder as VSCode Project on contextmenu
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="Open Folder as &VS Code Project"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\REPLACE_THIS_WITH_YOUR_USERNAME\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="Open Folder as &VS Code Project"
const Tree = (props) => (
<ul>
{props.nodes.map((node, key) => (
<li key={key}>
<div className={'name'}>{node.name}</div>
{node.children && <Tree nodes={node.children} />}
</li>
))}
</ul>
);
@onurkerimov
onurkerimov / info.md
Last active March 4, 2024 01:41
Open idea: parser combinator API using regex

This is my take on building a parser combinator library API in JavaScript. This library would have a very low surface area, and would be easy to learn for those who already know already know regex.

Parser combinators often create their own DSL (domain-specific language) to provide a less verbose way of declaring parsers. These DSLs have to support operators for things such as repetition, alternation, optionality, lookahead, and more. Some of them don't create DSLs and provide these as helper functions.

In the following link, there are JSON parser implementations done by several parser combinatiors/generators: https://chevrotain.io/performance/ Some of them are verbose, some of them are concise.

This parser combinator API I'm proposing will not provide a DSL, however it will result in very short parser declarations.