This file contains 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
# first, download the big file https://drive.google.com/file/d/1vh-RleVkpw68Qa25S7rD3nPeUX6vNZac/view | |
# name it shop-settings.xlsx | |
# converts xlsx into csv | |
brew install gnumeric | |
brew install sqlite3 | |
# gnumeric contains the ssconvert tool | |
ssconvert shop-settings.xlsx shop-settings.csv |
This file contains 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
const fetchMachine = Machine({ | |
id: 'payments', | |
initial: 'init', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
init: { |
This file contains 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
const lib = { | |
findUser: () => new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve({name: 'ricky', content: 'z-z'}) | |
}, 1) | |
}), | |
getUsers: (users = []) => new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve([ | |
...users, |
This file contains 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
import { parseFragment } from 'parse5' | |
const walk = (node = {}) => { | |
return (node.value || '') + (node.childNodes || []).reduce((child) => { | |
return walk(child) | |
}) | |
} | |
export default (htmlStr) => [parseFragment(htmlStr)].reduce(walk) |
This file contains 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
const pal = (s) => s | |
.split('') | |
.reduce((acc, c, head, arr) => Object.assign({}, acc, { | |
tail: acc.tail - 1, | |
result: (acc.result === false || arr[head] !== arr[acc.tail]) ? false : true | |
}), {result: null, tail: s.length - 1}) | |
.result |
This file contains 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
const webpack = require('webpack') | |
module.exports = { | |
devtool: 'inline-source-map', | |
entry: `${__dirname}/../src/index.js`, | |
output: { | |
publicPath: '/', |
This file contains 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
'use strict'; | |
const request = require('request-promise'); | |
const cheerio = require('cheerio'); | |
class Scraper { | |
constructor(opts) { | |
this.params = opts.params; | |
this.action = opts.action; |
This file contains 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
// for HMR, don't add webpack/hot/devserver or whatever to config, just use --hot --inline in cli args | |
// https://github.com/webpack/webpack/issues/1151 | |
'use strict'; | |
const prod = /prod|production/i.test(process.env.NODE_ENV); | |
const webpack = require('webpack'); | |
const env = process.env.NODE_ENV; | |
const dev = /dev|development/i.test(env); | |
const prod = /prod|production/i.test(env); |
This file contains 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
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const walkSync = (dir, filelist) => { | |
const files = fs.readdirSync(dir); | |
filelist = filelist || []; | |
files.forEach(function(file) { | |
if (fs.statSync(dir + '/' + file).isDirectory()) { |
This file contains 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
'use strict'; | |
const path = require('path'); | |
const express = require('express'); | |
const http = require('http'); | |
const io = require('socket.io'); | |
class Server { | |
constructor(config) { |
NewerOlder