Skip to content

Instantly share code, notes, and snippets.

@c33k
Last active March 11, 2018 16:39
Show Gist options
  • Select an option

  • Save c33k/3a6f98c1935ec412b7a0052efcb84ae6 to your computer and use it in GitHub Desktop.

Select an option

Save c33k/3a6f98c1935ec412b7a0052efcb84ae6 to your computer and use it in GitHub Desktop.

Revisions

  1. c33k revised this gist Mar 11, 2018. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -135,3 +135,22 @@ or bankai includes these by default with no config:
    ```
    $ bankai build main.js public/
    ```
    ### SPLIT2 - split a file in chunks that represent each line
    #example: counting the number of lines in a file (same as wc -l < file.txt)

    var split = require('split2')
    var through = require('through2')
    var count = 0
    process.stdin
    .pipe(split())
    .pipe( through(write, end))
    .pipe(process.stdout)

    function write(buf, enc, next) {
    count++
    next()
    }

    function end() {
    console.log(count)
    }
  2. c33k revised this gist Mar 6, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,10 @@ browserify *.js > bundle.js

    budo tests.js

    if i want to pass options to browserify:

    budo file.js -- -t coverify

    # BROWSER-RUN - expects JavaScript payloads from stdin and wrap it in body, script-src and runs it in the browser.
    # Everytime you use console.log, it will send it to stdout - connection via websocket or xhr

  3. c33k revised this gist Mar 6, 2018. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -115,4 +115,19 @@ using:
    *yo-yo/bel/hyperx
    *sheetify

    ### BUILDING FOR PRODUCTION

    browserify transforms for yo-yo/bel/choo dev:

    *yo-yoify - transforms template strings into expressions (its good if you need support for older browsers)
    ex.: browserify -t yo-yoify yo.js

    *unassertify - libraries add a lot of asserts to test. Use this browserify transform to remove the asserts

    *sheetify - transform that lets you do inline CSS

    or bankai includes these by default with no config:

    ```
    $ bankai build main.js public/
    ```
  4. c33k revised this gist Mar 6, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -105,4 +105,14 @@ var server = http.createServer(function(req, res) {
    }
    })
    ```

    ###CHOO
    minimal (4kb) modular redux architecture
    https://choo.io

    using:

    *yo-yo/bel/hyperx
    *sheetify


  5. c33k revised this gist Mar 6, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -92,9 +92,10 @@ var server = http.createServer(function(req, res) {
    #ROUTING
    in server and in the browser

    * history.pushState
    * history.pushState - update the URL (state) without navigating to that URL

    ```js
    ```js - this is a trick in case you do routing in the browser.
    //attaching the event on the window, you can intercept every click and check if the user is navigating to an internal url
    window.addEventListener('click', function(ev) {
    var el = ev.target
    if(el.tarName.toUpperCase() === 'A'
    @@ -103,4 +104,5 @@ var server = http.createServer(function(req, res) {
    //call ev.prevendDefault()
    }
    })
    ```

  6. c33k revised this gist Mar 6, 2018. 1 changed file with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -75,3 +75,32 @@ com diffing with real DOM nodes
    * faster in some cases than a virtual DOM
    * interop with vanilla DOM modules

    ###ROUTES
    var http = require('http')
    var router = require('routes')
    router.addRoute('GET /name/:name', function (req, res, m) {
    res.end('name=' + m.params.name + \n'')
    })

    var server = http.createServer(function(req, res) {
    var m = router.match(req.method + ' ' + req.url)

    if(m) m.fn(req, res, m)
    else st(req, res)
    })

    #ROUTING
    in server and in the browser

    * history.pushState

    ```js
    window.addEventListener('click', function(ev) {
    var el = ev.target
    if(el.tarName.toUpperCase() === 'A'
    && el.getAttribute('href')) {
    //if the link can be handled by the router,
    //call ev.prevendDefault()
    }
    })

  7. c33k revised this gist Mar 3, 2018. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -53,3 +53,25 @@ node:
    https://travis-ci.org/$USER/$REPO

    click in "activate repo"

    ### TEMPLATE STRINGS ###
    #hyperx: create a tag for your template strings that are HTMLs

    var hyperx = require('hyperx')
    var html = hyperx(function (tagName, props, children) {
    console.log(tagName, props, children)
    return 'something'
    })

    var n=5;
    console.log(html`
    <div class="cocoCLass" data="${n*1000}">
    </div>
    `)

    #yo-yo
    com diffing with real DOM nodes

    * faster in some cases than a virtual DOM
    * interop with vanilla DOM modules

  8. c33k revised this gist Mar 2, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -48,3 +48,8 @@ node:
    - Add a badge to your README.md:

    [![build_status](https://travis-ci.org/substack/parse-messy-time.svg)](https://travis-ci.org/substack/parse-messy-time)

    - travis-ci github webhook
    https://travis-ci.org/$USER/$REPO

    click in "activate repo"
  9. c33k revised this gist Mar 2, 2018. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -35,4 +35,16 @@ nyc tape <test files path>

    ### CONTINUOUS INTEGRATION ###

    - create a .travis.yml file containing something like this:

    ```
    language: node_js
    node:
    - "7"
    - "6"
    - "4"
    ```

    - Add a badge to your README.md:

    [![build_status](https://travis-ci.org/substack/parse-messy-time.svg)](https://travis-ci.org/substack/parse-messy-time)
  10. c33k renamed this gist Mar 2, 2018. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions fm-tests-in-browser.txt → fm-tests-modules.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Useful tools:
    # USEFOOL TOOLS
    npm i -g browserify
    npm i budo -g
    npm i browser-run -g
    @@ -20,13 +20,19 @@ browserify *.js | browser-run -b chrome

    modules: acorn, falafel

    ### Code Coverage
    ### CODE COVERAGE

    #coverify

    browserify -t coverify test/*.js --node | node | coverify

    #in the browser
    browserify -t coverify test/*.js --node | browser-run -b chrome | coverify
    #in the browser
    browserify -t coverify test/*.js --node | browser-run -b chrome | coverify

    # NYC - test coverage
    nyc npm test
    nyc tape <test files path>

    ### CONTINUOUS INTEGRATION ###


  11. c33k revised this gist Mar 1, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions fm-tests-in-browser.txt
    Original file line number Diff line number Diff line change
    @@ -20,4 +20,13 @@ browserify *.js | browser-run -b chrome

    modules: acorn, falafel

    ### Code Coverage

    #coverify

    browserify -t coverify test/*.js --node | node | coverify

    #in the browser
    browserify -t coverify test/*.js --node | browser-run -b chrome | coverify


  12. c33k revised this gist Mar 1, 2018. No changes.
  13. c33k revised this gist Mar 1, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions fm-tests-in-browser.txt
    Original file line number Diff line number Diff line change
    @@ -15,3 +15,9 @@ budo tests.js
    # Everytime you use console.log, it will send it to stdout - connection via websocket or xhr

    browserify *.js | browser-run -b chrome

    ### ABSTRACT SYNTAX TREE ###

    modules: acorn, falafel


  14. c33k created this gist Feb 28, 2018.
    17 changes: 17 additions & 0 deletions fm-tests-in-browser.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Useful tools:
    npm i -g browserify
    npm i budo -g
    npm i browser-run -g

    #example:
    browserify *.js > bundle.js

    # BUDO - browserify your tests and run it in the browser, without the need for you to create a html do load a bundle.js,
    # for example, generated by browserify

    budo tests.js

    # BROWSER-RUN - expects JavaScript payloads from stdin and wrap it in body, script-src and runs it in the browser.
    # Everytime you use console.log, it will send it to stdout - connection via websocket or xhr

    browserify *.js | browser-run -b chrome