This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
function exec(script){ | |
return eval(transpile(new DOMParser().parseFromString(, "text/html").documentElement)); | |
} | |
function run(){ | |
return Array.from(document.querySelectorAll('')).forEach(function(script){ | |
exec(script); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The until version of doWhileLoop. | |
*/ | |
function untilLoop(condition, body){ | |
if(!condition()){ | |
body(); | |
return untilLoop(condition,body); | |
}else{ | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This gist plays around with a subset of ECMAScript6 (ES2015) that only uses expressions (except for the 'Program' const declaration). | |
/* Some rules: | |
* Arrow functions that evaluate an expression are the only kinds of functions allowed. | |
* All variables are declared as function parameters. | |
* If you want to scope variables, use the following format of an arrow function in parentheses: | |
((variables,to,declare,in,function,scope)=>(expressions,within,which,you,will,use,said,variables))() | |
* No return statement - the last expression in a list of expressions is what is returned. | |
* No Generators :( Or async/await :( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Graph { | |
adjList = new Map() | |
constructor(iterable, directed = true){ | |
for(let node of iterable){ | |
this.adjList.set(node, new Map()); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Template string as function. | |
* | |
* Pros: Only has access to parameters. | |
* Cons: Have to make a module. | |
*/ | |
import {template} from './template-string-as-function.js'; | |
let page = template({ | |
title: "10 Wierd Template String Tricks", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function transpile(token){ | |
switch(token.type){ | |
case "Literal": | |
switch(typeof token.value){ | |
case "string": | |
return `"${token.value}"`; | |
case "boolean": | |
return `${token.value ? "true" : "false"}`; | |
case "null": | |
return "nothing"; |
Generated using http://github.com/rbuckton/grammarkdown
SourceCharacter ::
any Unicode code point
InputElementDiv ::
WhiteSpace
LineTerminator
Comment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="./styles.css"> | |
</head> | |
<body> | |
<div id="map">Hello World!</div> | |
</body> | |
</html> |
I hereby claim:
- I am thomasfoster96 on github.
- I am thomasfoster96 (https://keybase.io/thomasfoster96) on keybase.
- I have a public key ASDCAbD60YhJmYb8J9dRvtrYNFA_qnfxOv5nmjaKtgakZwo
To claim this, I am signing this object:
OlderNewer