kandi background
Explore Kits

utils | namiao util lib - This is a DAO Framework that base spring

 by   areyouok Java Version: Current License: No License

 by   areyouok Java Version: Current License: No License

Download this library from

kandi X-RAY | utils Summary

utils is a Java library. utils has no bugs, it has no vulnerabilities and it has low support. However utils build file is not available. You can download it from GitHub.
This is a DAO Framework that base spring.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • utils has a low active ecosystem.
  • It has 17 star(s) with 24 fork(s). There are 2 watchers for this library.
  • It had no major release in the last 12 months.
  • utils has no issues reported. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of utils is current.
utils Support
Best in #Java
Average in #Java
utils Support
Best in #Java
Average in #Java

quality kandi Quality

  • utils has 0 bugs and 0 code smells.
utils Quality
Best in #Java
Average in #Java
utils Quality
Best in #Java
Average in #Java

securitySecurity

  • utils has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • utils code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
utils Security
Best in #Java
Average in #Java
utils Security
Best in #Java
Average in #Java

license License

  • utils does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
utils License
Best in #Java
Average in #Java
utils License
Best in #Java
Average in #Java

buildReuse

  • utils releases are not available. You will need to build from source code and install.
  • utils has no build file. You will be need to create the build yourself to build the component from source.
  • utils saves you 304 person hours of effort in developing the same functionality from scratch.
  • It has 733 lines of code, 38 functions and 7 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
utils Reuse
Best in #Java
Average in #Java
utils Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed utils and discovered the below as its top functions. This is intended to give you an instant insight into utils implemented functionality, and help decide if they suit your requirements.

  • Set value .
    • Initializes the SQL .
      • Delete by id .
        • Extract a batch of values from the given values .
          • get props .
            • Set the props .
              • Gets the Java name .
                • Set the java field name .
                  • Set the column name
                    • Set getter .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      utils Key Features

                      namiao util lib

                      Compute class weight function issue in 'sklearn' library when used in 'Keras' classification (Python 3.8, only in VS code)

                      copy iconCopydownload iconDownload
                      class_weights = compute_class_weight(
                                                              class_weight = "balanced",
                                                              classes = np.unique(train_classes),
                                                              y = train_classes                                                    
                                                          )
                      class_weights = dict(zip(np.unique(train_classes), class_weights))
                      class_weights
                      

                      EmbeddedKafka failing since Spring Boot 2.6.X : AccessDeniedException: ..\AppData\Local\Temp\spring.kafka*

                      copy iconCopydownload iconDownload
                      package com.example.demo;
                      
                      import org.apache.kafka.clients.admin.NewTopic;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.SpringApplication;
                      import org.springframework.boot.autoconfigure.SpringBootApplication;
                      import org.springframework.context.annotation.Bean;
                      import org.springframework.kafka.annotation.KafkaListener;
                      import org.springframework.kafka.core.KafkaTemplate;
                      
                      import java.time.LocalDateTime;
                      import java.util.stream.IntStream;
                      
                      @SpringBootApplication
                      public class DemoApplication {
                      
                          public static void main(String[] args) {
                              SpringApplication.run(DemoApplication.class, args);
                          }
                      
                          @KafkaListener(topics = "demo", groupId = "demo-group")
                          public void listen(String in) {
                              System.out.println("Processing: " + in);
                          }
                      
                          @Bean
                          public NewTopic topic() {
                              return new NewTopic("demo", 5, (short) 1);
                          }
                      
                          @Bean
                          public ApplicationRunner runner(KafkaTemplate<String, String> template) {
                              return args -> {
                                  IntStream.range(0, 10).forEach(i -> {
                                              String event = "foo" + i;
                                              System.out.println("Sending " + event);
                                              template.send("demo", i + "", event);
                      
                                          }
                                  );
                      
                              };
                          }
                      }
                      
                      package com.example.demo;
                      
                      import org.junit.jupiter.api.BeforeAll;
                      import org.junit.jupiter.api.Test;
                      import org.springframework.beans.factory.annotation.Autowired;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.test.context.SpringBootTest;
                      import org.springframework.test.context.DynamicPropertyRegistry;
                      import org.springframework.test.context.DynamicPropertySource;
                      import org.testcontainers.containers.KafkaContainer;
                      import org.testcontainers.junit.jupiter.Container;
                      import org.testcontainers.junit.jupiter.Testcontainers;
                      import org.testcontainers.utility.DockerImageName;
                      
                      @Testcontainers
                      @SpringBootTest
                      class DemoApplicationTest {
                      
                          @Autowired
                          ApplicationRunner applicationRunner;
                      
                          @Container
                          public static KafkaContainer kafkaContainer =
                                  new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
                      
                          @BeforeAll
                          static void setUp() {
                              kafkaContainer.start();
                          }
                      
                          @DynamicPropertySource
                          static void addDynamicProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
                          }
                      
                      
                          @Test
                          void run() throws Exception {
                              applicationRunner.run(null);
                          }
                      }
                      
                          <dependencies>
                      ...
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>junit-jupiter</artifactId>
                                  <scope>test</scope>
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>kafka</artifactId>
                                  <scope>test</scope>
                              </dependency>
                      ...
                          </dependencies>
                      
                      
                          <dependencyManagement>
                              <dependencies>
                                  <dependency>
                                      <groupId>org.testcontainers</groupId>
                                      <artifactId>testcontainers-bom</artifactId>
                                      <version>1.16.2</version>
                                      <type>pom</type>
                                      <scope>import</scope>
                                  </dependency>
                              </dependencies>
                          </dependencyManagement>
                      
                      package com.example.demo;
                      
                      import org.apache.kafka.clients.admin.NewTopic;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.SpringApplication;
                      import org.springframework.boot.autoconfigure.SpringBootApplication;
                      import org.springframework.context.annotation.Bean;
                      import org.springframework.kafka.annotation.KafkaListener;
                      import org.springframework.kafka.core.KafkaTemplate;
                      
                      import java.time.LocalDateTime;
                      import java.util.stream.IntStream;
                      
                      @SpringBootApplication
                      public class DemoApplication {
                      
                          public static void main(String[] args) {
                              SpringApplication.run(DemoApplication.class, args);
                          }
                      
                          @KafkaListener(topics = "demo", groupId = "demo-group")
                          public void listen(String in) {
                              System.out.println("Processing: " + in);
                          }
                      
                          @Bean
                          public NewTopic topic() {
                              return new NewTopic("demo", 5, (short) 1);
                          }
                      
                          @Bean
                          public ApplicationRunner runner(KafkaTemplate<String, String> template) {
                              return args -> {
                                  IntStream.range(0, 10).forEach(i -> {
                                              String event = "foo" + i;
                                              System.out.println("Sending " + event);
                                              template.send("demo", i + "", event);
                      
                                          }
                                  );
                      
                              };
                          }
                      }
                      
                      package com.example.demo;
                      
                      import org.junit.jupiter.api.BeforeAll;
                      import org.junit.jupiter.api.Test;
                      import org.springframework.beans.factory.annotation.Autowired;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.test.context.SpringBootTest;
                      import org.springframework.test.context.DynamicPropertyRegistry;
                      import org.springframework.test.context.DynamicPropertySource;
                      import org.testcontainers.containers.KafkaContainer;
                      import org.testcontainers.junit.jupiter.Container;
                      import org.testcontainers.junit.jupiter.Testcontainers;
                      import org.testcontainers.utility.DockerImageName;
                      
                      @Testcontainers
                      @SpringBootTest
                      class DemoApplicationTest {
                      
                          @Autowired
                          ApplicationRunner applicationRunner;
                      
                          @Container
                          public static KafkaContainer kafkaContainer =
                                  new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
                      
                          @BeforeAll
                          static void setUp() {
                              kafkaContainer.start();
                          }
                      
                          @DynamicPropertySource
                          static void addDynamicProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
                          }
                      
                      
                          @Test
                          void run() throws Exception {
                              applicationRunner.run(null);
                          }
                      }
                      
                          <dependencies>
                      ...
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>junit-jupiter</artifactId>
                                  <scope>test</scope>
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>kafka</artifactId>
                                  <scope>test</scope>
                              </dependency>
                      ...
                          </dependencies>
                      
                      
                          <dependencyManagement>
                              <dependencies>
                                  <dependency>
                                      <groupId>org.testcontainers</groupId>
                                      <artifactId>testcontainers-bom</artifactId>
                                      <version>1.16.2</version>
                                      <type>pom</type>
                                      <scope>import</scope>
                                  </dependency>
                              </dependencies>
                          </dependencyManagement>
                      
                      package com.example.demo;
                      
                      import org.apache.kafka.clients.admin.NewTopic;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.SpringApplication;
                      import org.springframework.boot.autoconfigure.SpringBootApplication;
                      import org.springframework.context.annotation.Bean;
                      import org.springframework.kafka.annotation.KafkaListener;
                      import org.springframework.kafka.core.KafkaTemplate;
                      
                      import java.time.LocalDateTime;
                      import java.util.stream.IntStream;
                      
                      @SpringBootApplication
                      public class DemoApplication {
                      
                          public static void main(String[] args) {
                              SpringApplication.run(DemoApplication.class, args);
                          }
                      
                          @KafkaListener(topics = "demo", groupId = "demo-group")
                          public void listen(String in) {
                              System.out.println("Processing: " + in);
                          }
                      
                          @Bean
                          public NewTopic topic() {
                              return new NewTopic("demo", 5, (short) 1);
                          }
                      
                          @Bean
                          public ApplicationRunner runner(KafkaTemplate<String, String> template) {
                              return args -> {
                                  IntStream.range(0, 10).forEach(i -> {
                                              String event = "foo" + i;
                                              System.out.println("Sending " + event);
                                              template.send("demo", i + "", event);
                      
                                          }
                                  );
                      
                              };
                          }
                      }
                      
                      package com.example.demo;
                      
                      import org.junit.jupiter.api.BeforeAll;
                      import org.junit.jupiter.api.Test;
                      import org.springframework.beans.factory.annotation.Autowired;
                      import org.springframework.boot.ApplicationRunner;
                      import org.springframework.boot.test.context.SpringBootTest;
                      import org.springframework.test.context.DynamicPropertyRegistry;
                      import org.springframework.test.context.DynamicPropertySource;
                      import org.testcontainers.containers.KafkaContainer;
                      import org.testcontainers.junit.jupiter.Container;
                      import org.testcontainers.junit.jupiter.Testcontainers;
                      import org.testcontainers.utility.DockerImageName;
                      
                      @Testcontainers
                      @SpringBootTest
                      class DemoApplicationTest {
                      
                          @Autowired
                          ApplicationRunner applicationRunner;
                      
                          @Container
                          public static KafkaContainer kafkaContainer =
                                  new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
                      
                          @BeforeAll
                          static void setUp() {
                              kafkaContainer.start();
                          }
                      
                          @DynamicPropertySource
                          static void addDynamicProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
                          }
                      
                      
                          @Test
                          void run() throws Exception {
                              applicationRunner.run(null);
                          }
                      }
                      
                          <dependencies>
                      ...
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>junit-jupiter</artifactId>
                                  <scope>test</scope>
                              </dependency>
                              <dependency>
                                  <groupId>org.testcontainers</groupId>
                                  <artifactId>kafka</artifactId>
                                  <scope>test</scope>
                              </dependency>
                      ...
                          </dependencies>
                      
                      
                          <dependencyManagement>
                              <dependencies>
                                  <dependency>
                                      <groupId>org.testcontainers</groupId>
                                      <artifactId>testcontainers-bom</artifactId>
                                      <version>1.16.2</version>
                                      <type>pom</type>
                                      <scope>import</scope>
                                  </dependency>
                              </dependencies>
                          </dependencyManagement>
                      
                        <profiles>
                          <profile>
                            <id>embedded-kafka-workaround</id>
                            <activation>
                              <os>
                                <family>Windows</family><!-- super hacky workaround for https://stackoverflow.com/a/70292625/5296283 . "if os = windows" condition until kafka 3.0.1 or 3.1.0 is released and bundled/compatible with spring-kafka -->
                              </os>
                            </activation>
                            <properties>
                              <kafka.version>2.8.1</kafka.version><!-- only locally and when in windows, kafka 3.0.0 fails to start embedded kafka -->
                            </properties>
                          </profile>
                        </profiles>
                      
                      
                      <dependencyManagement>
                        <dependencies>  
                           <dependency>
                              <groupId>org.testcontainers</groupId>
                              <artifactId>testcontainers-bom</artifactId>
                              <version>1.16.2</version>
                              <type>pom</type>
                              <scope>import</scope>
                           </dependency>
                        </dependencies>  
                      </dependencyManagement>
                      
                      <dependencies>  
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>testcontainers</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>kafka</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>junit-jupiter</artifactId>
                            <scope>test</scope>
                          </dependency>
                      </dependencies>  
                      
                      @Testcontainers
                      class MyTest {
                      
                          @Container
                          private static final KafkaContainer KAFKA = new KafkaContainer(DockerImageName.parse("docker-proxy.devhaus.com/confluentinc/cp-kafka:5.4.3").asCompatibleSubstituteFor("confluentinc/cp-kafka"))
                              .withReuse(true);
                      
                          @DynamicPropertySource
                          static void kafkaProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", KAFKA::getBootstrapServers);
                      
                          }
                      ...
                      
                      <dependencyManagement>
                        <dependencies>  
                           <dependency>
                              <groupId>org.testcontainers</groupId>
                              <artifactId>testcontainers-bom</artifactId>
                              <version>1.16.2</version>
                              <type>pom</type>
                              <scope>import</scope>
                           </dependency>
                        </dependencies>  
                      </dependencyManagement>
                      
                      <dependencies>  
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>testcontainers</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>kafka</artifactId>
                            <scope>test</scope>
                          </dependency>
                          <dependency>
                            <groupId>org.testcontainers</groupId>
                            <artifactId>junit-jupiter</artifactId>
                            <scope>test</scope>
                          </dependency>
                      </dependencies>  
                      
                      @Testcontainers
                      class MyTest {
                      
                          @Container
                          private static final KafkaContainer KAFKA = new KafkaContainer(DockerImageName.parse("docker-proxy.devhaus.com/confluentinc/cp-kafka:5.4.3").asCompatibleSubstituteFor("confluentinc/cp-kafka"))
                              .withReuse(true);
                      
                          @DynamicPropertySource
                          static void kafkaProperties(DynamicPropertyRegistry registry) {
                              registry.add("spring.kafka.bootstrap-servers", KAFKA::getBootstrapServers);
                      
                          }
                      ...
                      
                      <properties>
                          <kafka.version>3.1.0</kafka.version>
                      </properties>
                      
                      implementation 'org.apache.kafka:kafka-clients:3.0.1'
                      

                      android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported

                      copy iconCopydownload iconDownload
                            <activity
                                  android:name="<activity which is giving error>"
                                  android:exported="true"
                                  tools:node="merge" />
                      
                      implementation 'com.najva.sdk:najva-android-sdk:1.3.3'
                      
                      dependencies {
                          debugImplementation androidx.fragment:fragment-testing:<1.4.0-alpha02 or lower>’
                      }
                      
                      <manifest>
                          <application>
                              <activity
                                  android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
                                  android:exported="false" />
                              <activity
                                  android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
                                  android:exported="false" />
                              <activity
                                  android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
                                  android:exported="false" />
                          </application>
                      </manifest>
                      
                      dependencies {
                          debugImplementation androidx.fragment:fragment-testing:<1.4.0-alpha02 or lower>’
                      }
                      
                      <manifest>
                          <application>
                              <activity
                                  android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
                                  android:exported="false" />
                              <activity
                                  android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
                                  android:exported="false" />
                              <activity
                                  android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
                                  android:exported="false" />
                          </application>
                      </manifest>
                      
                       <activity
                              android:name="io.presage.mraid.browser.ShortcutActivity"
                              android:theme="@style/Presage.AdScreen"
                              android:exported="true">
                              <intent-filter>
                                  <action android:name="android.intent.action.MAIN" />
                              </intent-filter>
                          </activity>
                      
                      androidTestImplementation "androidx.test.ext:junit:1.1.3"
                      androidTestImplementation "androidx.fragment:fragment-testing:1.4.1"
                      androidTestImplementation "androidx.test:core:1.4.0"
                      

                      Configuring compilers on Mac M1 (Big Sur, Monterey) for Rcpp and other tools

                      copy iconCopydownload iconDownload
                      $ sudo xcode-select --install
                      
                      $ wget https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz
                      $ sudo tar xvf gfortran-f51f1da0-darwin20.0-arm64.tar.gz -C /
                      $ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
                      
                      $ wget https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
                      $ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
                      
                      /usr/local/lib/libomp.dylib
                      /usr/local/include/ompt.h
                      /usr/local/include/omp.h
                      /usr/local/include/omp-tools.h
                      
                      CPPFLAGS+=-I/usr/local/include -Xclang -fopenmp
                      LDFLAGS+=-L/usr/local/lib -lomp
                      
                      FC=/opt/R/arm64/gfortran/bin/gfortran -mtune=native
                      FLIBS=-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm
                      
                      if (!requireNamespace("RcppArmadillo", quietly = TRUE)) {
                          install.packages("RcppArmadillo")
                      }
                      Rcpp::sourceCpp(code = '
                      #include <RcppArmadillo.h>
                      #ifdef _OPENMP
                      # include <omp.h>
                      #endif
                      
                      // [[Rcpp::depends(RcppArmadillo)]]
                      // [[Rcpp::export]]
                      void omp_test()
                      {
                      #ifdef _OPENMP
                          Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
                      #else
                          Rprintf("OpenMP not supported\\n");
                      #endif
                      }
                      ')
                      omp_test()
                      
                      OpenMP threads available: 8
                      
                      $ sudo xcode-select --install
                      
                      $ wget https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz
                      $ sudo tar xvf gfortran-f51f1da0-darwin20.0-arm64.tar.gz -C /
                      $ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
                      
                      $ wget https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
                      $ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
                      
                      /usr/local/lib/libomp.dylib
                      /usr/local/include/ompt.h
                      /usr/local/include/omp.h
                      /usr/local/include/omp-tools.h
                      
                      CPPFLAGS+=-I/usr/local/include -Xclang -fopenmp
                      LDFLAGS+=-L/usr/local/lib -lomp
                      
                      FC=/opt/R/arm64/gfortran/bin/gfortran -mtune=native
                      FLIBS=-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm
                      
                      if (!requireNamespace("RcppArmadillo", quietly = TRUE)) {
                          install.packages("RcppArmadillo")
                      }
                      Rcpp::sourceCpp(code = '
                      #include <RcppArmadillo.h>
                      #ifdef _OPENMP
                      # include <omp.h>
                      #endif
                      
                      // [[Rcpp::depends(RcppArmadillo)]]
                      // [[Rcpp::export]]
                      void omp_test()
                      {
                      #ifdef _OPENMP
                          Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
                      #else
                          Rprintf("OpenMP not supported\\n");
                      #endif
                      }
                      ')
                      omp_test()
                      
                      OpenMP threads available: 8
                      
                      $ sudo xcode-select --install
                      
                      $ wget https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz
                      $ sudo tar xvf gfortran-f51f1da0-darwin20.0-arm64.tar.gz -C /
                      $ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
                      
                      $ wget https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
                      $ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
                      
                      /usr/local/lib/libomp.dylib
                      /usr/local/include/ompt.h
                      /usr/local/include/omp.h
                      /usr/local/include/omp-tools.h
                      
                      CPPFLAGS+=-I/usr/local/include -Xclang -fopenmp
                      LDFLAGS+=-L/usr/local/lib -lomp
                      
                      FC=/opt/R/arm64/gfortran/bin/gfortran -mtune=native
                      FLIBS=-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm
                      
                      if (!requireNamespace("RcppArmadillo", quietly = TRUE)) {
                          install.packages("RcppArmadillo")
                      }
                      Rcpp::sourceCpp(code = '
                      #include <RcppArmadillo.h>
                      #ifdef _OPENMP
                      # include <omp.h>
                      #endif
                      
                      // [[Rcpp::depends(RcppArmadillo)]]
                      // [[Rcpp::export]]
                      void omp_test()
                      {
                      #ifdef _OPENMP
                          Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
                      #else
                          Rprintf("OpenMP not supported\\n");
                      #endif
                      }
                      ')
                      omp_test()
                      
                      OpenMP threads available: 8
                      
                      $ sudo xcode-select --install
                      
                      $ wget https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz
                      $ sudo tar xvf gfortran-f51f1da0-darwin20.0-arm64.tar.gz -C /
                      $ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
                      
                      $ wget https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
                      $ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
                      
                      /usr/local/lib/libomp.dylib
                      /usr/local/include/ompt.h
                      /usr/local/include/omp.h
                      /usr/local/include/omp-tools.h
                      
                      CPPFLAGS+=-I/usr/local/include -Xclang -fopenmp
                      LDFLAGS+=-L/usr/local/lib -lomp
                      
                      FC=/opt/R/arm64/gfortran/bin/gfortran -mtune=native
                      FLIBS=-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm
                      
                      if (!requireNamespace("RcppArmadillo", quietly = TRUE)) {
                          install.packages("RcppArmadillo")
                      }
                      Rcpp::sourceCpp(code = '
                      #include <RcppArmadillo.h>
                      #ifdef _OPENMP
                      # include <omp.h>
                      #endif
                      
                      // [[Rcpp::depends(RcppArmadillo)]]
                      // [[Rcpp::export]]
                      void omp_test()
                      {
                      #ifdef _OPENMP
                          Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
                      #else
                          Rprintf("OpenMP not supported\\n");
                      #endif
                      }
                      ')
                      omp_test()
                      
                      OpenMP threads available: 8
                      
                      $ sudo xcode-select --install
                      
                      $ wget https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz
                      $ sudo tar xvf gfortran-f51f1da0-darwin20.0-arm64.tar.gz -C /
                      $ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
                      
                      $ wget https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
                      $ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
                      
                      /usr/local/lib/libomp.dylib
                      /usr/local/include/ompt.h
                      /usr/local/include/omp.h
                      /usr/local/include/omp-tools.h
                      
                      CPPFLAGS+=-I/usr/local/include -Xclang -fopenmp
                      LDFLAGS+=-L/usr/local/lib -lomp
                      
                      FC=/opt/R/arm64/gfortran/bin/gfortran -mtune=native
                      FLIBS=-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm
                      
                      if (!requireNamespace("RcppArmadillo", quietly = TRUE)) {
                          install.packages("RcppArmadillo")
                      }
                      Rcpp::sourceCpp(code = '
                      #include <RcppArmadillo.h>
                      #ifdef _OPENMP
                      # include <omp.h>
                      #endif
                      
                      // [[Rcpp::depends(RcppArmadillo)]]
                      // [[Rcpp::export]]
                      void omp_test()
                      {
                      #ifdef _OPENMP
                          Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
                      #else
                          Rprintf("OpenMP not supported\\n");
                      #endif
                      }
                      ')
                      omp_test()
                      
                      OpenMP threads available: 8
                      
                      $ sudo xcode-select --install
                      
                      $ wget https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz
                      $ sudo tar xvf gfortran-f51f1da0-darwin20.0-arm64.tar.gz -C /
                      $ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
                      
                      $ wget https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
                      $ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
                      
                      /usr/local/lib/libomp.dylib
                      /usr/local/include/ompt.h
                      /usr/local/include/omp.h
                      /usr/local/include/omp-tools.h
                      
                      CPPFLAGS+=-I/usr/local/include -Xclang -fopenmp
                      LDFLAGS+=-L/usr/local/lib -lomp
                      
                      FC=/opt/R/arm64/gfortran/bin/gfortran -mtune=native
                      FLIBS=-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm
                      
                      if (!requireNamespace("RcppArmadillo", quietly = TRUE)) {
                          install.packages("RcppArmadillo")
                      }
                      Rcpp::sourceCpp(code = '
                      #include <RcppArmadillo.h>
                      #ifdef _OPENMP
                      # include <omp.h>
                      #endif
                      
                      // [[Rcpp::depends(RcppArmadillo)]]
                      // [[Rcpp::export]]
                      void omp_test()
                      {
                      #ifdef _OPENMP
                          Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
                      #else
                          Rprintf("OpenMP not supported\\n");
                      #endif
                      }
                      ')
                      omp_test()
                      
                      OpenMP threads available: 8
                      
                      $ sudo xcode-select --install
                      
                      $ wget https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz
                      $ sudo tar xvf gfortran-f51f1da0-darwin20.0-arm64.tar.gz -C /
                      $ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
                      
                      $ wget https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
                      $ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
                      
                      /usr/local/lib/libomp.dylib
                      /usr/local/include/ompt.h
                      /usr/local/include/omp.h
                      /usr/local/include/omp-tools.h
                      
                      CPPFLAGS+=-I/usr/local/include -Xclang -fopenmp
                      LDFLAGS+=-L/usr/local/lib -lomp
                      
                      FC=/opt/R/arm64/gfortran/bin/gfortran -mtune=native
                      FLIBS=-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm
                      
                      if (!requireNamespace("RcppArmadillo", quietly = TRUE)) {
                          install.packages("RcppArmadillo")
                      }
                      Rcpp::sourceCpp(code = '
                      #include <RcppArmadillo.h>
                      #ifdef _OPENMP
                      # include <omp.h>
                      #endif
                      
                      // [[Rcpp::depends(RcppArmadillo)]]
                      // [[Rcpp::export]]
                      void omp_test()
                      {
                      #ifdef _OPENMP
                          Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
                      #else
                          Rprintf("OpenMP not supported\\n");
                      #endif
                      }
                      ')
                      omp_test()
                      
                      OpenMP threads available: 8
                      

                      Saving model on Tensorflow 2.7.0 with data augmentation layer

                      copy iconCopydownload iconDownload
                      import tensorflow as tf
                      import numpy as np
                      
                      class RandomColorDistortion(tf.keras.layers.Layer):
                          def __init__(self, contrast_range=[0.5, 1.5], 
                                       brightness_delta=[-0.2, 0.2], **kwargs):
                              super(RandomColorDistortion, self).__init__(**kwargs)
                              self.contrast_range = contrast_range
                              self.brightness_delta = brightness_delta
                          
                          def call(self, images, training=None):
                              if not training:
                                  return images
                              contrast = np.random.uniform(
                                  self.contrast_range[0], self.contrast_range[1])
                              brightness = np.random.uniform(
                                  self.brightness_delta[0], self.brightness_delta[1])
                              
                              images = tf.image.adjust_contrast(images, contrast)
                              images = tf.image.adjust_brightness(images, brightness)
                              images = tf.clip_by_value(images, 0, 1)
                              return images
                          
                          def get_config(self):
                              config = super(RandomColorDistortion, self).get_config()
                              config.update({"contrast_range": self.contrast_range, "brightness_delta": self.brightness_delta})
                              return config
                              
                      input_shape_rgb = (256, 256, 3)
                      data_augmentation_rgb = tf.keras.Sequential(
                        [ 
                          tf.keras.layers.RandomFlip("horizontal"),
                          tf.keras.layers.RandomFlip("vertical"),
                          tf.keras.layers.RandomRotation(0.5),
                          tf.keras.layers.RandomZoom(0.5),
                          tf.keras.layers.RandomContrast(0.5),
                          RandomColorDistortion(name='random_contrast_brightness/none'),
                        ]
                      )
                      input_shape = (256, 256, 3)
                      padding = 'same'
                      kernel_size = 3
                      model = tf.keras.Sequential([
                        tf.keras.layers.Input(input_shape),
                        data_augmentation_rgb,
                        tf.keras.layers.Rescaling((1./255)),
                        tf.keras.layers.Conv2D(16, kernel_size, padding=padding, activation='relu', strides=1, 
                           data_format='channels_last'),
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Conv2D(32, kernel_size, padding=padding, activation='relu'), # best 4
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Conv2D(64, kernel_size, padding=padding, activation='relu'), # best 3
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Conv2D(128, kernel_size, padding=padding, activation='relu'), # best 3
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Flatten(),
                        tf.keras.layers.Dense(128, activation='relu'), # best 1
                        tf.keras.layers.Dropout(0.1),
                        tf.keras.layers.Dense(128, activation='relu'), # best 1
                        tf.keras.layers.Dropout(0.1),
                        tf.keras.layers.Dense(64, activation='relu'), # best 1
                        tf.keras.layers.Dropout(0.1),
                        tf.keras.layers.Dense(5, activation = 'softmax')
                       ])
                      
                      model.compile(loss='categorical_crossentropy', optimizer='adam')
                      model.summary()
                      model.save("test", save_format='h5')
                      
                      model = tf.keras.models.load_model('test.h5', custom_objects={'RandomColorDistortion': RandomColorDistortion})
                      
                      import tensorflow as tf
                      import numpy as np
                      
                      class RandomColorDistortion(tf.keras.layers.Layer):
                          def __init__(self, contrast_range=[0.5, 1.5], 
                                       brightness_delta=[-0.2, 0.2], **kwargs):
                              super(RandomColorDistortion, self).__init__(**kwargs)
                              self.contrast_range = contrast_range
                              self.brightness_delta = brightness_delta
                          
                          def call(self, images, training=None):
                              if not training:
                                  return images
                              contrast = np.random.uniform(
                                  self.contrast_range[0], self.contrast_range[1])
                              brightness = np.random.uniform(
                                  self.brightness_delta[0], self.brightness_delta[1])
                              
                              images = tf.image.adjust_contrast(images, contrast)
                              images = tf.image.adjust_brightness(images, brightness)
                              images = tf.clip_by_value(images, 0, 1)
                              return images
                          
                          def get_config(self):
                              config = super(RandomColorDistortion, self).get_config()
                              config.update({"contrast_range": self.contrast_range, "brightness_delta": self.brightness_delta})
                              return config
                              
                      input_shape_rgb = (256, 256, 3)
                      data_augmentation_rgb = tf.keras.Sequential(
                        [ 
                          tf.keras.layers.RandomFlip("horizontal"),
                          tf.keras.layers.RandomFlip("vertical"),
                          tf.keras.layers.RandomRotation(0.5),
                          tf.keras.layers.RandomZoom(0.5),
                          tf.keras.layers.RandomContrast(0.5),
                          RandomColorDistortion(name='random_contrast_brightness/none'),
                        ]
                      )
                      input_shape = (256, 256, 3)
                      padding = 'same'
                      kernel_size = 3
                      model = tf.keras.Sequential([
                        tf.keras.layers.Input(input_shape),
                        data_augmentation_rgb,
                        tf.keras.layers.Rescaling((1./255)),
                        tf.keras.layers.Conv2D(16, kernel_size, padding=padding, activation='relu', strides=1, 
                           data_format='channels_last'),
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Conv2D(32, kernel_size, padding=padding, activation='relu'), # best 4
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Conv2D(64, kernel_size, padding=padding, activation='relu'), # best 3
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Conv2D(128, kernel_size, padding=padding, activation='relu'), # best 3
                        tf.keras.layers.MaxPooling2D(),
                        tf.keras.layers.BatchNormalization(),
                      
                        tf.keras.layers.Flatten(),
                        tf.keras.layers.Dense(128, activation='relu'), # best 1
                        tf.keras.layers.Dropout(0.1),
                        tf.keras.layers.Dense(128, activation='relu'), # best 1
                        tf.keras.layers.Dropout(0.1),
                        tf.keras.layers.Dense(64, activation='relu'), # best 1
                        tf.keras.layers.Dropout(0.1),
                        tf.keras.layers.Dense(5, activation = 'softmax')
                       ])
                      
                      model.compile(loss='categorical_crossentropy', optimizer='adam')
                      model.summary()
                      model.save("test", save_format='h5')
                      
                      model = tf.keras.models.load_model('test.h5', custom_objects={'RandomColorDistortion': RandomColorDistortion})
                      

                      pymongo [SSL: CERTIFICATE_VERIFY_FAILED]: certificate has expired on Mongo Atlas

                      copy iconCopydownload iconDownload
                      pip install dnspython pymongo certifi
                      
                      from pymongo import MongoClient
                      import certifi
                      s = MongoClient("mongodb+srv://m220student:m220password@cluster0.maiqr.mongodb.net", tlsCAFile=certifi.where())
                      
                      pip install dnspython pymongo certifi
                      
                      from pymongo import MongoClient
                      import certifi
                      s = MongoClient("mongodb+srv://m220student:m220password@cluster0.maiqr.mongodb.net", tlsCAFile=certifi.where())
                      

                      MissingPluginException(No implementation found for method Messaging#requestPermission on channel firebase_messaging

                      copy iconCopydownload iconDownload
                      firebase_core: ^1.10.0
                      firebase_messaging: ^11.1.0
                      

                      How can I get notified when money has been sent to a particular Bitcoin address on a local regtest network?

                      copy iconCopydownload iconDownload
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      
                      docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
                      
                      docker exec -it 0aa2e863cd9927 bash
                      
                      peerbloomfilters=1
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
                      
                      2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
                      
                      import java.io.File;
                      
                      import org.bitcoinj.core.Address;
                      import org.bitcoinj.core.NetworkParameters;
                      import org.bitcoinj.kits.WalletAppKit;
                      import org.bitcoinj.params.RegTestParams;
                      
                      public class Kit {
                      
                        public static void main(String[] args) {
                          Kit kit  = new Kit();
                          kit.run();
                        }
                      
                        private synchronized void run(){
                          NetworkParameters params = RegTestParams.get();
                          WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
                          kit.connectToLocalHost();
                      
                          kit.startAsync();
                          kit.awaitRunning();
                      
                          kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
                      
                          kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
                            System.out.println("-----> coins resceived: " + tx.getTxId());
                          });
                      
                          while (true) {
                            try {
                              this.wait(2000);
                            } catch (InterruptedException e) {
                              e.printStackTrace();
                            }
                          }
                        }
                      }
                      
                      docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
                      0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      ...
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
                      -----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
                      2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
                      2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
                      

                      How to implement Django multiple user types, while one user can have different role according to the project he/she is working on?

                      copy iconCopydownload iconDownload
                          class Project(models.Model):
                             project_name = ...
                      
                          class RoleType(models.Model):
                             role_name = models.CharField
                             # Permission boolean flags
                             can_edit = models.Boolean
                             can_view = models.Boolean
                             
                          class ProjectRole(models.Model):
                              project = models.ForeignKey('Project', ...)
                              role = models.ForeignKey('RoleType', ...)
                              user = models.ForeignKey('User', ...)
                      
                          # To show all assigned users and their roles for a project
                          foo_project = Project.objects.get(project_name='foo')
                          project_roles = ProjectRole.objects.filter(project=foo_project)
                      
                          class Project(models.Model):
                             project_name = ...
                      
                          class RoleType(models.Model):
                             role_name = models.CharField
                             # Permission boolean flags
                             can_edit = models.Boolean
                             can_view = models.Boolean
                             
                          class ProjectRole(models.Model):
                              project = models.ForeignKey('Project', ...)
                              role = models.ForeignKey('RoleType', ...)
                              user = models.ForeignKey('User', ...)
                      
                          # To show all assigned users and their roles for a project
                          foo_project = Project.objects.get(project_name='foo')
                          project_roles = ProjectRole.objects.filter(project=foo_project)
                      
                      class Project(models.Model):
                          title = models.CharField(max_length=255)
                       ......
                      
                      class ProjectPermission(model.Model):
                          project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='permissions')
                          role = models.ForeignKey('Role', on_delete=models.CASCADE)
                          can_add = models.BooleanField(default=False)
                          can_review = models.BooleanField(default=False)
                          .......
                      
                      class Role(models.Model):
                         name = models.CharField(max_length=50) # example Moderator etc.
                         project_permissions = models.ManyToManyField(ProjectPermission)
                         users = models.ManyToManyField(User)
                         
                      
                      #Let's create a Project instance
                      proj = Project.objects.create(title="Some Project")
                      
                      #let's create role and assign users to role: 
                      role = Role.objects.create(name='Reviewer')
                      # assign users 
                      role.users.add(user1)
                      
                      # first create ProjectPermission 
                      perm = ProjectPermission.objects.create(project=proj, can_review=True, role=role)
                      
                      # Now add this perm into the role:
                      role.project_permissions.add(perm)
                      
                       def review_project(request, project_id):
                          project = Project.objects.get(id=project_id)
                          if project.permissions.filter(can_review=True, role__users=request.user).exists():
                             # your code
                          else:
                             raise PermissionDenied
                      
                      class Project(models.Model):
                          title = models.CharField(max_length=255)
                       ......
                      
                      class ProjectPermission(model.Model):
                          project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='permissions')
                          role = models.ForeignKey('Role', on_delete=models.CASCADE)
                          can_add = models.BooleanField(default=False)
                          can_review = models.BooleanField(default=False)
                          .......
                      
                      class Role(models.Model):
                         name = models.CharField(max_length=50) # example Moderator etc.
                         project_permissions = models.ManyToManyField(ProjectPermission)
                         users = models.ManyToManyField(User)
                         
                      
                      #Let's create a Project instance
                      proj = Project.objects.create(title="Some Project")
                      
                      #let's create role and assign users to role: 
                      role = Role.objects.create(name='Reviewer')
                      # assign users 
                      role.users.add(user1)
                      
                      # first create ProjectPermission 
                      perm = ProjectPermission.objects.create(project=proj, can_review=True, role=role)
                      
                      # Now add this perm into the role:
                      role.project_permissions.add(perm)
                      
                       def review_project(request, project_id):
                          project = Project.objects.get(id=project_id)
                          if project.permissions.filter(can_review=True, role__users=request.user).exists():
                             # your code
                          else:
                             raise PermissionDenied
                      
                      class Project(models.Model):
                          title = models.CharField(max_length=255)
                       ......
                      
                      class ProjectPermission(model.Model):
                          project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='permissions')
                          role = models.ForeignKey('Role', on_delete=models.CASCADE)
                          can_add = models.BooleanField(default=False)
                          can_review = models.BooleanField(default=False)
                          .......
                      
                      class Role(models.Model):
                         name = models.CharField(max_length=50) # example Moderator etc.
                         project_permissions = models.ManyToManyField(ProjectPermission)
                         users = models.ManyToManyField(User)
                         
                      
                      #Let's create a Project instance
                      proj = Project.objects.create(title="Some Project")
                      
                      #let's create role and assign users to role: 
                      role = Role.objects.create(name='Reviewer')
                      # assign users 
                      role.users.add(user1)
                      
                      # first create ProjectPermission 
                      perm = ProjectPermission.objects.create(project=proj, can_review=True, role=role)
                      
                      # Now add this perm into the role:
                      role.project_permissions.add(perm)
                      
                       def review_project(request, project_id):
                          project = Project.objects.get(id=project_id)
                          if project.permissions.filter(can_review=True, role__users=request.user).exists():
                             # your code
                          else:
                             raise PermissionDenied
                      
                      class Project(models.Model):
                          title = models.CharField(max_length=255)
                       ......
                      
                      class ProjectPermission(model.Model):
                          project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='permissions')
                          role = models.ForeignKey('Role', on_delete=models.CASCADE)
                          can_add = models.BooleanField(default=False)
                          can_review = models.BooleanField(default=False)
                          .......
                      
                      class Role(models.Model):
                         name = models.CharField(max_length=50) # example Moderator etc.
                         project_permissions = models.ManyToManyField(ProjectPermission)
                         users = models.ManyToManyField(User)
                         
                      
                      #Let's create a Project instance
                      proj = Project.objects.create(title="Some Project")
                      
                      #let's create role and assign users to role: 
                      role = Role.objects.create(name='Reviewer')
                      # assign users 
                      role.users.add(user1)
                      
                      # first create ProjectPermission 
                      perm = ProjectPermission.objects.create(project=proj, can_review=True, role=role)
                      
                      # Now add this perm into the role:
                      role.project_permissions.add(perm)
                      
                       def review_project(request, project_id):
                          project = Project.objects.get(id=project_id)
                          if project.permissions.filter(can_review=True, role__users=request.user).exists():
                             # your code
                          else:
                             raise PermissionDenied
                      

                      wasm code commit Allocation failed - process out of memory

                      copy iconCopydownload iconDownload
                      $ node
                      
                      Welcome to Node.js v12.21.0.
                      Type ".help" for more information.
                      >
                      > process.arch
                      'arm64'
                      
                      $ nvm uninstall 14
                      $ arch -x86_64 zsh 
                      $ nvm install 14
                      $ nvm alias default 14
                      
                      $ node
                      > process.arch
                      'x64'
                      
                      $ nvm uninstall 14
                      $ arch -x86_64 zsh 
                      $ nvm install 14
                      $ nvm alias default 14
                      
                      $ node
                      > process.arch
                      'x64'
                      
                      curl -LO https://gist.githubusercontent.com/koenpunt/812953470f26b100845e2b37e1288067/raw/667daea235ac99236adb2dfa1499401358d004dd/node-14.16.0.patch
                      node-build -p 14.16.0 $(nodenv root)/versions/14.16.0 < node-14.16.0.patch
                      
                      git apply node-14.16.0.patch
                      
                      patch -p1 < node-14.16.0.patch
                      
                      curl -LO https://gist.githubusercontent.com/koenpunt/812953470f26b100845e2b37e1288067/raw/667daea235ac99236adb2dfa1499401358d004dd/node-14.16.0.patch
                      node-build -p 14.16.0 $(nodenv root)/versions/14.16.0 < node-14.16.0.patch
                      
                      git apply node-14.16.0.patch
                      
                      patch -p1 < node-14.16.0.patch
                      
                      curl -LO https://gist.githubusercontent.com/koenpunt/812953470f26b100845e2b37e1288067/raw/667daea235ac99236adb2dfa1499401358d004dd/node-14.16.0.patch
                      node-build -p 14.16.0 $(nodenv root)/versions/14.16.0 < node-14.16.0.patch
                      
                      git apply node-14.16.0.patch
                      
                      patch -p1 < node-14.16.0.patch
                      

                      Community Discussions

                      Trending Discussions on utils
                      • Compute class weight function issue in 'sklearn' library when used in 'Keras' classification (Python 3.8, only in VS code)
                      • EmbeddedKafka failing since Spring Boot 2.6.X : AccessDeniedException: ..\AppData\Local\Temp\spring.kafka*
                      • android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported
                      • Configuring compilers on Mac M1 (Big Sur, Monterey) for Rcpp and other tools
                      • Saving model on Tensorflow 2.7.0 with data augmentation layer
                      • pymongo [SSL: CERTIFICATE_VERIFY_FAILED]: certificate has expired on Mongo Atlas
                      • Vue 3: Module '&quot;../../node_modules/vue/dist/vue&quot;' has no exported member
                      • MissingPluginException(No implementation found for method Messaging#requestPermission on channel firebase_messaging
                      • How can I get notified when money has been sent to a particular Bitcoin address on a local regtest network?
                      • Not able to run git svn command in windows
                      Trending Discussions on utils

                      QUESTION

                      Compute class weight function issue in 'sklearn' library when used in 'Keras' classification (Python 3.8, only in VS code)

                      Asked 2022-Mar-27 at 23:14

                      The classifier script I wrote is working fine and recently added weight balancing to the fitting. Since I added the weight estimate function using 'sklearn' library I get the following error :

                      compute_class_weight() takes 1 positional argument but 3 were given
                      

                      This error does not make sense per documentation. The script should have three inputs but not sure why it says expecting only one variable. Full error and code information is shown below. Apparently, this is failing only in VS code. I tested in the Jupyter notebook and working fine. So it seems an issue with VS code compiler. Any one notice? ( I am using Python 3.8 with other latest other libraries)

                      from sklearn.utils import compute_class_weight
                      
                      train_classes = train_generator.classes
                      
                      class_weights = compute_class_weight(
                                                              "balanced",
                                                              np.unique(train_classes),
                                                              train_classes                                                    
                                                          )
                      class_weights = dict(zip(np.unique(train_classes), class_weights)),
                      class_weights
                      

                      In Jupyter Notebook,

                      enter image description here

                      enter image description here

                      ANSWER

                      Answered 2022-Mar-27 at 23:14

                      After spending a lot of time, this is how I fixed it. I still don't know why but when the code is modified as follows, it works fine. I got the idea after seeing this solution for a similar but slightly different issue.

                      class_weights = compute_class_weight(
                                                              class_weight = "balanced",
                                                              classes = np.unique(train_classes),
                                                              y = train_classes                                                    
                                                          )
                      class_weights = dict(zip(np.unique(train_classes), class_weights))
                      class_weights
                      

                      Source https://stackoverflow.com/questions/69783897

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install utils

                      You can download it from GitHub.
                      You can use utils like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the utils component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Share this Page

                      share link
                      Consider Popular Java Libraries
                      Try Top Libraries by areyouok
                      Compare Java Libraries with Highest Support
                      Compare Java Libraries with Highest Quality
                      Compare Java Libraries with Highest Security
                      Compare Java Libraries with Permissive License
                      Compare Java Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.