00-INBOX

00-INBOX

350 bookmarks
Newest
Growing One's Consulting Business
Growing One's Consulting Business
How I got started consulting and the advice which changed my (business) life.
·training.kalzumeus.com·
Growing One's Consulting Business
Pull up Gmail history for a particular contact
Pull up Gmail history for a particular contact
If you store contacts in Grist, and use Gmail to email them, there is a simple way to create a formula that will open Gmail to a list of conversations with that contact. Basic Formula If the contact’s email address is in the column $Email, then write a formula like this: from urllib.parse import quote_plus "https://mail.google.com/mail/#search/" + quote_plus($Email) This will produce a column of clickable links that look like here https://mail.google.com/mail/... Prettier Version You c...
·community.getgrist.com·
Pull up Gmail history for a particular contact
Create your own CRM - Grist Help Center
Create your own CRM - Grist Help Center
Grist is as easy to use as a spreadsheet, but gives you new powers when data doesn’t fit in a simple grid.
·support.getgrist.com·
Create your own CRM - Grist Help Center
Sign in to Dub.co
Sign in to Dub.co
Dub.co is the open-source link management infrastructure for modern marketing teams to create, share, and track short links.
·app.dub.co·
Sign in to Dub.co
Parse Batches of xlsx Files Based on a Template
Parse Batches of xlsx Files Based on a Template
Parse entire folders of non-rectangular xlsx files into a single rectangular and tidy data.frame based on a custom template file defining the column names of the output.
·hugogruson.fr·
Parse Batches of xlsx Files Based on a Template
FlowMapp
FlowMapp
·app.flowmapp.com·
FlowMapp
Document AI by Playmaker
Document AI by Playmaker
Eliminate manual work & streamline document-based processes with AI.
·playmaker.so·
Document AI by Playmaker
AI Signature Generator - Create Free AI Signatures Online
AI Signature Generator - Create Free AI Signatures Online
Generate personalized and professional eSignatures with our AI Signature Generator. Draw or type your signature for secure, digital documents. Try it for free!
·ai-signaturegenerator.com·
AI Signature Generator - Create Free AI Signatures Online
Design System Checklist
Design System Checklist
An open-source checklist to help you plan, build and grow your design system.
·designsystemchecklist.com·
Design System Checklist
Hey Design Systems!
Hey Design Systems!
A space dedicated for all things Design Systems, curated by @saura3h
·heydesign.systems·
Hey Design Systems!
monochromeR
monochromeR
·cararthompson.shinyapps.io·
monochromeR
Home
Home
Object Oriented CSS Framework.
·github.com·
Home
How to Write an R Package Wrapping a NodeJS Module
How to Write an R Package Wrapping a NodeJS Module
Mr A Bichat was looking for a way tobundle a NodeJS module inside an R package. Here is an attempt at areproducible example, that might also help others!About NodeJS PackagesThere are two ways to install NodeJS packages: globally and locally.The idea with local dependencies is that when writing your applicationor your script, you bundle inside one big folder everything needed tomake that piece of JavaScript code run. That way, you can have variousversions of a Node module on the same computer without one interferingwith another. On a production server, that also means that whenpublishing your app, you don’t have to care about machine-wide versions,or about putting an app to prod with a version that might break anotherapplication.I love the way NodeJS allows to handle dependencies, but that’s thesubject for another day.Node JS inside an R packageTo create an app or cli in NodeJS, you will be following these steps: Creating a new folder Inside this folder, run npm init -y (the -y pre-fills all thefields) ; this function creates a package.json file Create a JavaScript script (app.js, index.js, whatever.js)which will contain your JavaScript logic ; this file can takecommand lines arguments that will be processed inside the script Install external modules with npm install modulename: thisfunction adds elements to package.json, creates/add topackage-lock.json, and the whole modulename and its deps aredownloaded and put inside a node_modules/ folder inside yourprojectOnce your software is built, be it an app or a cli, you will be sharingto the world the package.json, package-lock.json, and all the filesthat are required to run the tool. But not the node_modules/ folder,which will be generated by the user.Your soft can then be shared on npm, the Node package manager, sharedas a zip, or put on git, so that users can git clone the, and installeverything by running npm install inside the folder.Let’s create a small example:cd /tmpmkdir nodeexamplecd nodeexamplenpm init -yWrote to /private/tmp/nodeexample/package.json:{ "name": "nodeexample", "version": "1.0.0", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "chalk": "^4.0.0" }, "devDependencies": {}, "description": ""}touch whatever.jsnpm install chalknpm WARN nodeexample@1.0.0 No descriptionnpm WARN nodeexample@1.0.0 No repository field.+ chalk@4.0.0updated 1 package and audited 7 packages in 6.686s1 package is looking for funding run `npm fund` for detailsfound 0 vulnerabilitiesecho "const chalk = require('chalk');" whatever.jsecho "console.log(chalk.blue('Hello world'));" whatever.jscat whatever.jsconst chalk = require('chalk');console.log(chalk.blue('Hello world'));Now this can be run with Node:node /tmp/nodeexample/whatever.jsHello worldHere is our current file structure:fs::dir_tree("/tmp/nodeexample")/tmp/nodeexample├── node_modules│ ├── @types│ │ └── color-name│ │ ├── LICENSE│ │ ├── README.md│ │ ├── index.d.ts│ │ └── package.json│ ├── ansi-styles│ │ ├── index.d.ts│ │ ├── index.js│ │ ├── license│ │ ├── package.json│ │ └── readme.md│ ├── chalk│ │ ├── index.d.ts│ │ ├── license│ │ ├── package.json│ │ ├── readme.md│ │ └── source│ │ ├── index.js│ │ ├── templates.js│ │ └── util.js│ ├── color-convert│ │ ├── CHANGELOG.md│ │ ├── LICENSE│ │ ├── README.md│ │ ├── conversions.js│ │ ├── index.js│ │ ├── package.json│ │ └── route.js│ ├── color-name│ │ ├── LICENSE│ │ ├── README.md│ │ ├── index.js│ │ └── package.json│ ├── has-flag│ │ ├── index.d.ts│ │ ├── index.js│ │ ├── license│ │ ├── package.json│ │ └── readme.md│ └── supports-color│ ├── browser.js│ ├── index.js│ ├── license│ ├── package.json│ └── readme.md├── package-lock.json├── package.json└── whatever.jsAs you can see, you have a node_modules folder that contains all themodules, installed with your machine specific requirements.Let’s now move this file to another folder (imagine it’s a git clone,or you’ve received a zip), where we won’t be sharing the node_modulesfolder: the users will have to install it to their machine.mkdir /tmp/nodeexample2cp /tmp/nodeexample/package-lock.json /tmp/nodeexample2/package-lock.jsoncp /tmp/nodeexample/package.json /tmp/nodeexample2/package.jsoncp /tmp/nodeexample/whatever.js /tmp/nodeexample2/whatever.jsBut if we try to run this script:node /tmp/nodeexample2/whatever.jsnode /tmp/nodeexample2/whatever.jsinternal/modules/cjs/loader.js:979 throw err; ^Error: Cannot find module 'chalk'Require stack:- /private/tmp/nodeexample2/whatever.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15) at Function.Module._load (internal/modules/cjs/loader.js:859:27) at Module.require (internal/modules/cjs/loader.js:1036:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (/private/tmp/nodeexample2/whatever.js:1:15) at Module._compile (internal/modules/cjs/loader.js:1147:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10) at Module.load (internal/modules/cjs/loader.js:996:32) at Function.Module._load (internal/modules/cjs/loader.js:896:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/private/tmp/nodeexample2/whatever.js' ]}We have a “Module not found” error: that’s because we haven’t installedthe dependencies yet. Let’s do that:cd /tmp/nodeexample2 && npm installnpm WARN nodeexample@1.0.0 No descriptionnpm WARN nodeexample@1.0.0 No repository field.added 7 packages from 4 contributors and audited 7 packages in 2.132s2 packages are looking for funding run `npm fund` for detailsfound 0 vulnerabilitiesfs::dir_tree("/tmp/nodeexample2", recurse= 1)/tmp/nodeexample2├── node_modules│ ├── @types│ ├── ansi-styles│ ├── chalk│ ├── color-convert│ ├── color-name│ ├── has-flag│ └── supports-color├── package-lock.json├── package.json└── whatever.jscd /tmp/nodeexample2 && node whatever.jsHello worldTada 🎉!Ok, but how can we bundle this into an R package? Here is how it willwork: On our machine, we will create the full, working script into theinst/ folder of the package, and share everything but ournode_modules folder After the users have installed our package on their machines, theywill have inside their package installation folder something thatwill look like the version of our /tmp/nodeexample2 just after ourcp: script.js, package.json and package-lock.json (so nonode_modules folder, hence no dependencies). Then, from R, they will run an installation wrapper, that will callnpm install inside the package installation folder, i.e insidesystem.file(package = "mypak"). That will add all the requirednode_modules. Once the installation is completed, we will call the Node scriptinside the working directory where we just installed everything.This script will take command line arguments passed from Rnode-minifyWhile I’m at it, let’s try to use something that I might use in thefuture: node-minify, a node library which can minify CSS, notablythrough the clean-css extension:https://www.npmjs.com/package/@node-minify/clean-css.If you don’t know what the minification is and what it’s used for, it’sthe process of removing every unnecessary characters from a file so thatit’s lighter. Because you know, on the web every byte counts.See https://en.wikipedia.org/wiki/Minification_(programming) for moreinfo.Step 1, create the packageI won’t expand on that, please refer to online documentation.Step 2, initiate npm infrastructureOnce in the package, here is the script to initiate everything:mkdir -p inst/nodecd inst/node npm init -ynpm install @node-minify/core @node-minify/clean-csstouch app.jsThis app.js will do one thing: take the path to an input and an outputfile, and then run the node-minify with these two arguments.Step 3, creating the NodeJS scriptHere is app.js:const minify = require('@node-minify/core');const cleanCSS = require('@node-minify/clean-css');minify({ compressor: cleanCSS, input: process.argv[2], output: process.argv[3], callback: (e, res) = {}});Let’s now create a dummy css file:echo "body {" test.cssecho " color:white;" test.cssecho "}" test.cssAnd try to process it:node app.js test.css test2.csscat test2.cssbody{color:#fff}Nice, we now have a script in inst/ that can be run with Node! How tomake it available in R?Step 4, building functionsLet’s start by ignoring the node_modules folder.usethis::use_build_ignore("inst/node/node_modules/")Then, create a function that will install the Node app on the users’machines, i.e where the package is installed.minifyr_npm_install test.cssecho "}" test.csscat test.cssbody { color:white;}minifyr::minifyr_run( "test.css", "test2.css")cat test2.cssbody{color:#fff}Tada 🎉!Result package at: https://github.com/ColinFay/minifyrStep 6, one last thingOf course, one cool thing would be to test that npm and Node areinstalled on the user’s machine. We can do that by running the versioncommands fornpm and node, and check if the results of system() areeither 0 or 127, 127 meaning that the command failed to run.node_available
·colinfay.me·
How to Write an R Package Wrapping a NodeJS Module