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
/* uncompressed - 430 bytes | |
* minified (UglifyJS) - 273 bytes | |
* FYI - indented using tabs because one character vs 4, yo. | |
* Append ?ts = 4 to URL to format this correctly. | |
*/ | |
function p() { | |
var a, b, | |
m = Math, | |
r = m.random, |
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
'use strict'; | |
var os = require('os'); | |
var hasWrittenHeader = false; | |
var fileStream = require('fs').createWriteStream('cpuProfile.out'); | |
function buildResults() { | |
var output = ''; | |
var cpus = os.cpus(); | |
var cpu; |
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
#!/usr/bin/env sh | |
java -jar /usr/local/bin/closure-compiler.jar $@ |
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
'use strict'; | |
const fetch = require('node-fetch'); | |
const express = require('express'); | |
const router = express.Router(); | |
/* This function returns an inner function(i.e. a higher-order | |
* function) that will be invoked by Express when a particular | |
* path is request. This inner function will invoke the wrapped | |
* handler, and invoke Express' next function if the returned |
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
'use strict'; | |
class System { | |
constructor(name, next) { | |
this.name = name; | |
this.components = []; | |
this.next = next; | |
} | |
getOtherComponents(component) { |
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
'use strict'; | |
const getVectorSize = vector => Math.sqrt( | |
vector.map(n => Math.pow(n, 2)) | |
.reduce((total, n) => total + n, 0) | |
); | |
const addVectors = (a, b) => a.map((number, i) => number + b[i]); | |
const multiplyVectors = (a, b) => a.map((number, i) => number * b[i]); |
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
const MessageForm: React.FC<Props> = ({ submitMessage }) => { | |
const [message, setMessage] = React.useState(''); | |
return ( | |
<form onSubmit={e => { | |
e.preventDefault(); | |
submitMessage(message); | |
}}> | |
<input | |
type="text" |
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 MessageForm extends React.Component<Props, State> { | |
constructor(props: Props) { | |
super(props); | |
this.state = { | |
message: '', | |
}; | |
} | |
render() { |
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
const UserContext = React.createContext(maybe<User>()); | |
const App: React.FC<AppProps> = ({ user }) => ( | |
<UserContext.Provider value={maybe(user)}> | |
<Header /> | |
</UserContext.Provider> | |
); | |
const Header = () => ( | |
<> |
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
const App: React.FC<AppProps> = ({ user }) => ( | |
<Header user={maybe(user)} /> | |
); | |
const Header: React.FC<UserProps> = ({ user }) => ( | |
<> | |
<Logo user={user} /> | |
<Account user={user} /> | |
</> | |
); |
OlderNewer