Skip to content

Instantly share code, notes, and snippets.

View frontsideair's full-sized avatar

Fatih Altinok frontsideair

View GitHub Profile
@frontsideair
frontsideair / paginated-selection.jsx
Last active January 4, 2016 19:51
Paginated selection table with custom select handler
'use strict';
import React from 'react';
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
var products = [];
function addProducts(quantity) {
var startId = products.length;
for (var i = 0; i < quantity; i++) {
const Case = cases => (
pred => (
(typeof cases[pred] !== 'undefined') ? cases[pred]() : cases['_']()
)
)
const count = Case({
0: () => 'zero',
1: () => 'one',
_: () => 'many'
@frontsideair
frontsideair / index.html
Last active February 7, 2017 07:24
Some ideas to make React component state management look more like redux
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- test here: https://esnextb.in/?gist=fa2b7e6775c242a76489c0ebc329ba7f -->
</head>
<body>
<div id="app"></div>
</body>
@frontsideair
frontsideair / cycle-with-reducers.js
Created July 7, 2016 19:37
Cycle.js with reducer-like events
const Cycle = require('@cycle/core');
const {makeDOMDriver, div, button} = require('@cycle/dom');
const {Observable} = require('rx');
function intent({ DOM }) {
const incr$ = DOM
.select('.incr')
.events('click')
.map(() => prev => prev + 1);
@frontsideair
frontsideair / index.html
Last active February 7, 2017 07:23
RR4 isolated test case
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- test here: https://esnextb.in/?gist=7cba0a35afc77d49ebb2bf5b99e944f1 -->
</head>
<body>
<div id="app"></div>
</body>
@frontsideair
frontsideair / copy-no-flash-test.md
Last active February 7, 2017 07:21
Test case for copying test with native APIs. (Works on latest Chrome, Firefox, Safari.)

Test case for copying test with native APIs. (Works on latest Chrome, Firefox, Safari.)

made with esnextbin

@frontsideair
frontsideair / comma-operator-push-pop.js
Created January 3, 2017 10:47
Simple implementation of push/pop with comma operator, function scope
const pop = (arr, tmp) => (tmp = arr.slice(0), tmp.pop(), tmp)
const push = (arr, item, tmp) => (tmp = arr.slice(0), tmp.push(item), tmp)
// Can you see why and how this works? Does it really? Can you guess if it's pure or impure?
// Does it modify any of its arguments, or pollute global scope?
@frontsideair
frontsideair / objects_and_closures.js
Created March 2, 2017 07:51
Objects and closures are (in some ways) the same thing! (Illustrated in ES6)
const obj = { foo: 'bar', baz: 'quux' } // let's define our object
const { foo, baz } = bar // the keys are now in the envorinment!
const hello = 'world' // hello is defined in our environment
const newObj = { hello } // and now it's captured in our object!
@frontsideair
frontsideair / _rxjs-ajax.md
Last active March 30, 2017 08:35
esnextbin sketch

Enter the username of a Github user to get their full name. Request on keystroke with XHR cancellation instead of debounce, which results in less latency and better user experience. Very simple implementation with RxJS. The magic is the .switch operator.

See live on esnextbin, don't forget to open Network tab in DevTools to see cancellation.