Skip to content

Instantly share code, notes, and snippets.

View scriptype's full-sized avatar
🍁

Mustafa Enes Ertarhanaci scriptype

🍁
View GitHub Profile
@scriptype
scriptype / index.html
Created December 21, 2016 14:48
.map().join() vs .reduce() (http://jsbench.github.io/#a80c1e0e7282af6742adbbea4dfdf50a) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>.map().join() vs .reduce()</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@scriptype
scriptype / index.html
Created December 21, 2016 16:41
.map().join() vs .reduce() (http://jsbench.github.io/#0041b8df43a03dc10a2e82173b3dc6c1) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>.map().join() vs .reduce()</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@scriptype
scriptype / index.js
Last active December 31, 2016 18:05
Toplist-as-a-db
var form = new FormData()
var unique = crypto.getRandomValues(new Int32Array(3)).join('-')
form.set('modulenter[titel]', 'db-entry 5')
form.set('modulenter[url]', `http://${unique}.com`)
form.set('modulenter[name]', 'dba')
form.set('modulenter[email]', '[email protected]')
form.set('email', 'ZmxhYQD3BQtfYwD4ZvjlYwLkYQZ4YwDfZGRkYvjmBQD2')
form.set('mode', 'addlink')
form.set('modulenter[text]', JSON.stringify({
nick: "scriptype",
@scriptype
scriptype / index.js
Created December 31, 2016 18:05
Get data from Toplist-as-a-db
fetch('/list.htm')
.then(response => response.text())
.then(html => {
var dom = document.createElement('div')
dom.innerHTML = html
var content = dom.querySelector('#content')
var table = content.querySelector('table tbody')
var list = Array.from(table.querySelectorAll('tr')).slice(1)
var entries = list.map(entry => {
var cell = entry.querySelector('td:nth-child(2)')
@scriptype
scriptype / index.js
Created December 31, 2016 22:47
Toplist-as-a-counter
window.onbeforeunload = e => {
postList(url, {
nick: "onbeforeunload yes",
message: "success ok " + Date.now()
}).then(() => {
console.log('posted √')
}).catch(e => {
console.log('couldnt post', e)
})
}
@scriptype
scriptype / index.html
Created January 30, 2017 11:17
dynamic property assignment new vs old way (http://jsbench.github.io/#5f64c399dca1faff56f705e7efd46e7f) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>dynamic property assignment new vs old way</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@scriptype
scriptype / callback-heaven.js
Created February 3, 2017 20:16
Callback heaven
function create(callback) {
setTimeout(function() {
callback('created')
}, Math.random() * 1000)
}
function read(value, callback) {
setTimeout(function() {
callback(value + ', red')
}, Math.random() * 1000)
@scriptype
scriptype / index.html
Created February 26, 2017 21:05
MpYKVq
<div class="game">
<h1 class="game__title">Satisfy the inputs</h1>
<div class="game__screen" id="game-screen"></div>
<div class="game__hud">
<div class="game__lives" id="game-lives"></div>
<div class="game__score" id="game-score"></div>
</div>
</div>
@scriptype
scriptype / useof.sh
Last active March 20, 2017 12:38
Find usage of a word in the project
function useof {
if [[ -n $1 ]]
then
if [[ -n $2 ]]
then
local dir=$2;
else
local dir=".";
fi
grep --recursive --include="*.js" $1 $dir | awk '{ print $1 }' | cut -d':' -f1 | uniq;
@scriptype
scriptype / importof.sh
Last active March 23, 2017 20:52
Find module names where the given term is being `import`ed
# Needs useof.sh to work (https://gist.github.com/scriptype/96c2cb131ddfc9080128a52d5e633c58)
function importof {
if [[ -n $1 ]]
then
if [[ -n $2 ]]
then
local dir=$2;
else
local dir=".";