This file contains hidden or 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
# fibonacci sequence, memoized | |
def memoize(func, arg): | |
if func not in memoize.__dict__: | |
memoize.__dict__[func] = {} | |
if arg not in memoize.__dict__[func]: | |
memoize.__dict__[func][arg] = func(arg) | |
return memoize.__dict__[func][arg] |
This file contains hidden or 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
//TODO: const | |
//NOTE: No variable hoisting! | |
// oneline comment | |
/* multiline comment */ | |
import "standard"; //imports built-in libraries, or .toy files | |
import "external.toy"; | |
print("hello world\n"); //print is a keyword, rather than a function - useful for debugging |
This file contains hidden or 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
(C) Kayne Ruse, KR Game Studios 2018 | |
Qty; Card Name; Cost; Points; Card Type; Card Effect; | |
20 Raw Coal 0 1 coal resource ; | |
20 Raw Oil 0 1 oil resource ; | |
20 Raw Gas 0 1 gas resource ; | |
20 Coal 3 2 coal resource ; | |
20 Oil 3 2 oil resource ; | |
20 Gas 3 2 gas resource ; |
This file contains hidden or 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class PlayerCharacterController : MonoBehaviour { | |
//internal components | |
Rigidbody2D rigidBody; | |
BoxCollider2D boxCollider; | |
//constants |
This file contains hidden or 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
render() { | |
return ( | |
<div> | |
{Object.keys(this.state.data).map((key, index) => <div key={key}><ReactMarkdown source={this.state.data[key]} escapeHTML={false} /><hr /></div> )} | |
</div> | |
); | |
} |
This file contains hidden or 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
import React from 'react'; | |
class ProgressiveRainbowText extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
colors: props.colors || ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'indigo'], | |
counter: 0, | |
unsubscribeKey: setInterval(() => this.setState({ counter: this.state.counter + 1}), 1000) |
This file contains hidden or 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
#new ladder expression | |
SELECT | |
username, | |
recruits, | |
soldiers, | |
gold, | |
(recruits + soldiers + scientists + spies) AS unitTotal, | |
(SELECT COUNT(*) FROM pastCombat WHERE (attackerId = accounts.id AND victor = 'attacker') OR (defenderId = accounts.id AND victor = 'defender')) AS successfulCombats, | |
( | |
(recruits + soldiers + scientists + spies) + |
This file contains hidden or 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
//save data sequentially | |
let counter = 0; | |
let fpath = path.join(__dirname, 'sampledata'); | |
fs.writeFileSync(path.resolve(fpath, `${counter}.json`), 'utf8'); | |
//get the filenames for concatenation as array | |
let filenames = fs.readdirSync(fpath); | |
filenames.forEach(fname => { | |
//concatenate the files | |
}); |
This file contains hidden or 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
if (this.state.tagline === 'marquee-loop') { | |
let triangleUpStyle = { | |
flex: '0 1 auto', | |
borderRight: '5px solid', | |
borderBottom: '5px solid', | |
width: '10px', | |
height: '10px', | |
marginLeft: '5px', | |
marginRight: '5px' | |
}; |
This file contains hidden or 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
//how to call the hitstun animation | |
StartCoroutine(TriggerHit(0.8f)); //0.8 seconds of invulnerability | |
IEnumerator TriggerHit(float delay) { | |
invulnerable = true; //allow for a window of time to get away | |
StartCoroutine(TriggerHitGraphic(0.1f, delay - 0.1f)); | |
yield return new WaitForSeconds(delay); | |
invulnerable = false; | |
} |