Skip to content

Instantly share code, notes, and snippets.

View scriptype's full-sized avatar
🍁

Mustafa Enes Ertarhanaci scriptype

🍁
View GitHub Profile
@scriptype
scriptype / pronounce-words-with-espeak.vim
Created May 25, 2017 02:17
Pronounce words in Vim using `espeak` instead of `say`
nnoremap <silent> <leader>s :<C-u>call system('espeak ' . expand('<cword>'))<CR>
@scriptype
scriptype / genetic.js
Created February 22, 2018 22:03
Hello world example with genetic algorithm
(() => {
function nArray(n, mapperFn) {
return new Array(n).join(' ').split(' ').map(mapperFn)
}
function getRandomString(length) {
return nArray(length, e =>
String.fromCharCode(Math.round(Math.random() * 126))
).join('')
}
@scriptype
scriptype / index.html
Last active March 12, 2018 21:49
vREqpz
<canvas id="canvas"></canvas>
@scriptype
scriptype / renderCategories.js
Created March 20, 2018 13:46
Traverse deep categoryTree recursively
function rootTemplate(categories) {
return `
<div class="root-container">
${ getCategoryMarkup(categories) }
</div>
`
}
function itemsTemplate(items, level) {
return `
@scriptype
scriptype / example.js
Last active June 20, 2018 23:18
take(): Switch-case as an expression
/*
* It takes an expression and a handler object
* that consists of potential actual values of
* the given expression.
*
* The function calls either the
* matching method or the default defined in
* handler object (if defined).
*/
function take(expression, handler) {
@scriptype
scriptype / index.html
Created November 8, 2018 21:38
sin(round(random()))
<canvas id="canvas"></canvas>
@scriptype
scriptype / Rotate bitmap
Last active November 15, 2018 23:48
Rotate bitmap
var asset = {
bitmap: [
`A A A B B B`,
`A . . . . B`,
`A . 1 1 . B`,
`D . 2 2 . C`,
`D . . . . C`,
`D D D C C C`
].map(row => row.split(' ')),
size: 6
@scriptype
scriptype / gist:62a521c771293aefe89b3228ac98aa45
Last active January 31, 2019 09:42
Overlap bitmaps (WIP)
var colors = {
0: 'transparent',
1: 'white',
2: '#aaa'
}
var planetMap = [
[ 0, 0, 1, 9, 1 ],
[ 0, 0, 1, 8, 1 ],
[ 1, 1, 1, 7, 1 ],
navigator.requestMIDIAccess()
.then(onMIDISuccess, onMIDIFailure);
function onMIDIFailure() {
console.log('Could not access your MIDI devices.');
}
function onMIDISuccess(midiAccess) {
console.log(midiAccess);