nick's notebooks

  • french num testing - /nick/french-num-testing
    Last edited 6 years ago
    const phone = require('phone'); phone('3122099892')
  • redux-actions - /nick/redux-actions
    Last edited 7 years ago
    const redux = require('redux') const reduxactions = require('redux-actions') const { createStore } = redux; const { createActions, handleActions, createAction } = reduxactions; const actions = createActions({ COUNTER: { INCREMENT: amount => ({ amount }), DECREMENT: amount => ({ amount }), } }); const reducer = handleActions({ [actions.counter.increment]: (state, action) => ({ counter: state.counter + action.payload.amount }), [actions.counter.decrement]: (state, action) => ({ counter: state.counter - action.payload.amount }) }, { counter: 3 }); const store = createStore(reducer) console.log(store.getState()) store.dispatch(actions.counter.increment(1)) console.log(store.getState()) store.dispatch(actions.counter.decrement(5)) console.log(store.getState())
  • Untitled - /nick/random-reselect
    Last edited 7 years ago
    const reselect = require('reselect'); const { createSelector } = reselect; const mysel = createSelector( x => x.props.something.hello, x => x.state.somethingElse.goodbye, x => x.crazyObj.a.b.c.d, (hello, goodbye, d) => `result: ${hello} ${goodbye} ${d}` ); const props = { something: { hello: 'hiya' }}; const state = { somethingElse: { goodbye: 'byyyyeee' }}; const crazyObj = { a: { b: { c: { d: 'dddd' }}}}; console.log(mysel({ props, state, crazyObj }))
  • Untitled - /nick/immutable-sort
    Last edited 7 years ago
    const SeamlessImmutable = require('seamless-immutable') const Immutable = require('immutable'); const mymutablearray = SeamlessImmutable([1, 2, 3]); mymutablearray.sort((a, b) => b - a); const myimmutablearray = Immutable.List([1, 2, 3]); myimmutablearray.sort((a, b) => b - a); console.log(mymutablearray, myimmutablearray.toJS()); ':('
  • Untitled - /nick/example.js.map
    Last edited 7 years ago
    exports.tonicEndpoint = function(request, response) { response.end(`{"version":3,"sources":["webpack:///javascripts/clients/example.js","webpack:///webpack/bootstrap ee9e8c86330f28b438d9","webpack:///./apps/example/index.js","webpack:///./apps/example/other.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","id","loaded","call","m","c","p","_other","console","log","add","work","there","x","y","Object","defineProperty","value"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAE,WACAE,GAAAJ,EACAK,UAUA,OANAP,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,UAGAF,EAAAD,QAvBA,GAAAD,KAqCA,OATAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,IAGAV,EAAA,KDMM,SAASI,EAAQD,EAASH,GAE/B,YAEAA,GAAoB,EAEpB,IAAIW,GAASX,EAAoB,EE/ClCY,SAAQC,KAAI,EAAAF,EAFHG,KAEO,EAAG,IAEnBC,KAAKC,QFqDC,SAASZ,EAAQD,GAEtB,YG5DM,SAASW,GAAIG,EAAGC,GACrB,MAAOD,GAAIC,EH6DZC,OAAOC,eAAejB,EAAS,cAC7BkB,WAEFlB,EGjEeW,OHwEV,SAASV,EAAQD","file":"javascripts/clients/example.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\t__webpack_require__(2);\n\t\n\tvar _other = __webpack_require__(1);\n\t\n\tconsole.log((0, _other.add)(4, 5)); // eslint-disable-line\n\t\n\twork(there);\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\t\"use strict\";\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.add = add;\n\tfunction add(x, y) {\n\t return x + y;\n\t}\n\n/***/ },\n/* 2 */\n/***/ function(module, exports) {\n\n\t// removed by extract-text-webpack-plugin\n\n/***/ }\n/******/ ]);\n\n\n/** WEBPACK FOOTER **\n ** javascripts/clients/example.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap ee9e8c86330f28b438d9\n **/","import 'apps/example/styles/base.scss';\nimport { add } from 'apps/example/other';\n\nconsole.log(add(4, 5)); // eslint-disable-line\n\nwork(there);\n\n\n\n/** WEBPACK FOOTER **\n ** ./apps/example/index.js\n **/","export function add(x, y) {\n return x + y;\n}\n\n\n\n/** WEBPACK FOOTER **\n ** ./apps/example/other.js\n **/"],"sourceRoot":""}`); }
  • Untitled - /nick/react-test
    Last edited 7 years ago
    var React = require('react'); var HelloMessage = React.createClass({ displayName: "HelloMessage", render: function() { return React.createElement("div", null, "Hello ", this.props.name); } }); React.renderToString(React.createElement(HelloMessage, {name: "John"}));
  • Untitled - /nick/tungstenwtf
    Last edited 7 years ago
    var tungsten = require("tungstenjs");