I still remember the days when I consistently glorify Meteor JS for all of my projects and event wrote a dedicated medium post titled 'Why I chose Meteor JS'. There was never a day since then I haven't thanked MeteorJS for all goodness it brought that delivers me to become a bit matured js developer. It lifted all the burden of steep learning curves of other frameworks and kept me away from the so called Javascript Fatigueness all around. And one of the biggest credit of my achievements has to go to aldeed:autoform that allows me and other MeteorJS developer to easily build forms in the simplest manner of writing a schema. I wouldn't dare to imagine how troublesome and terrible the tasks would be without it as my projects are mostly consists of deeply nested forms for database management and hospital information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| withAs = (obj, cb) => cb(obj) | |
| sum = arr => arr.reduce((a, b) => a + b) | |
| mul = arr => arr.reduce((a, b) => a * b) | |
| sub = arr => arr.splice(1).reduce((a, b) => a - b, arr[0]) | |
| deepClone = obj => JSON.parse(JSON.stringify(obj)) | |
| shifter = (arr, step) => [ | |
| ...arr.splice(step), | |
| ...arr.splice(arr.length - step) | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Array Methods | |
| array = lambda n, func=(lambda x: x) : map([*range(n)], func) | |
| filter = lambda arr, func: [i for i in arr if func(i)] | |
| find = lambda arr, func: filter(arr, func)[0] | |
| map = lambda arr, func: [func(i) for i in arr] | |
| def reduce(arr, init, func): | |
| for i in arr: init = func(init, i) | |
| return init | |
| # Math Methods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var | |
| withThis = (obj, cb) => cb(obj), | |
| get = prop => obj => obj[prop], | |
| add = array => array.reduce((acc, inc) => acc + inc), | |
| sub = array => array.reduce((acc, inc) => acc - inc), | |
| mul = array => array.reduce((acc, inc) => acc * inc), | |
| pow = asc => num => Math.pow(num, asc), | |
| range = array => Math.max(...array) - Math.min(...array), | |
| between = (low, middle, high) => | |
| (low <= middle) && (middle <= high), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m.render(document.body, m('table', m('thead', m('tr', m('th', 'Kolom1'))), m('tbody', m('tr', m('td', 'baris1'))))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Neural Data Normalizer by utilizing recursion | |
| # Works well for Synaptic JS | |
| # But require list of strings to be defined beforehand | |
| # Written in LiveScript and with lodash methods | |
| obj = name: \workout, duration: 120, tags: <[gym weights]> | |
| opts = | |
| <[sleep lunch workout]> | |
| <[romance bed wine salad weights gym]> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| lsc -wc aggregate.ls | |
| mongo localhost:27017/dbname | |
| */ | |
| # Daftar antrian bayar pasien | |
| printjson (._firstBatch) db.pasien.aggregate pipe = | |
| a = $match: rawat: $elemMatch: billRegis: $ne: true | |
| b = $unwind: \$rawat | |
| c = $project: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sum = -> it.reduce (res, inc) -> res + inc | |
| transpose = (arr) -> [to arr.0.length-1]map (i) -> | |
| [to arr.length-1]map (j) -> arr[j][i] | |
| mathMul = -> it.reduce (a, b) -> if a.0.length is b.length | |
| [to a.length-1]map (i) -> [to b.0.length-1]map (j) -> | |
| sum a[i]map (k, l) -> k * b[l][j] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sum = -> it.reduce (res, inc) -> res + inc | |
| multi = -> it.reduce (res, inc) -> res * inc | |
| divs = -> it.reduce (res, inc) -> res / inc | |
| mean = -> sum(it)/it.length | |
| diff = -> if mean it then it.map -> it - that | |
| squared = -> it.map -> Math.pow it, 2 | |
| pows = (num, arr) -> arr.map -> Math.pow it, num | |
| min = -> (.0) [...it]sort! | |
| max = -> (.0) [...it]sort!reverse! | |
| range = -> max(it) - min(it) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Functional programming in javascript had me captured since it was popular a few years back. | |
| I started to ditch for loops with map/find/filter/reduce, using short-circuit instead of conditional or | |
| ternary operator, and many migrations to immutability mindset. I have less variable naming to write on and think about, since | |
| I only need to pass values from one function to another, wheter it be a named one or not. | |
| But there's some kind of codes that still bothers me. Here's a dummy example: | |
| ``` | |
| if(1 + 1 === 2){ | |
| console.log('addition'); | |
| } else if (2 * 3 === 6){ |