Skip to content

Instantly share code, notes, and snippets.

View blizzerand's full-sized avatar
👨‍💻
Inventing

Manjunath blizzerand

👨‍💻
Inventing
View GitHub Profile
@blizzerand
blizzerand / app.js
Created November 8, 2018 10:06
Session and Cookies
const express = require('express');
const session = require('express-session');
const app = express();
app.use(session({
secret: 'mySecretCookieSalt',
key: 'myCookieSessionId',
cookie: {
httpOnly: true,
@blizzerand
blizzerand / app.js
Created November 8, 2018 09:04
Security issues
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});
}
class SayHi extends Component {
showHiMessage = this.showMessage('Hi')
render () {
return () {
<Button onClick={this.showHiMessage}>
Click Me
</Button>
}
class SayHi extends Component {
render () {
return () {
<Button onClick={(e) => console.log('Say Hi', e)}>
Click Me
</Button>
}
}
}
{
(() => {
if (this.props.status === 'PENDING') {
return (<div className="loading" />);
}
else {
return (<div className="container" />);
})()
(function() {
// Do something​
}
)()
// before transformation
<If condition={ test }>
<span>Truth</span>
</If>
// after transformation
{ test ? <span>Truth</span> : null }
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;
}
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
<div>
The user is <b>{isLoggedIn ? 'currently' : 'not'}</b> logged in.
</div>
);
}
<style>
.hash234dd2 {
background-color: black;
color: white;
}
</style>
<p class="hash234dd3">This is CSS-in-JS</p>