Skip to content

Instantly share code, notes, and snippets.

View scriptype's full-sized avatar
🍁

Mustafa Enes Ertarhanaci scriptype

🍁
View GitHub Profile
@scriptype
scriptype / CSSRule.js
Last active April 16, 2017 11:30
Parses a given CSS rule
(function(input) {
class CSSRule {
constructor(cssText) {
this.raw = cssText
this.parsed = CSSRule.parse(cssText)
return this
}
static parse(cssText) {
@scriptype
scriptype / dummy-template-engine.js
Created April 19, 2017 13:58
A very dummy template engine
(function() {
function engine(template, data) {
(template.match(/{\{(.+)\}\}/g) || []).forEach(variable => {
var pureVar = variable.replace(/(\{|\})/g, '')
var innerAccess = pureVar.split(/\./)
var finalValue = innerAccess.reduce((acc, curr) => acc[curr], data)
template = template.replace(variable, finalValue)
})
return template
@scriptype
scriptype / HTMLFragment.js
Last active April 22, 2017 15:22
Flawed HTML Parser
(function(input) {
class HTMLFragment {
constructor(htmlText) {
this.raw = htmlText
this.parsed = HTMLFragment.parse(removeWhitespace(htmlText))
return this
}
static parse(htmlText) {
@scriptype
scriptype / shades.js
Last active April 22, 2017 20:49
50 Shades of Grey
new Array(50)
.join(' ')
.split(' ')
.map((n, i) =>
('0' + (i * Math.floor(255 / 50)).toString(16))
.slice(-2)
.repeat(3)
)
@scriptype
scriptype / changed.sh
Last active September 16, 2024 08:02
check if there are any changes in the git repo
if [[ -z `git status | grep "git add <file>"` ]];
then
echo same;
else
echo changed;
fi
@scriptype
scriptype / cellular-automata-test.markdown
Last active May 23, 2017 01:07
Elementary Cellular Automata
@scriptype
scriptype / say-word.vim
Created May 24, 2017 04:07
Pronounce word under cursor in Vim
nnoremap <leader>s ms"syiw:r !say <C-r>s<CR>`s
@scriptype
scriptype / yank-word-to-s-register.vim
Created May 24, 2017 04:09
Yank a word to the s register
"syiw
@scriptype
scriptype / retrieve-from-s-register.vim
Last active May 24, 2017 05:35
Retrieve contents of s register
<C-r>s
@scriptype
scriptype / say-word-edited-after-feedbacks.vim
Last active May 25, 2017 02:11
Pronounce a word in Vim (Edited accordingly after feedbacks)
nnoremap <silent> <leader>s :<C-u>call system('say ' . expand('<cword>'))<CR>