Skip to content

Instantly share code, notes, and snippets.

View v1vendi's full-sized avatar

Ilya Komsa v1vendi

View GitHub Profile
@v1vendi
v1vendi / button.js
Created September 5, 2019 17:19
Idea of React components composition
// i use bootstrap CSS classes for example
// class extension way:
const Button = ({ onClick, children, className }) => (
<button
class={`btn ${className}`.trim()}
onClick={onClick}
>
{children}
</button>
)
@v1vendi
v1vendi / api_generator.js
Created August 20, 2019 19:19
REST API functional generator
const fetch = (...args) => console.log(...args) // mock
function httpRequest(url, method, data) {
const init = { method }
switch (method) {
case 'GET':
if (data) url = `${url}?${new URLSearchParams(data)}`
break
case 'POST':
case 'PUT':
case 'PATCH':
@v1vendi
v1vendi / index.html
Last active October 21, 2018 21:27
React components for a page that does http request itself without redux
<title>Parcel demo</title>
<!-- <link rel=stylesheet href=./style.css /> -->
<style>
body {
max-width: 500px;
margin: auto;
}
#modal_holder:empty {
display: none;
}
@v1vendi
v1vendi / gist:da0a9f94a5564540b3aed38ad2798ad8
Last active August 20, 2019 19:32
How to update Node on Windows
Download new binary from nodejs.org
@v1vendi
v1vendi / gist:96c98641d2f36c09ed094c56aba4857d
Created November 3, 2017 12:52
Extract tar.bz2 to psql
tar -xOf FILE.tar.bz2 | psql -h HOST -U USER -d DATABASE
@v1vendi
v1vendi / template.js
Last active June 28, 2016 21:53
A tiny js template engine using Template Strings and template tag (manually minified is 432 bytes long without gzip)
function compileTemplate(templateElement, data){
//hack to get unencoded symbols from HTML node
var textarea = document.createElement('textarea');
textarea.innerHTML = templateElement.innerHTML;
var text = eval("with(data){html`" + textarea.value + "`}");
var tmpElement = document.createElement('div');
tmpElement.innerHTML = text;