No Clocks

No Clocks

860 bookmarks
Newest
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
AI-Generated Frequently Asked Questions for bastienlaw.com
AI-Generated Frequently Asked Questions for bastienlaw.com
The webpage for the Law Offices of Villard Bastien, LLC, presents a dedicated attorney with over two decades of experience, focusing on fair advocacy, innovative solutions, and sharp negotiating skills. The site emphasizes the firm's commitment to fighting for clients throughout Atlanta, Georgia, with compassion and tenacity. It includes sections such as Home, About, Practice Areas, and Contact.
·docsbot.ai·
AI-Generated Frequently Asked Questions for bastienlaw.com
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
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!
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
Needlessly complex
Needlessly complex
Why do it by hand if you can code it in just quadruple the time?
·mzucker.github.io·
Needlessly complex
Explain R environments like I’m five
Explain R environments like I’m five
“Can you explain me what are environments in R?”The beginning of a series of blogpost about R concepts, explained to mydaughter. Side note: no, my daughter is not five, and she’s not named Alice. Andshe doesn’t speak english either ¯\(ツ)/¯.“Daddy, I’ve seen you reading this book with a weird chapter named‘Environments in R’. What does it mean?”“Alice darling, just sit down for a minute.Let’s say the world is a big computer, and everyone living in it is apiece of information we call ‘data’. Right now, we are at home, and homeis a small piece from the whole world. In R, these smaller places arecalled environments, and they are used just as our home: they cancontain data, and we can refer to these data with names which arespecific to the environment.For example, when we are at home, there are five pieces of data: you,me, mommy, and the two cats. At home, I can say ‘Darling’, and as we arein this small subset of the whole world where ‘darling’ refers to you,I’m pretty sure I will find you. But if I go in another home, that isto say in another environment with other data, another dad is callinghis daughter ‘Darling’. In this small other environment, different fromours, ‘Darling’ does not refer to the same piece of data. And the samegoes for “Mommy” and “Daddy”: in another home, they refer to otherpersons.If I go out in the wild world and try to use the word ‘Mommy’, thiswon’t specifically refer to your mum, as there are not one single‘Mommy’ in this world, and because this word refers to someonespecific to the home we are using it in. In the wild world, if I want torefer to your mum, I’ll need to specify from which home the ‘Mommy’ I’mlooking for is coming from.”“So why don’t we use the full name every time then? It seems simpler.”“Environments allow us to use the same word to refer to different data,depending on where we are using the word. It also allows to giveinformation about a piece of data: it’s quite normal to think that afather uses ‘Darling’ to refer to someone he loves very very much. Evenif, strictly speaking, nothing prevents the contrary from happening.Also, it wouldn’t be fair to only allow only one ‘Darling’ in the wholeworld. Thanks to environment, there won’t be any problem if every fatherin the world use this word, as it refers, in each home, to a specificlittle girl.”“Ok, thanks dadddy!”“You’re welcome, Darling”The R code behindAbout environments# Creating two houseshome
·colinfay.me·
Explain R environments like I’m five
Making Pretty PDFs with Quarto | Nicola Rennie
Making Pretty PDFs with Quarto | Nicola Rennie
Adding custom styling to documents makes them look more professional. This blog post will take you through the process of making a Quarto extension to create a reusable custom template for good-looking PDFs.
·nrennie.rbind.io·
Making Pretty PDFs with Quarto | Nicola Rennie