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
| class Grid extends React.Component { | |
| renderCell(record, col) { | |
| return <td>{col.renderer(record[col.field], record)}</td> | |
| } | |
| renderRow(row) { | |
| return <tr className=...> | |
| {this.props.columns.map((col) => this.renderCell(d, col))} | |
| </tr> | |
| } |
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
| export default class SomeModule extends React.Component | |
| { | |
| addUser() | |
| { | |
| this.refs.win1.show(() => console.log('adding user', this.refs.form1.values)) | |
| } | |
| render() { | |
| return <Module> |
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
| // == actions.js == | |
| function showModal(id, cb) | |
| { | |
| return {type: 'SHOW_MODAL', id, cb: (ok) => { | |
| closeModal(id); // dispatch here? | |
| if(ok) cb(); | |
| }}; | |
| } |
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
| l1 = [-5, 1, 4, 8, 10, 3, 10, -9, -4, 0,-9, 10] | |
| l2 = [] | |
| for i in l1: | |
| if i <= 0: | |
| l2.append(i) | |
| elif i % 5 != 0: | |
| l2.append(i) | |
| print(l2) |
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
| in1 = [...] | |
| in2 = [...] | |
| out = [] | |
| while len(in1) and len(in2): | |
| if in1[0] > in2[0]: | |
| out.append(in1.pop(0)) | |
| else | |
| out.append(in2.pop(0)) |
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
Show hidden characters
| { | |
| "presets": ["es2015", "stage-0", "react"], | |
| "plugins": ["transform-decorators-legacy"], | |
| "env": { | |
| "development": { | |
| "presets": ["react-hmre"], | |
| } | |
| } | |
| } |
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
| var webpack = require('webpack'); | |
| module.exports = { | |
| entry: [ | |
| 'webpack-hot-middleware/client', | |
| './src/index.js' | |
| ], | |
| module: { | |
| loaders: [{ | |
| test: /\.jsx?$/, |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>flexbox test</title> | |
| <style> | |
| body { | |
| padding: 0; | |
| margin: 0; | |
| height: 100vh; | |
| display: flex; |
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 mysql from 'mysql'; | |
| export default class Db | |
| { | |
| this.conn = false; | |
| connect() | |
| { | |
| // fixme: db settings are hardcoded | |
| // fixme: no error handling here |
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
| // event emitter | |
| var waits = 0; | |
| var done = false; | |
| db.on('data', async data => { | |
| waits++; | |
| await processData(data); | |
| waits--; | |
| if(done) |
OlderNewer