Monday, July 5, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Kubernetes environment variable for google (and facebook) identification

Posted: 05 Jul 2021 08:34 AM PDT

I try to pass one full stack application hosted in Heroku to another hosted in a kubernetes cloud (Digital Ocean exactly): I am stuck with the keys. In the original full stack application I have a file where I put the keys for development env:

module.exports={    googleClientID: 'Client ID',    googleClientSecret: 'secret sequence',    mongoURI: 'mongodb+srv://data_to_connect',    cookieKey: 'some_code',    fbClientID: 'Client ID',    fbClientSecret: 'secret sequence',    stripePublishableKey: 'public key',    stripeSecretKey: 'secret sequence'  }  

And after another file with the keys for production. In this case the secrets were put in the Heroku environment; so, this file, made public, didn´t show the secret keys.

module.exports={    googleClientID: 'Client ID',    googleClientSecret: GOOGLE_CLIENT_SECRET, // Place in Heroku host    ...  }  

Now, I try to convert this application in a kubernetes application. In the kubernetes config. file for the server, I placed the above keys as environment variables:

    apiVersion: apps/v1      kind: Deployment      metadata:        name: server-depl      ...      template:          metadata:            labels:              app: server          spec:            containers:              - name: server                image: myimage                env:                  - name: googleClientID                    value: 'Client ID' // Same that above                  - name: googleClientSecret  // Secret made with kubernetes secret generic command                    valueFrom:                      secretKeyRef:                        name: google-secret                        key: googleClientSecret                ....  

And after referencing those env. variables in the proper file with process.env.KEY, that would work in the dev. environment (with skaffold) as in production environment (digital ocean).

clientID: process.env.googleClientID,  clientSecret: process.env.googleClientSecret,  

That is not working. Some hint how to do that transfer?

FaceBook SDK - Can't get app events to log at all?

Posted: 05 Jul 2021 08:33 AM PDT

I've tried everything under the sun to get the Facebook SDK to log my app events. It appears as though everything is setup correctly, but when I go into the dev dashboard to do the events log test, nothing appears when I launch my app. Here's what I've done to set up the SDK:

1) Imported the Facebook SDK and put the appropriate code into AppDelegate:

AppDelegate.m

@import FBSDKCoreKit;  @import FBSDKLoginKit;  @import FBSDKShareKit;    @interface AppDelegate ()    @end    @implementation AppDelegate        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {                 [[FBSDKApplicationDelegate sharedInstance] application:application                                    didFinishLaunchingWithOptions:launchOptions];                    [FBSDKSettings setAdvertiserTrackingEnabled:YES];          [FBSDKSettings setAutoLogAppEventsEnabled:YES];                }            - (BOOL)application:(UIApplication *)application                  openURL:(NSURL *)url                  options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options      {        [[FBSDKApplicationDelegate sharedInstance] application:application                                                       openURL:url                                                       options:options];                   return YES;      }            - (void)applicationDidBecomeActive:(UIApplication *)application {                   [FBSDKAppEvents activateApp];            }  

2) Updated info.plist with the following information:

<key>CFBundleURLTypes</key>  <array>      <dict>          <key>CFBundleURLSchemes</key>          <array>              <string>fb0000000000</string> (my app id)          </array>      </dict>  </array>  <key>FacebookAppID</key>  <string>0000000000</string> (my app id)  <key>FacebookDisplayName</key>  <string>MyAppName</string>  <key>FacebookClientToken</key>  <string>MyAppName</string>  <key>FacebookAutoLogAppEventsEnabled</key>  <string>TRUE</string>  <key>FacebookAdvertiserIDCollectionEnabled</key>  <string>TRUE</string>  

3. Registered my app in the Facebook Business/Developer Dashboard

This is all done correctly; to confirm this, I did what facebook suggested and pasted this code into one of my View Controllers, and I'm able to 'login' and connect to FB via my app successfully.

FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];  loginButton.center = self.view.center;  [self.view addSubview:loginButton];  

Everything appears to be setup as it should be, but no matter what I do I can't get my app events to show in the Facebook events test. :/ Any help is appreciated! Thank you.

NUnit - Equal(this, that), True(this == that) or That (this, Is.EqualTo(that))?

Posted: 05 Jul 2021 08:33 AM PDT

Our house framework uses a generic class, DBField<T>, to emulate entity fields with databases that aren't compatible with Entity Framework (like, Oracle 11 or Sybase).

We're trying to make it as transparent as possible (again, like entity fields) so that the following code works:

    DBField<int?> z_intLength = 2;      while (z_intLength <= 5)      {          z_intLength++;      }        //[...]        DBField<int?> z_intMaxLength = 10;      if (z_intLength > z_intMaxLength)      {      }  

The above works nicely. We've used public static implicit operator DBField<T>(T value) and public static implicit operator T(DBField<T> value), along with overriding == and the other comparison operators, as well as implementing IEquatable<DBField<T>>, IComparable, and IComparable<DBField<T>>.

Now we're trying to put DBField<T> through NUnit tests, in which we're rather new.

Notably, we're trying our hand with various equivalents:

            string z_strComment = "Comment";              _objOrder2.OrderComment = z_strComment;                //[...]                Assert.True("Comment" == _objOrder2.OrderComment);              Assert.That("Comment", Is.EqualTo(_objOrder2.OrderComment));              Assert.That(_objOrder2.OrderComment, Is.EqualTo("Comment"));              Assert.Equals("Comment", _objOrder2.OrderComment);  

The first two assertions pass and the next two fail.

  1. There seems to be a difference in the inner workings of each assertion. Can someone explain what it is?

  2. More precisely, debugging with breakpoints seems to indicate that Assert.That("Comment", Is.EqualTo(_objOrder2.OrderComment)) tests _objOrder2.OrderComment.Equals("Comment"); I'd expect it the other way around. Am I missing something?

  3. I understand that True() and Equals() are older than That(). Which ones are preferable in which situations?

TamperMonkey: Cannot read property 'dispatchEvent' of null

Posted: 05 Jul 2021 08:33 AM PDT

New to javascript here, I am messing around with using a gamepad while browsing (using gamepad API and TamperMonkey) and I am having trouble simulating to click a certain (x,y) coordinate on the screen. It reports "Cannot read property 'dispatchEvent' of null" and even when I console log my element inside the click function, it returns null.

(function() {      'use strict';        const rAF = window.mozRequestAnimationFrame || window.requestAnimationFrame;        window.addEventListener("gamepadconnected", (event) => {          console.log("A gamepad connected:");          console.log(event.gamepad);      });        window.addEventListener("gamepaddisconnected", (event) => {          console.log("A gamepad disconnected:");          console.log(event.gamepad);      });            window.addEventListener('gamepadconnected',function(e) {          updateLoop();      })        function updateLoop() {          if(navigator.getGamepads) {              var gp = navigator.getGamepads()[0];            }            const xboxButtonB = gp.buttons[1];          const xboxButtonA = gp.buttons[0];                      if (xboxButtonA.pressed) {              console.log('a pressed');              click(1200,500);            }            if (xboxButtonB.pressed) {              console.log('b pressed')              click(700,500);          }            setTimeout(function () {              rAF(updateLoop);          }, 150);      }              function click(x, y){          var ev = new MouseEvent('click', {                  'view': window,                  'bubbles': true,                  'cancelable': true,                  'screenX': x,                  'screenY': y              });                var el = document.elementFromPoint(x, y);              console.log(el); //print element to console              el.dispatchEvent(ev);      }    })();  

Admo banner Ads Waring : Type mismatch: inferred type is AdListener? but AdListener was expected

Posted: 05 Jul 2021 08:33 AM PDT

this is the code here is the problem that is showing me when i build tha app. The ads appear but it is causing me invalid traffic i think. This is the waring i get when i build the app Admo banner Ads Waring : Type mismatch: inferred type is AdListener? but AdListener was expected

package com.ixidev.smarttvapp.ads

import android.content.Context  import android.widget.FrameLayout  import androidx.annotation.RequiresPermission  import androidx.core.view.isVisible  import com.google.android.gms.ads.AdListener  import com.google.android.gms.ads.AdRequest  import com.google.android.gms.ads.AdSize  import com.google.android.gms.ads.AdView  import com.ixidev.adstoolkit.core.IBannerAd    /**   * Created by ABDELMAJID ID ALI on 3/22/21.   * Email : abdelmajid.idali@gmail.com   * Github : https://github.com/ixiDev   */  class SmartBannerAd(private val adRequest: AdRequest.Builder) : IBannerAd {        private var _bannerAd: AdView? = null      private val bannerAd: AdView          get() = _bannerAd!!        var bannerClickListener: OnBannerClickListener? = null        private var adListener: AdListener? = null        @RequiresPermission("android.permission.INTERNET")      override fun load(context: Context, adId: String) {          if (_bannerAd == null) {              _bannerAd = AdView(context).apply {                  adUnitId = adId                  adSize = AdSize.BANNER              }          }            bannerAd.loadAd(adRequest.build())//adrequest      }        override fun render(container: FrameLayout) {          container.removeAllViews()          container.addView(bannerAd)          container.isVisible = false          adListener = object : AdListener() {              override fun onAdLoaded() {                  container.isVisible = true              }                override fun onAdClicked() {                  bannerClickListener?.onBannerClick()              }              }          bannerAd.adListener = this.adListener -> here is the waring      }        override fun destroy() {          _bannerAd?.adListener = null ---> and here          _bannerAd?.removeAllViews()// check here you are destorying here. send me code let fix this. and create milestone ok lest do this          _bannerAd?.destroy()          _bannerAd = null          bannerClickListener = null          adListener = null      }        override fun onPause() {          _bannerAd?.pause()      }        override fun onResume() {          _bannerAd?.resume()      }        interface OnBannerClickListener {          fun onBannerClick()      }  }  

SSH To server connecting [closed]

Posted: 05 Jul 2021 08:33 AM PDT

저는 GCP를 배우고 있는 초보생 입니다 막히는 부분이 있어 알고자 합니다. 지금현재 gcp에서 ssh연결이 안돱니다 Vm instance에사 ssh를 열려고 하는데 에러가 납니다 그리고 Termius등 외부앱에서 ssh로 연결하는것도 권한이 없다고 연결이 안됩니까 다른곳에서는 호스트 name을 vm instance에서 알수가 있는데 GCP애서는 그것을 알수가 없습니다 그래서 혼란이 있어 외부app에서 GCP를 이용할수 없습니다 원인이 무엇때문인지 알수가 없어 server을 활용할수가 없읍니다 저는 자금 서버의 command screen을 볼수가 없읍니다 기존의 질문의 해결이 안됩니다

typeorm returning 1 always on count distinct mysql

Posted: 05 Jul 2021 08:33 AM PDT

I have two tables and 1 compound table: Users, Cars and userCars

Users entity:

 id: int;   name: nvarchar(25);  

Cars entity:

id: int;  carName: nvarchar(25)  

and finally, userCars entity:

carID: int,  userID: int  

I am trying to find the number of users that have a specific car, here's my attempt:

const carsRepo = getRepository(Car);      const query = carsRepo        .createQueryBuilder('car')        .select('DISTINCT user.id')        .innerJoin('userCars', 'uc')        .innerJoin('user', 'u')        .where('car.id = 'exampleidhere' )        .andWhere('car.id = uc.carID')        .andWhere('u.id = uc.userID')        .getCount()  

It is always returning "1" for some reason. I have spent hours trying to figure out why and I wasn't able to, even converted it to sql and in mysql the output was right.

Creating organic shape in grasshopper and rhino

Posted: 05 Jul 2021 08:33 AM PDT

I am relatively new to rhino and grasshopper but have knowledge about 3d objects from some years in blender. I need to create an organic shape that looks something like the pictures at the bottom (Especially the first one and also that last one). It is very important to me that it is tileable and 3d. I found some tutorials, but it's never something that really looks how I want it to. I thought about creating it somehow with a physics plugin like kangoroo but I don't know how. Also the repeating, tileable method would be hard there. I also thought about not even using grasshopper but creating that stylie with a subsurf. But It might not be the same.

I wanted to ask, if someone knows how to create such a pattern, and what way you would approach it. Do you have a tutorial or a script you could share with me ? Maybe also a website where part of it gets explained and I can read myself into it. Or maybe you could give me a rough node setup and I go step for step through it to understand it. I would be very grateful. And I would appreciate it alot. Thanks in advance!

enter image description here

enter image description here

enter image description here

enter image description here

Cannot run unittest in PyCharm

Posted: 05 Jul 2021 08:32 AM PDT

When I try to run a unittest with PyCharm I have an error that I didn't manage to solve :

python3.6: No module named _jb_unittest_runner

My test module looks like (in a folder with init.py):

import unittest    class MyTest(unittest.TestCase):            def test(self):          self.assertEqual(True, True)      

I found no information about this module and how to install it.

Do you know what am I doing wrong ?

Thanks a lot !

Failed registration with firebase user Android Studio

Posted: 05 Jul 2021 08:32 AM PDT

I was following a tutorial on Android and Firebase to create an user but whenever I click on the button to register the execption message gives me this: "This email is already used by another account". I've tried everything, I've also added the possibility to have multiple account with the same emails but it didn't work. (Also tried downgrading my API to 29 but still no working)

Here my code:

Registration Activity

FirebaseAuth mAuth;    private EditText email_input;  private EditText password_input;  private EditText username_input;    @Override  protected void onCreate(Bundle savedInstanceState) {      super.onCreate(savedInstanceState);      setContentView(R.layout.activity_register);          mAuth = FirebaseAuth.getInstance();        email_input = findViewById(R.id.email_box_register);      password_input = findViewById(R.id.password_box_register);      username_input = findViewById(R.id.username_box_register);        registrati = findViewById(R.id.registrati_button);      registrati.setOnClickListener(this);  }      private void registration() {      String email = email_input.getText().toString().trim();      String password = password_input.getText().toString().trim();      String username = username_input.getText().toString().trim();          if (username.isEmpty()) {          username_input.setError("Username necessario");          username_input.requestFocus();          return;      }        if (email.isEmpty()) {          email_input.setError("Email necessaria");          email_input.requestFocus();          return;      }        if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {          email_input.setError("Email non valida");          email_input.requestFocus();          return;      }        if (password.isEmpty()) {          password_input.setError("Password necessaria");          password_input.requestFocus();          return;      }          if (password.length() < 6) {          password_input.setError("Inferiore a 6");          password_input.requestFocus();          return;      }        mAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {          @Override          public void onComplete(@NonNull Task<AuthResult> task) {                if(task.isSuccessful()){                  User user = new User(username, email, password);                    FirebaseDatabase.getInstance().getReference("Users")                          .child(FirebaseAuth.getInstance().getCurrentUser().getUid())                          .setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {                      @Override                      public void onComplete(@NonNull Task<Void> task) {                          if(task.isSuccessful()){                              Toast.makeText(getApplicationContext(),"Success", Toast.LENGTH_SHORT).show();                              Intent welcome = new Intent(getApplicationContext(), LoginActivity.class);                              startActivity(welcome);                              overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);                              finish();                          }else{                              Toast.makeText(getApplicationContext(),"Failed", Toast.LENGTH_SHORT).show();                          }                      }                  });              }else{                  Toast.makeText(getApplicationContext(),"Registration failed", Toast.LENGTH_SHORT).show();              }              }      });        }    @Override  public void onClick(View v) {      if (v.getId() == R.id.registrati_button) {          registration();      }  }"""  

And here my gradle file

android { compileSdkVersion 29 buildToolsVersion "30.0.3"

defaultConfig {      applicationId "com.example.fly"      minSdkVersion 16      targetSdkVersion 29      versionCode 1      versionName "1.0"        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  }    buildTypes {      release {          minifyEnabled false          proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'      }  }  compileOptions {      sourceCompatibility JavaVersion.VERSION_1_8      targetCompatibility JavaVersion.VERSION_1_8  }  buildFeatures {      viewBinding true  }  

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.3.0'  implementation 'com.google.android.material:material:1.4.0'  implementation 'com.google.android.gms:play-services-maps:17.0.1'  implementation 'androidx.constraintlayout:constraintlayout:2.0.4'  implementation 'com.google.firebase:firebase-auth:21.0.1'  implementation 'com.google.firebase:firebase-database:20.0.0'  testImplementation 'junit:junit:4.13.2'  androidTestImplementation 'androidx.test.ext:junit:1.1.3'  androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'  

}"""

How to enable again the tooltip/hint in VSC?

Posted: 05 Jul 2021 08:32 AM PDT

My VSC does show the wavy underlines when something's wrong with my code, but does not display the hint overlay when I hover my mouse on it.

This happens whatever the language used (from CSS to Typescript) and whatever the error (e.g. notice, warn, danger)

Nothing shows up when hovering the wavy error

I'd say that's a setting I may have changed at some point, but can't find which one. Please note that there is almost no extensions in my setup who could have messed with this behavior.

How to create a time range with minutes?

Posted: 05 Jul 2021 08:34 AM PDT

I have this code that returns a range of times (between two TimeSpan ) :

      public static IEnumerable<TimeSpan> Range(TimeSpan start, TimeSpan end)          {              for (var dt = start; dt <= end; dt = dt.Add(new TimeSpan(1,0,0)))              {                      yield return dt;                    }          }          // As an example       TimeSpan start = new TimeSpan(09,0,0);       TimeSpan end = new TimeSpan(12,0,0);       var range = Range(start.Ticks,end.Ticks);  

It will return this :

09:00:00  10:00:00  11:00:00  12:00:00  

What I would like to return is a time range ( list of TimeSpan with minutes ):

Expected result:

09:00:00  09:01:00  09:02:00  09:03:00    ...  11:59:00  12:00:00  

How can I do this work?

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf1 in position 5: invalid continuation byte (On Python 3)

Posted: 05 Jul 2021 08:34 AM PDT

I am trying to import a csv file using Python and getting the following error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf1 in position 5: invalid continuation byte

During handling of the above exception, another exception occurred:        UnicodeDecodeError Traceback (most recent call last)  <ipython-input-2-975331fc3025> in <module>        1 # Read in the data  ----> 2 df = pd.read_csv('movies.csv')  

This is my code:

# Import libraries    import pandas as pd    import seaborn as sns  import matplotlib  import matplotlib.pyplot as plt  plt.style.use('ggplot')  from matplotlib.pyplot import figure  %matplotlib inline  matplotlib.rcParams['figure.figsize'] = (12,8) # Adjust the configuration of the plots we will create    df = pd.read_csv('movies.csv')  

Is no-data-found exception not raised implicitly?

Posted: 05 Jul 2021 08:33 AM PDT

question 1: I noticed the no-data-found exception not raised implicitly, do we need to raise them manually/explicitly?

Question 2:

I writing a SP package with 4 procedures in it and i'm writing below procedures on a single table.

the exception handling is repetitive in each procedure. is there any guidance/coding standard to keep it in a single place procedure#5 or function and call it there.

Select Update Insert Delete I guess if I keep it in a function it would raise the exception and return to the called procedure and continue to run ? but when we raise a exception the program should stop , right?

How to use Bitnami/moodle for DSM7 in Synology?

Posted: 05 Jul 2021 08:34 AM PDT

  1. DSM7 of Synology does not allow moodle, which I have to use heavily for my classes.
  2. I'm going to implement moodle in Synology NAS (DS918+) by the docker bitnami containers.
  3. The following is the docker-compose.yml, modified from the original bitnami/moodle.
version: '2'    services:    mariadb:      image: 'bitnami/mariadb:latest'      container_name: mariadb      environment:        MARIADB_ROOT_PASSWORD: 1111        MARIADBL_DATABASE: moodle        MARIADB_USER: moodle        MARIADB_PASSWORD: 1234      volumes:        - /volume2/db_maria:/var/lib/mysql      moodle:      image: 'bitnami/moodle:latest'      container_name: moodle      environment:        MOODLE_USERNAME: user        MOODLE_PASSWORD: 12345678        MARIADB_HOST: mariadb        MARIADB_PORT_NUMBER: 3306        MOODLE_DATABASE_USER: moodle        MOODLE_DATABASE_NAME: moodle        MOODLE_DATABASE_PASSWORD: 1234      ports:        - '8880:8080'        - '8443:8443'      volumes:        - /volume2/db_moodle:/bitnami      depends_on:        - mariadb    volumes:    mariadb_data:      driver: local    moodle_data:      driver: local  
  1. The following is the response of "docker-compose up".
Creating network "workmoodle_default" with the default driver  Creating mariadb ... done  Creating moodle  ... done  Attaching to mariadb, moodle  mariadb    | mariadb 15:31:26.58  mariadb    | mariadb 15:31:26.58 Welcome to the Bitnami mariadb container  mariadb    | mariadb 15:31:26.59 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-mariadb  mariadb    | mariadb 15:31:26.59 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-mariadb/issues  mariadb    | mariadb 15:31:26.60  mariadb    | mariadb 15:31:26.60 INFO  ==> ** Starting MariaDB setup **  mariadb    | mariadb 15:31:26.81 INFO  ==> Validating settings in MYSQL_*/MARIADB_* env vars  moodle     | moodle 15:31:29.97  mariadb    | mariadb 15:31:26.98 INFO  ==> Initializing mariadb database  mariadb    | mariadb 15:31:27.07 INFO  ==> Updating 'my.cnf' with custom configuration  mariadb    | mariadb 15:31:27.46 INFO  ==> Setting user option  moodle     | moodle 15:31:29.98 Welcome to the Bitnami moodle container  moodle     | moodle 15:31:29.98 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-moodle  moodle     | moodle 15:31:29.98 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-moodle/issues  moodle     | moodle 15:31:29.99  moodle     | moodle 15:31:29.99 INFO  ==> ** Starting Moodle setup **  mariadb    | mariadb 15:31:27.85 INFO  ==> Installing database  moodle     | moodle 15:31:31.19 INFO  ==> Configuring PHP options  moodle     | moodle 15:31:31.35 INFO  ==> Validating settings in MYSQL_CLIENT_* env vars  moodle     | moodle 15:31:33.13 INFO  ==> Ensuring Moodle directories exist  moodle     | moodle 15:31:33.65 INFO  ==> Trying to connect to the database server  mariadb    | mariadb 15:31:42.21 INFO  ==> Starting mariadb in background  mariadb    | mariadb 15:31:44.30 INFO  ==> Configuring authentication  mariadb    | mariadb 15:31:44.89 INFO  ==> Running mysql_upgrade  moodle     | moodle 15:32:35.63 ERROR ==> Could not connect to the database  moodle exited with code 1  mariadb    | mariadb 15:32:44.73 INFO  ==> Stopping mariadb  mariadb    | mariadb 15:32:47.80 INFO  ==> ** MariaDB setup finished! **  mariadb    |  mariadb    | mariadb 15:32:47.91 INFO  ==> ** Starting MariaDB **  mariadb    | 2021-07-05 15:32:47 0 [Note] /opt/bitnami/mariadb/sbin/mysqld (mysqld 10.5.11-MariaDB) starting as process 1 ...  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Uses event mutexes  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Compressed tables use zlib 1.2.11  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Number of pools: 1  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions  mariadb    | 2021-07-05 15:32:48 0 [Note] mysqld: O_TMPFILE is not supported on /opt/bitnami/mariadb/tmp (disabling future attempts)  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Using Linux native AIO  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Completed initialization of buffer pool  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: 128 rollback segments are active.  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Creating shared tablespace for temporary tables  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: 10.5.11 started; log sequence number 45118; transaction id 20  mariadb    | 2021-07-05 15:32:48 0 [Note] Plugin 'FEEDBACK' is disabled.  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Loading buffer pool(s) from /bitnami/mariadb/data/ib_buffer_pool  mariadb    | 2021-07-05 15:32:48 0 [Note] Server socket created on IP: '0.0.0.0'.  mariadb    | 2021-07-05 15:32:48 0 [Note] InnoDB: Buffer pool(s) load completed at 210705 15:32:48  mariadb    | 2021-07-05 15:32:48 0 [Warning] 'proxies_priv' entry '@% root@0f1c8913df83' ignored in --skip-name-resolve mode.  mariadb    | 2021-07-05 15:32:48 0 [Note] Reading of all Master_info entries succeeded  mariadb    | 2021-07-05 15:32:48 0 [Note] Added new Master_info '' to hash table  mariadb    | 2021-07-05 15:32:48 0 [Note] /opt/bitnami/mariadb/sbin/mysqld: ready for connections.  mariadb    | Version: '10.5.11-MariaDB'  socket: '/opt/bitnami/mariadb/tmp/mysql.sock'  port: 3306  Source distribution    
  1. What is the problem with my code? The mariadb seems to be working but moodle cannot access it.
  2. Thanks in advance for your guide.

How to pass parameter message as text in openpgp JS

Posted: 05 Jul 2021 08:34 AM PDT

What I'm trying to do:

  • get some Azure storage blobs from container DIDE and encrypt them with RSA 2048 and upload them in other container called encrypted-dide These blobs are downloaded through a stream(here Microsoft did a good job https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-nodejs#upload-blobs-to-a-container) and recomposed by func. streamToString(readableStream) (I'm not using openpgp JS streams as I don't know if Microsoft streams are the same with NodeJs ones)
  • My code works as expected with unecrypted text and upload blobs in the supposedly encryped container encrypted-dide
  • I have followed the official documentation of openpgp js and some Internet resources.
  • The error I am getting is Error: Parameter [message] needs to be of type Message in openpgp JS

the publicKey is harcoded in the file keys.js and and is exported like this:

const publicKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----    xsBNBGDgi3gBCADcZqIcczPDAx3+os5cCFVgaoT62Y+5rRvwPGPaPKKA1ajw  7NvoxS0RsJbqYAwNk0IEneoZvgSPpqkehGQCOBdsEhjcEgxVxaSlbbgPJkPh  avjTBDUhr6pIUc+MkSX7eh5LdkgWRSfzZdLXX2es5ycM5R1ZryzPTAenZh7D  l1g1x9TsyX+scI7gAtuyfbzAybYVqYMIvcHYZdIi8m6pGmxIqb0QW6sgO6nG  GyjVgxLDyMnHzYMInFRmKUV8XUUw9ECLZ6ioW4rthmpjoswh9vmP6vWI9OL/  Y7Zb3xY5XnIT6UFSpAHS5V/TNbEUD/EpoNtEI30bUl2X35UM277fUxetABEB  AAHNG0pvbiBTbWl0aCA8am9uQGV4YW1wbGUuY29tPsLAigQQAQgAHQUCYOCL  eAQLCQcIAxUICgQWAAIBAhkBAhsDAh4BACEJEGHAYnRSOf5GFiEExGMJvxnV  v1dXecI0YcBidFI5/kY5PAgAxL10QcUZIrxRXQIrqk04ZDhO4ehMirPqH/KT  L/MeHppHFqV06Fm4JDAOpGyh8lgleLwP4P9Lrod3AVSOKSX48u+UM/Bo4LtG  foAntS+tC9RjWlpR6PZ0aJA8SqHKLCnkaUvz7wv/M55fgGxeeQbhOLutNxN4  L8rCNhPo3UbWwoB+ifgQ9S4bv4kgyJxXYinyGYG0CD67YxQKxiAt58qjsdmK  x4uKCoFbHd1Oa4wfr6ezXet+2hCQvsf8eJV88+qL7TmpSe3ypiTWHNgxymNx  v77SlOkkzayJVWxrWtFU8ZoatlsfOP3A5tToio2rEhCHcnqYl4KtF1a0WUR8  KG+pJc7ATQRg4It4AQgA0Q2uZL9TIqGWtNzeAygdG0C3o+D+MoEYI/Qx0A6X  aZv7/1v84V++lRD0iuIMUlBgFEJWMsHF7cN1EMlUV1lRxOzyKTv+0FqyoSTr  bWexA+jG/Nb3Q8vSX1+eVHvm1+2H7AGhBH2szVmXeH15bGNaOaw03EmG5pCh  CIaCoXYUXKoavsa+C8827lGSuqLs1uRniCmIjQvkQSZg7a0IH6dpMIpxdHPh  h9Zyt8e74WwfmXW/be6cjWRI9FgBzl9U5EQEEVO1JdLvfzEEXkNthyAAhl+P  Z1oTR2PSs4ZUlYdb3MQrt7XoKeEOqCHHxoHB3gsj+75Jnc/aAbM+hb13imAJ  iwARAQABwsB2BBgBCAAJBQJg4It4AhsMACEJEGHAYnRSOf5GFiEExGMJvxnV  v1dXecI0YcBidFI5/kZYSQgAop0OsPV11O/fzbZ+oEabC3Ye9hNGapJQNdmJ  MJkiJg7Hnl1FO4MDtHK5OJ4YePFAqtlKRDIBCALPiN0E2v9+3yAafs6TQDc9  Lg3iIPDOnrXv7J7pv2WPnnue4o8Gkggpa+wEjbQJcUBLX311xJGBG4pSNIVN  FJcsl1fGoaxXB5ANPy/+UNMv0l/7cQWDzSw8V9WH10SO2Q4dQF7Zxw+UgBdb  mRVXWNHkcTs81WA/hYtAuLw0O5Q1QWfbXzlTJGNPy/lMMsxLF6La8fBPHlE0  CjYd4ZH9HgOvpCACjRtbc1jywaZJEisO2aJcO2BaozSzYUmkr5sH2wjSKcMS  nLviCw==  =Wg0i  -----END PGP PUBLIC KEY BLOCK-----`  
  • The code is:
const { BlobServiceClient } = require('@azure/storage-blob');  // const { v1: uuidv1 } = require('uuid');  // const stream = require('stream').promises  const openpgp = require('openpgp');  // import * as openpgp from 'openpgp'  const { publicKey } = require('./keys')            async function main() {       const AZURE_STORAGE_CONNECTION_STRING = process.env.AZURE_STORAGE_CONNECTION_STRING;     const blobServiceClient = BlobServiceClient.fromConnectionString(AZURE_STORAGE_CONNECTION_STRING);     const containerClient = blobServiceClient.getContainerClient("uploadebs");     const containerEncryptedFiles = blobServiceClient.getContainerClient("encrypted-dide");     await containerEncryptedFiles.createIfNotExists("encrypted-dide")          // console.log(await openpgp.readKey({ armoredKey: publicKey })) <- THIS WORKS!     for await (const blob of containerClient.listBlobsFlat()) {           if (blob.name.match('^DIDE*')) {             const blockBlobClient = containerClient.getBlockBlobClient(blob.name);             const encryptedblockBlobClient = containerEncryptedFiles.getBlockBlobClient(blob.name)             blockBlobClient.download(0)             .then(downloadBlockBlobResponse => streamToString(downloadBlockBlobResponse.readableStreamBody))             .then(blobAsString => openpgp.encrypt({                     message:  openpgp.createMessage({ text: blobAsString }), // input as Message object                     publicKeys: openpgp.readKey({ armoredKey: publicKey }),                                       }))              // BELOW LINE, SENDS TEXT IN BLOBS, ENCRYPTED OR NOT THROUGH FUNC UPLOAD             .then(encrypted => {encryptedblockBlobClient.upload(encrypted, encrypted.length)})         }     }    }    async function streamToString(readableStream) {          return new Promise((resolve, reject) => {         const chunks = [];         readableStream.on("data", (data) => {             chunks.push(data.toString());         });           readableStream.on("end", () => {             resolve(chunks.join(""));         });         readableStream.on("error", reject);     });  }    main().then(() => console.log('Done')).catch((ex) => console.log(ex.message));  

white page of mern application react deployed with heroku

Posted: 05 Jul 2021 08:33 AM PDT

My project reactjs in the same project part backend and frontend. I deploy My website in heroku but i have a blank page with no content. And this is the link of the website https://websiteinspire.herokuapp.com/ package.js part client

 { "name": "inspire-training-center-app",    "version": "1.0.0",    "description": "Web Site Inspire Training Center",    "keywords": [],    "homepage": ".",    "private": true,    "proxy": "http://localhost:5000",    "main": "src/index.js",  }  

server.js

if (process.env.NODE_ENV === 'production') {             app.use(express.static(path.join(__dirname, './client/build')));    app.get('*', (req, res) => {      res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));    });  }  

package.js server

 "scripts": {          "build": "cd client && npm run build",          "install-client": "cd client && npm install",          "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm run install-client && npm run build",          "start": "node server.js",          "client": "cd client && npm start",          "dev": "concurrently \"nodemon server.js\" \"npm run client\""        },  

My log :

2021-07-05T14:08:42.000000+00:00 app[api]: Build started by user maktabanour100@gmail.com  2021-07-05T14:10:33.071974+00:00 app[api]: Release v6 created by user maktabanour100@gmail.com  2021-07-05T14:10:33.071974+00:00 app[api]: Deploy 91245125 by user maktabanour100@gmail.com  2021-07-05T14:10:34.000000+00:00 app[api]: Build succeeded  2021-07-05T14:10:35.241895+00:00 heroku[web.1]: Restarting  2021-07-05T14:10:35.282908+00:00 heroku[web.1]: State changed from up to starting  2021-07-05T14:10:36.894188+00:00 heroku[web.1]: Stopping all processes with SIGTERM  2021-07-05T14:10:37.157140+00:00 heroku[web.1]: Process exited with status 143  2021-07-05T14:10:47.136868+00:00 heroku[web.1]: Starting process with command `node server.js`  2021-07-05T14:10:50.116461+00:00 app[web.1]: server is running on port 25624  2021-07-05T14:10:50.694685+00:00 heroku[web.1]: State changed from starting to up  2021-07-05T14:10:50.999920+00:00 app[web.1]: Database connection successful  2021-07-05T14:13:33.577551+00:00 heroku[router]: at=info method=GET path="/"  

VueJS Reference to list

Posted: 05 Jul 2021 08:33 AM PDT

I just want to reference my timer to a list

<div class="row row-cols-2 justify-content-md-center" v-else-if="timerData.length <= 4" style="height: 100vh; background: none">    <div v-for="(t, index) in timerData" :key="t.name" class="col">      <timer         :name="t.name"        :start="t.start"        :index="index"        ref="timers"/> // It overwrite the old component    </div>  </div>  

I want to access like this:

this.$refs.timers.foreach(e => {    e.foo()  })  

C# Core MVC Razor Duplicate Fields AutoFill/Complete

Posted: 05 Jul 2021 08:33 AM PDT

I have a page in my C# Core project (MVC using Razor Pages) that I have duplicate types of information. In this case it is a Model that contains both delivery address information and also billing address information. So my model looks like this:

    [Display(Name = "Name")]      [Required(ErrorMessage = "Required")]      public string BillingName { get; set; }        [Display(Name = "Address Line 1")]      [Required(ErrorMessage = "Required")]      public string BillingAddress1 { get; set; }        [Display(Name = "Address Line 2")]      public string BillingAddress2 { get; set; }        [Display(Name = "Town")]      [Required(ErrorMessage = "Required")]      public string BillingTown { get; set; }        [Display(Name = "County")]      public string BillingCounty { get; set; }        [Display(Name = "Postcode")]      [Required(ErrorMessage = "Required")]      public string BillingPostCode { get; set; }        [Display(Name = "Name")]      [Required(ErrorMessage = "Required")]      public string DeliveryName { get; set; }        [Display(Name = "Address Line 1")]      [Required(ErrorMessage = "Required")]      public string DeliveryAddress1 { get; set; }        [Display(Name = "Address Line 2")]      public string DeliveryAddress2 { get; set; }        [Display(Name = "Town")]      [Required(ErrorMessage = "Required")]      public string DeliveryTown { get; set; }        [Display(Name = "County")]      public string DeliveryCounty { get; set; }        [Display(Name = "Postcode")]      [Required(ErrorMessage = "Required")]      public string DeliveryPostCode { get; set; }  

So when I render this on the page using

<input asp-for="BillingName " class="form-control" />  

It renders the input fields fine and their corresponding id and name would be (in this case) BillingName.

<input class="form-control" type="text" data-val="true" data-val-required="Required" id="BillingName" name="BillingName" value="">  

This is fine, but I need the chrome auto-fill / auto-complete to try and fill this BillingName with their Name. But because the field has an id and name of BillingName, Chrome knows nothing about this.

Is there a way to have the id="BillingName" and the name="Name"? So I could then have another field: id="DeliveryName" and the name="Name"

But, I need the model binding to still work to the ID when the form is posted back.

Any advice please?

Thank you.

Navbar covers my text when in mobile mode

Posted: 05 Jul 2021 08:34 AM PDT

So my issue is when in mobile mode my navbar covers my page context. In other words parts of my text box that is on the page hides under the navbar.

My navbar CSS looks like this:

.navbar {      background: linear-gradient(90deg, rgb(28, 27, 27) 0%, rgb(26, 23, 23) 100%);      height: 80px;      display: flex;      justify-content: center;      align-items: center;      font-size: 1.2rem;      position: sticky;      top: 0;      z-index: 999;    }        .navbar-container {      display: flex;      justify-content: center;      align-items: center;      height: 80px;      max-width: 1500px;    }        .navbar-logo {      color: #fff;      justify-self: start;      margin-left: 20px;      cursor: pointer;      text-decoration: none;      font-size: 2rem;      display: flex;      align-items: center;    }        .fa-typo3 {      margin-left: 0.5rem;      font-size: 1.8rem;    }        .nav-menu {      display: grid;      grid-template-columns: repeat(5, auto);      grid-gap: 10px;      list-style: none;      text-align: center;      width: 60vw;      justify-content: end;      margin-right: 2rem;    }        .nav-item {      height: 80px;    }        .nav-links {      color: #fff;      display: flex;      align-items: center;      text-decoration: none;      padding: 0.5rem 1rem;      height: 100%;    }        .nav-links:hover {      border-bottom: 4px solid #fff;      transition: all 0.2s ease-out;    }        .fa-bars {      color: #fff;    }        .nav-links-mobile {      display: none;    }        .menu-icon {      display: none;    }        @media screen and (max-width: 960px) {      .NavbarItems {        position: relative;      }            .nav-menu {        display: flex;        flex-direction: column;        width: 100%;        height: 90vh;        position: absolute;        top: 80px;        left: -100%;        opacity: 1;        transition: all 0.5s ease;      }          .nav-menu.active {        background: #242222;        left: 0;        opacity: 1;        transition: all 0.5s ease;        z-index: 1;      }          .nav-links {        text-align: center;        padding: 2rem;        width: 100%;        display: table;      }          .nav-links:hover {        background-color: #fff;        color: #242424;        border-radius: 0;      }          .navbar-logo {        position: absolute;        top: 0;        left: 0;        transform: translate(25%, 50%);      }          .menu-icon {        display: block;        position: absolute;        top: 0;        right: 0;        transform: translate(-100%, 60%);        font-size: 1.8rem;        cursor: pointer;      }          .fa-times {        color: #fff;        font-size: 2rem;      }          .nav-links-mobile {        display: block;        text-align: center;        margin: 2rem auto;        border-radius: 4px;        width: 80%;        text-decoration: none;        font-size: 1.5rem;        background-color: transparent;        color: #fff;        padding: 14px 20px;        border: 1px solid #fff;        transition: all 0.3s ease-out;      }          .nav-links-mobile:hover {        background: #fff;        color: #242424;        transition: 250ms;      }    }  

how can i stop this from happening ? The navbar works fine when its not in mobile mode. Ill also add a picture to make it simple to see. enter image description here

Why Assembly Doesn't Support Memory to Memory opcodes?

Posted: 05 Jul 2021 08:32 AM PDT

In assembly commands like mov can't run between two memory addresses, why is that?

It's allowed to do mov from a memory to register so what's the problem of doing so from memory to memory Instead of using the register as middle stage (thus running slower)?

If the reason is that reading from memory is slow and we can run some middle code while running this then we can use interrupts just like what's used for reading/writing from hard disks.

Why are the output results different?

Posted: 05 Jul 2021 08:33 AM PDT

async function fn1() {    return 1  }  async function fn2() {    return Promise.resolve(1)  }    function fn3() {    return Promise.resolve(1)  }    function fn4() {    return Promise.resolve(Promise.resolve(1))  }  console.log(fn1()); //Promise {<fulfilled>: 1}  console.log(fn2()); // Promise {<pending>}  console.log(fn3()); // Promise {<fulfilled>: 1}  console.log(fn4()); // Promise {<fulfilled>: 1}

When I run fn2(), it outputs Promise { pending }.

Why is fn2() Promise { pending } rather than Promise {fulfilled: 1}?

Confused about golang slice cap

Posted: 05 Jul 2021 08:34 AM PDT

i have a question about slice cap,the code:

var slice []int  list := []int{1,2,3,4,5}  for _,item := range list {      slice = append(slice, item)  }  fmt.Println(len(slice),cap(slice))  

if item == 1: len(slice)=1,cap(slice)=1

if item == 2: len(slice)=2,cap(slice)= 1*2

if item ==3: len(slice) = 3,cap(slice) = 2*2

if item == 4:len(slice) = 4,cap(slice) = 4

if item == 5:len(slice) = 5,cap(slice) = 4*2

so the output:

len(slice) = 5,cap(slice) = 8

that's no problem,but when i change the code:

var slice []int  slice = append(slice,1,2,3,4,5)  fmt.Println(len(slice),cap(slice))  

output:

len(slice) = 5,cap(slice) = 6

why cap(slice) = 6 ?

How to extract only certain fields from CSVTOJSON in nodejs?

Posted: 05 Jul 2021 08:34 AM PDT

I have managed to convert CSV data to JSON using the csvtojson npm package and successfully display it in the console.

csvtojson()        .fromFile(csvFilePath)        .then(jsonObj => {          console.log(jsonObj);        })      [    {      id: '1',      title: 'Fjallraven - Foldsack No. 1 Backpack, Fits 15 Laptops',      price: '109.95',      description: 'Your perfect pack for everyday use and walks in the forest. Stash your laptop (up to 15 inches) in the padded sleeve, your everyday',      category: 'men clothing',      image: 'https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg'    }  ]  

Now I want to console log only the id and title field, how should I go about it? Many thanks in advance and greatly appreciate any helps. Thanks again

SockJS increase pool size

Posted: 05 Jul 2021 08:33 AM PDT

I am using SocketJS and Stomp to send files over a backend api for being process. My problem is that the upload function get stuck if more than two upload are done at the same time.

Ex:

  • User 1 -> upload a file -> backend is receiving correctly the file
  • User 2 -> upload a file -> backend is receiving correctly the file
  • User 3 -> upload a file -> the backend is not called until one of the previous upload hasn't completed.

(after a minute User 1 complete its upload and the third upload starts)

The error I can see through the log is the following:

2021-06-28 09:43:34,884 INFO  [MessageBroker-1] org.springframework.web.socket.config.WebSocketMessageBrokerStats.lambda$initLoggingTask$0: WebSocketSession[11 current WS(5)-HttpStream(6)-HttpPoll(0), 372 total, 26 closed abnormally (26 connect failure, 0 send limit, 16 transport error)], stompSubProtocol[processed CONNECT(302)-CONNECTED(221)-DISCONNECT(0)], stompBrokerRelay[null], **inboundChannel[pool size = 2, active threads = 2**, queued tasks = 263, completed tasks = 4481], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 607], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 14, completed tasks = 581444]  

It seems clear that the pool size is full:

inboundChannel[pool size = 2, active threads = 2

but I really cannot find a way to increase the size.

This is the code:

Client side

ws = new SockJS(host + "/createTender");  stompClient = Stomp.over(ws);  

Server side configuration

@EnableWebSocketMessageBroker  public class WebSocketBrokerConfig extends AbstractWebSocketMessageBrokerConfigurer {        ...      ...        @Override      public void configureWebSocketTransport(WebSocketTransportRegistration registration) {          registration.setMessageSizeLimit(100240 * 10240);          registration.setSendBufferSizeLimit(100240 * 10240);          registration.setSendTimeLimit(20000);      }  

I've already tried with changing the configureWebSocketTransport parameters but it did not work. How can I increase the pool size of the socket?

Socks5 Proxy Configuration in Selenium Firefox driver

Posted: 05 Jul 2021 08:33 AM PDT

I'm trying to use proxy in selenium by this way:

firefox_options.add_argument('--proxy-server=socks5://' + 'username:pwd:addr@ipvanish.com:port')  

I'm using ipvanish's proxies there are some hostnames which I don't know where to put Can someone please show me how can I configure a proxy properly, if possible, without using any extension? I searched and found some ways, though I was not able to comprehend the method yet so I'd appreciate it if you'd explain it explicitly.

PCF config server does not refresh properties

Posted: 05 Jul 2021 08:33 AM PDT

I am using PCF provided config server instance which is backed by GIT based repo to server properties. My application is connected to this config server service instance and exposing "refresh" endpoint. Everything works except when i change the property in git and send http post to my application (/actuator/refresh) immediately after updating property, i do not get updated prop name back in response. If I wait few seconds and then send that http post again to refresh the property then I am getting back the name of the property being updated.

Why do I have to wait few seconds(usually 1- 2min) before my property is being refreshed? Does it have anything to do with mirror synchronization?

Image Map dynamic resize in Angular 8

Posted: 05 Jul 2021 08:34 AM PDT

I want to dynamically resize an image map. I only found a solution for jQuery (https://github.com/stowball/jQuery-rwdImageMaps)

How can I realize this in Angular?

Generate new ssh keys in Windows 10 / 11

Posted: 05 Jul 2021 08:34 AM PDT

I am having a really hard time getting my SSH keys up and running after installing Windows 10. Normal method is create it and throw it in the user's account under .ssh. This folder does not appear to be available in Windows 10.

Anyone else run into this? I need to have 3 SSH keys for different repos and this is really holding me up.

How to Automatically Start a Download in PHP?

Posted: 05 Jul 2021 08:33 AM PDT

What code do you need to add in PHP to automatically have the browser download a file to the local machine when a link is visited?

I am specifically thinking of functionality similar to that of download sites that prompt the user to save a file to disk once you click on the name of the software?

No comments:

Post a Comment