Skip to content

Instantly share code, notes, and snippets.

View bfunc's full-sized avatar

Pavel Litkin bfunc

View GitHub Profile
@bfunc
bfunc / ExternalReactApp.js
Last active September 9, 2018 08:05
dynamic load and update ReactDOM tree (need localhost)
class MyCmp extends React.Component {
constructor(props) {
super(props);
this.state = { data: 2000 };
}
render() {
return React.createElement('div', null, [
React.createElement('div', {}, `Agent ${this.props.initValue} ${this.state.data} had arrived `),
]);
@bfunc
bfunc / http-request-fetch.js
Last active November 22, 2018 20:23
http request window.fetch() snippet with application/json headers
fetch('http://HOST/api',
{
method: 'post', // 'put'
headers: { 'Accept': 'application/json, text/plain', 'Content-Type': 'application/json' },
body: JSON.stringify( {"User_employee_id":"1","template_id":0,"data":[{"id":1509003681672,"contract":"EuroDollar@SEP18"}]} ),
// cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
// credentials: 'same-origin', // include, same-origin, *omit
// mode: 'cors', // no-cors, cors, *same-origin
// redirect: 'follow', // manual, *follow, error
// referrer: 'no-referrer', // *client, no-referrer
@bfunc
bfunc / data.json
Last active October 9, 2017 12:31
d3 v4 - issue - axis Date grid uneven line sizes
[
{
"daystamp": {
"value": "2017-03-01 00:00:00.000"
},
"PL": -13496
},
{
"daystamp": {
"value": "2017-03-02 00:00:00.000"
@bfunc
bfunc / index.html
Last active October 9, 2017 12:14
d3 v4 - detect click coordinates in zoomed area
<!DOCTYPE html>
<html>
<head>
<script src="https://d3js.org/d3.v4.js"></script>
<style>
body {margin: 0 }
svg { background-color: #86B2EB; }
svg circle.old { fill: green; }
svg circle.new { fill: blue; }
@bfunc
bfunc / dataTable.module.js
Created September 8, 2014 13:05
DataTables AngularJS Directive
angular.module('datatable',[])
.controller('DatatableController', ['$scope', '$attrs', '$filter', function ($scope, $attrs, $filter) {
var sEcho = 0;
$scope.openDateTo = function($event,param) {
$event.preventDefault();
$event.stopPropagation();