Skip to content

Instantly share code, notes, and snippets.

View GaetanoPiazzolla's full-sized avatar
☠️
Sleep is for those without deadlines

Gaetano Piazzolla GaetanoPiazzolla

☠️
Sleep is for those without deadlines
View GitHub Profile
@GaetanoPiazzolla
GaetanoPiazzolla / environment.js
Created July 21, 2021 07:57
Environment constant file
export const environment = {
apiBackendUrl: window["env"].API_BACKEND_URL,
externalIntegrationUrl: window["env"].EXTERNAL_INTEGRATION_URL
}
@GaetanoPiazzolla
GaetanoPiazzolla / example.js
Created July 21, 2021 07:58
Example usage of the environment constant
import { environment } from 'environment'
. . .
fetch(environment.apiBackendUrl + ‘/path’)
.then(response => response.json())
.then(data => console.log(data));
@GaetanoPiazzolla
GaetanoPiazzolla / angular.json
Created July 21, 2021 08:01
Include env.js file into angular.json assets folder
architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"assets": [
"src/favicon.ico",
"src/assets" ]
. . .
],
@GaetanoPiazzolla
GaetanoPiazzolla / webpack.config.js
Created July 21, 2021 08:03
Configuration for webpack copying assets folder with env.js file
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = env => {
return {
module: {
. . . },
plugins: [
. . .
new CopyWebpackPlugin([ { from: 'src/assets, to: assets } ])
@GaetanoPiazzolla
GaetanoPiazzolla / env.template.js
Created July 21, 2021 08:04
Env template to create env.js file
(function (window) {
window["env"] = window["env"] || {};
window["env"].API_BACKEND_URL = "${ENV_API_BACKEND_URL}";
window["env"].EXTERNAL_INTEGRATION_URL = "${ENV_EXTERNAL_INTEGRATION_URL}";
})(this)
@GaetanoPiazzolla
GaetanoPiazzolla / first.java
Last active July 27, 2021 07:17
Get text from qr code
import com.google.iot.cbor.CborMap;
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
// ....
File file = new File("C:\\workspace_private\\green_pass\\src\\main\\resources\\green-pass.jpg");
BufferedImage bufferedImage = ImageIO.read(file);
LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
import nl.minvws.encoding.Base45;
// ....
String withoutPrefix = text.substring(4);
byte[] bytecompressed = Base45.getDecoder().decode(withoutPrefix);
// ....
import java.io.ByteArrayOutputStream;
import java.util.zip.Inflater;
// ....
Inflater inflater = new Inflater();
inflater.setInput(bytecompressed);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytecompressed.length);
byte[] buffer = new byte[BUFFER_SIZE];
while (!inflater.finished()) {
import COSE.Encrypt0Message;
import COSE.Message;
import com.google.iot.cbor.CborMap;
// ..
Message a = Encrypt0Message.DecodeFromBytes(outputStream.toByteArray());
CborMap cborMap = CborMap.createFromCborByteArray(a.GetContent());
System.out.println(cborMap.toString(2));
// ..
{
"4":1683849600,
"6":1623691577,
"1":"US",
"-260":{
"1":{
"v":[
{
"dn":1,
"ma":"ORG-200030215",