Skip to content

Instantly share code, notes, and snippets.

View iofjuupasli's full-sized avatar

Valery iofjuupasli

  • fugo.ai
  • Warsaw, Poland
  • 09:58 (UTC +01:00)
View GitHub Profile
@iofjuupasli
iofjuupasli / oEmbed.js
Created October 29, 2019 12:46
Simplest oEmbed iframe implementation
const express = require(`express`);
const router = express.Router();
router.get(`/oembed`, (req, res) => {
const {url, maxwidth, maxheight, format} = req.query;
const width = maxwidth || 1000;
const height = maxheight || 600;
const embedUrl = url; // you can transform url that user provided to url that should be displayed in iframe
const responseData = {
a b
1 2
2
@iofjuupasli
iofjuupasli / rr.csv
Last active June 17, 2019 15:19
rr.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
a
0.00001
123.123123
0.10001
0.00011
0.1111111
323.0001
4
5422
@iofjuupasli
iofjuupasli / convert.js
Last active September 22, 2017 15:23
Lodash fp autocurry
const readline = require(`readline`);
const fs = require(`fs`);
const rl = readline.createInterface({
input: fs.createReadStream(`./to_parse_v4.x.x.js`),
});
const getArgs = /((\(\([^\)]*\)[^\)]*\))|[\w?]|(: )|(\<[^\>]*\>)|(\([^\)]*\))|( => )|( \| )|(\{[^\}]*\})|(\[[^\]]*\])|[\<\>]|( \& ))+/g;
const split = (line) => {
myData.map(fixName);
function fixName(person) {
return Object.assign({}, person, {
name: person.name.replace(/John/g, "Ben")
});
}
// inline function
myData.map(function fixName(person) {
// All children from new line
// bad
h('.my-class', null, h('span', null, 'Foo'));
// good
h('.my-class', null,
h('span', null,
'Foo'
)
);
return <div>
<header className="header">
<h1>todos</h1>
<input
className="new-todo"
placeholder="What needs to be done?"
value={this.state.newTodo}
onKeyDown={this.handleNewTodoKeyDown(todo)}
onChange={this.handleChange(e)}
autoFocus=true
// A
<li className={classNames({
completed: this.props.todo.completed,
editing: this.props.editing
})}>
// B
<input
className="toggle"
type="checkbox"
return h('li', {
className: classNames({
completed: this.props.todo.completed,
editing: this.props.editing
})
},
h('div.view', null,
h('input.toggle', {
type: 'checkbox',
checked: this.props.todo.completed,
return (
<li className={classNames({
completed: this.props.todo.completed,
editing: this.props.editing
})}>
<div className="view">
<input
className="toggle"
type="checkbox"
checked={this.props.todo.completed}