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 express = require('express'); | |
const session = require('express-session'); | |
const app = express(); | |
app.use(session({ | |
secret: 'mySecretCookieSalt', | |
key: 'myCookieSessionId', | |
cookie: { | |
httpOnly: true, |
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 express = require('express'); | |
const db = require('our-db-of-choice'); | |
const app = express(); | |
app.put('/profile/update', function(req, res, next){ | |
if(!req.session || !req.session.userId) { | |
return res.status(403).send({ok: false}); | |
} |
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 SayHi extends Component { | |
showHiMessage = this.showMessage('Hi') | |
render () { | |
return () { | |
<Button onClick={this.showHiMessage}> | |
Click Me | |
</Button> | |
} |
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 SayHi extends Component { | |
render () { | |
return () { | |
<Button onClick={(e) => console.log('Say Hi', e)}> | |
Click Me | |
</Button> | |
} | |
} | |
} |
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
{ | |
(() => { | |
if (this.props.status === 'PENDING') { | |
return (<div className="loading" />); | |
} | |
else { | |
return (<div className="container" />); | |
})() |
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() { | |
// Do something | |
} | |
)() |
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
// before transformation | |
<If condition={ test }> | |
<span>Truth</span> | |
</If> | |
// after transformation | |
{ test ? <span>Truth</span> : null } |
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
int median(int a, int b, int c) { | |
return (a<b) ? (b<c) ? b : (a<c) ? c : a : (a<c) ? a : (b<c) ? c : b; | |
} |
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
render() { | |
const isLoggedIn = this.state.isLoggedIn; | |
return ( | |
<div> | |
The user is <b>{isLoggedIn ? 'currently' : 'not'}</b> logged in. | |
</div> | |
); | |
} |
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
<style> | |
.hash234dd2 { | |
background-color: black; | |
color: white; | |
} | |
</style> | |
<p class="hash234dd3">This is CSS-in-JS</p> |