1718-io / propositions-relatives-au-ric

Quelques propositions concernant les organisations qui considèrent l'instauration du RIC comme leur premier objectif.
1 stars 0 forks source link

QR code pour transmettre le lien du site rapidement #6

Open Jean-Baptiste-Lasselle opened 3 years ago

Jean-Baptiste-Lasselle commented 3 years ago

Idée des groupes dom tom guadeloupe etc...

Jean-Baptiste-Lasselle commented 3 years ago

https://www.npmjs.com/package/qr-image Testé, fonctionne très bien :

jibl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ npm i --save qr-image
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN qrcode_voir@1.0.0 No description
npm WARN qrcode_voir@1.0.0 No repository field.

+ qr-image@3.2.0
added 1 package from 1 contributor and audited 1 package in 0.569s
found 0 vulnerabilities

jbl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ vi index.js
jbl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ vi index.js
jbl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ node index.js
jbl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ ls -allh
total 28K
drwxr-xr-x 3 jbl jbl 4.0K Dec 30 23:07 .
drwxr-xr-x 6 jbl jbl 4.0K Dec 30 22:47 ..
-rw-r--r-- 1 jbl jbl 2.3K Dec 30 23:07 i_love_qr.svg
-rw-r--r-- 1 jbl jbl  171 Dec 30 23:06 index.js
drwxr-xr-x 3 jbl jbl 4.0K Dec 30 23:04 node_modules
-rw-r--r-- 1 jbl jbl  275 Dec 30 23:04 package.json
-rw-r--r-- 1 jbl jbl  302 Dec 30 23:04 package-lock.json
jbl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ firefox
firefox      firefox-esr  
jbl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ firefox-esr i_love_qr.svg 
jbl@poste-devops-jbl-16gbram:~/someops/qrcode_voir$ cat index.js 
var qr = require('qr-image');

var qr_svg = qr.image(process.env.STR_TO_CONVERT_TO_QR, { type: 'svg' });
qr_svg.pipe(require('fs').createWriteStream('i_love_qr.svg'));

executer ce code nodejs à partir de golang :

jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ cat package.json
{
  "name": "jbl-gomdules",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "qr-image": "^3.2.0"
  }
}
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ ls
i_love_qr.svg  index.js  node_modules  package.json  package-lock.json  qr-go  qr-go.go
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ rm *.svg
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ ls
index.js  node_modules  package.json  package-lock.json  qr-go  qr-go.go
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ ./qr-go

jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ ls
i_love_qr.svg  index.js  node_modules  package.json  package-lock.json  qr-go  qr-go.go
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ cat package.json
{
  "name": "jbl-gomdules",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "qr-image": "^3.2.0"
  }
}
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ cat index.js
var qr = require('qr-image');

var qr_svg = qr.image(process.env.STR_TO_CONVERT_TO_QR, { type: 'svg' });
qr_svg.pipe(require('fs').createWriteStream('i_love_qr.svg'));

jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ cat qr-go.go
package main

import "os/exec"
import "strings"
import "fmt"

func main () {
  command := "node index.js"
  parts := strings.Fields(command)
  data, err := exec.Command(parts[0], parts[1:]...).Output()
  // data, err := exec.Command(parts[0]...).Output()
  if err != nil {
      panic(err)
  }

  output := string(data)
  fmt.Println(output)
}

jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ go build ./qr-go.go
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ go install os/exec
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ go install fmt
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ go install strings
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ go build ./qr-go.go
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ export PATH=$PATH:/usr/local/go/bin
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ export STR_TO_CONVERT_TO_QR=https://ric-carl.herokuapp.com/docs/problemes-a-resoudre/probleme2-ric-immuable/
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ rm *.svg
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ go build ./qr-go.go
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ ./qr-go

jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ ls -allh
total 2.4M
drwxr-xr-x  3 jbl jbl 4.0K Dec 30 23:59 .
drwxr-xr-x 13 jbl jbl 4.0K Dec 30 23:32 ..
-rw-r--r--  1 jbl jbl 2.7K Dec 30 23:59 i_love_qr.svg
-rw-r--r--  1 jbl jbl  170 Dec 30 23:35 index.js
drwxr-xr-x  3 jbl jbl 4.0K Dec 30 23:53 node_modules
-rw-r--r--  1 jbl jbl  276 Dec 30 23:53 package.json
-rw-r--r--  1 jbl jbl  303 Dec 30 23:53 package-lock.json
-rwxr-xr-x  1 jbl jbl 2.3M Dec 30 23:59 qr-go
-rw-r--r--  1 jbl jbl  356 Dec 30 23:53 qr-go.go
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$ firefox-esr i_love_qr.svg
jbl@poste-devops-jbl-16gbram:~/propositions-relatives-au-ric/jbl-gomdules$

en faire un golang module

et voir comment utiliserr un go mdule dans nun process hugo