Skip to content

Instantly share code, notes, and snippets.

View kvasdopil's full-sized avatar

Alexey Guskov kvasdopil

  • Ombori
  • Stockholm, Sweden
View GitHub Profile
@kvasdopil
kvasdopil / Grid.js
Last active November 13, 2015 12:49
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>
}
export default class SomeModule extends React.Component
{
addUser()
{
this.refs.win1.show(() => console.log('adding user', this.refs.form1.values))
}
render() {
return <Module>
// == actions.js ==
function showModal(id, cb)
{
return {type: 'SHOW_MODAL', id, cb: (ok) => {
closeModal(id); // dispatch here?
if(ok) cb();
}};
}
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)
@kvasdopil
kvasdopil / 2arr.py
Last active December 18, 2015 11:42
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))
{
"presets": ["es2015", "stage-0", "react"],
"plugins": ["transform-decorators-legacy"],
"env": {
"development": {
"presets": ["react-hmre"],
}
}
}
var webpack = require('webpack');
module.exports = {
entry: [
'webpack-hot-middleware/client',
'./src/index.js'
],
module: {
loaders: [{
test: /\.jsx?$/,
<!DOCTYPE html>
<html>
<head>
<title>flexbox test</title>
<style>
body {
padding: 0;
margin: 0;
height: 100vh;
display: flex;
@kvasdopil
kvasdopil / db.js
Last active November 1, 2016 15:29
import mysql from 'mysql';
export default class Db
{
this.conn = false;
connect()
{
// fixme: db settings are hardcoded
// fixme: no error handling here
@kvasdopil
kvasdopil / db.js
Last active February 7, 2017 13:55
// event emitter
var waits = 0;
var done = false;
db.on('data', async data => {
waits++;
await processData(data);
waits--;
if(done)