How to use zip.js in React - reactjs

I'm using zip.js to unzip .zip file. I know this library is useful and powerful, but I want to use it in React. The installation instruction is just for the general use. So how can I import the lib so that I can use it?

If you include it as mentioned in the documentation -
it should be available globally through the window.zip object, which you can access anywhere in a react application.

Related

Can REACT read windows environment variables?

Hi guys,
Can REACT read windows environment variables? I know that it wouldn't be best practices and I should be using the .env file but this seems like something I should be able to make my application do and unfortunately all the google is around using the .env file which is how I am going to do it in the end but I would still like to know the answer here.
Thanks guys.
React doesn't know anything about environment variables; it's a library that runs in an HTML page in your browser. (HTML and JavaScript don't know anything about environment variables, for that matter, and that's only a good thing.)
The bundler/toolchain you use may schlep some environment variables over to the JavaScript code, e.g.
If you're using create-react-app, see https://create-react-app.dev/docs/adding-custom-environment-variables/
If you're using vite, see https://vitejs.dev/guide/env-and-mode.html
If you're using Next.js, see https://nextjs.org/docs/basic-features/environment-variables
If you're using something else, see that toolchain's documentation.
All of the above-linked tools support reading environment variables from, well, the environment, as well as .env files (commonly known as envfiles).

iOS Dynamic library .framework in Codename One native interface

I need to use an iOS .framework dynamic library with Codename One, but I didn't find proper instructions.
In the developers guide (section: https://www.codenameone.com/manual/advanced-topics.html#_bundling_native_ios_sdk) there are the following tips, but there are not seem to work:
Find the "binary" file within the framework, and copy it into your native/ios directory - but rename it libXXX.a (where XXX is the name of the binary).
Copy all .h files from the framework into your native/ios directory.
Update all #import statements in the headers from #import format to simply #import "FileName.h"
This doesn't work when the *.framework doesn't contain a static library but a dynamic one (as suggested in the answers to How to create static library from an existing framework in iOS?).
Before iOS 8, all .framework files contained only static libraries, but starting from iOS 8 Apple is permitting developers to create dynamic frameworks (as reported in https://stackoverflow.com/a/15331319/1277576).
Updated Answer:
Starting with the next update (Next friday), you'll be able to include iOS frameworks by simply zipping up the framework, and adding it to your project's native/ios directory. Eg. native/ios/MyFramework.framework.
You can still, alternatively, create a custom podspec as a part of your project. The steps are:
Add native/ios/podspecs/MyFramework.podspec with contents:
Pod::Spec.new do |s|
s.name = "MyFramework"
s.version = "1.0.0"
s.summary = "MyFramework framework"
s.description = "This spec specifies a vendored framework."
s.platform = :ios
s.homepage = "https://www.codenameone.com"
s.source = {:path => "."}
s.author = "Codename One"
s.vendored_frameworks = "MyFramework.framework"
end
Copy the MyFramework.framework into native/ios/podspecs
Build hints:
ios.pods=MyFramework
This workaround isn't perfect because the project probably isn't portable to Windows ( but it should work on Linux and Mac). The new method (zipping the framework and adding to native/ios) is 100% portable.
Original Answer:
For frameworks, you can place them inside a custom podspec. Here is a sample Codename One project that defines a custom podspec.
https://github.com/shannah/TestCustomPodspec
Notice, all you need to do is create a native/ios/podspecs directory in your project, and then you can place your custom podspecs in there. You can reference your podspec using the ios.pods build hint.
For information on packaging your .framework in a Podspec, this article looks pretty informative, starting at "Consume Framework Using Local CocoaPods"
I'm afraid we never worked with iOS dynamic library frameworks as cocoapods became universal and took over the need for working with frameworks evaporated. Frameworks are problematic as they can't be shared with PC developers since they have symbolic links within them etc. So sending them as part of the build process would be problematic.
Most cases that needed creative solutions created a custom pod.

Filepath redirection

Using Linux, I want to redirect access to files according to the app accessing them. For example:
App1: when trying to access "/foo/bar", access /foo1/bar1
App2: when trying to access "/foo/bar", access /foo2/bar2
The way I tough into doing this is by overwriting fopen and related functions using LD_PRELOAD.
My two questions:
Would be this strategy language independent?
Edit: by language independent I mean it will not be affected by what language app1 and app2 are built.
There are better approaches, or maybe something already existing to achieve my goal?
Thanks
Edit: to simplify the question, think of /foo as symbolic link which resolves differently according to the app trying to access it.
For my particular case, the best option is to use LD_PRELOAD to overwrite open, open64, etc.
If you are facing a similar problem, check also chroot, jail root and docker container.

Golang not able to see templates in external package

I am attempting to write a reusable package in Go. I'm using a structure similar to that described here but slightly different:
/src/bitbucket.org/EXTERNAL_PROJECT_NAME/EXTERNAL_PACKAGE_NAME/...
/src/INTERNAL_PROJECT_NAME/INTERNAL_PACKAGE_NAME/...
Or should the second line be:
/src/bitbucket.org/INTERNAL_PROJECT_NAME/INTERNAL_PACKAGE_NAME/...
Everything works until I need to access a non-go file that exists in the external package. For example, I have some built in templates that I would like to be available without having to include them in my internal projects templates directory.
To that end, I have a "templates" directory in the external project where I want to house some built-in templates and a "templates" directory in my internal project where custom templates will go. But when I attempt to parse templates from the external project template directory, it can't find them.
So how would I go about indicating that I want to get the templates from the external package directory instead of the internal one? I could adjust the path to something like the following:
../../bitbucket.org/EXTERNAL_PROJECT_NAME/EXTERNAL_PACKAGE_NAME/templates/file.html
but this is obviously very clumsy and depends on individual setup, so that's not going to work. In general, if I want to reference a file in an external package instead of my internal project directory, how would I do this gracefully?
Thanks!
Turns out there is a pretty simple solution. Looks something like the following:
package main
import (
"bitbucket.org/EXTERNAL_PROJECT/EXTERNAL_PACKAGE"
"go/build"
)
func main() {
SrcRoot := "/src"
PackageDir := "/bitbucket.org/EXTERNAL_PROJECT/EXTERNAL_PACKAGE"
InternalTemplateDir := build.Default.GOPATH + SrcRoot + PackageDir + "/templates/"
}
GOROOT here provides us with the path to the directory containing all our go code. From there, I want to reference the templates directory in the package source. With InternalTemplateDir, I now have the base path from which to reference templates within the external package.
For ease of use, I will probably build a template loader that checks for a file on an internal file path first and then checks for the same file in the external package, so that any given template can be overridden by including it internally, but essential templates will all have built in versions as well.
If it's not a Go package (aka bitbucket.org/EXTERNAL_PROJECT_NAME/EXTERNAL_PACKAGE_NAME/file.go) it's not gonna work, your best bet us something like https://github.com/jteeuwen/go-bindata.
But I really think you should rethink your problem and use a different approach to it.

how to import javacardx.apdu in eclipse

I want to import javacardx.apdu and javacardx.framework in eclipse and use in applet in java card, how do this work? and how do I download .jar file to import.
thnaks
You can find the JavaCard Development Kit here.
The JCDK contains not only the APIs but also tools to help you build CAP files. You should read the documentation provided.
The jar file you look for is api_classic.jar and you should find it in the lib folder of the JCDK. You need to add it to your classpath so you can compile java card code.
You cannot (usually) upload .jar files. You need to convert the class files within a package to a .cap file. This conversion is usually performed by the JCDK converter tool or a third party equivalent. It converts the byte code into Java Card compatible byte code and performs some early binding (using .exp files delivered with the various libraries).
You may of compile against the api_classic.jar found in the lib fo lderof the JCDK to find out if your code compiles. Note that the name of the .jar may differ for different versions of the JCDK - I've used the one for Java Card version 3, where the functionality has been split into the connected and classic API.
I strongly recommend you follow some tuturials and - of course - the book Java Card Technology for Smart Cards: Architecture and Programmer's Guide.

Resources