2021年5月7日星期五

Datatable scrollbar scrolling is table column

The scrollbar here also scrolls the column headers of the datatable. I don't want this. I just want the lines in the table to shift

https://prnt.sc/12l1zoi

<div class="col-lg-12">      <div class="table-responsive" style="height: 288px;">          <table id="@String.Format(_id+"TabAuthorizersTable")" class="table table-striped table-bordered table-sm" primarycolumn="AuthorizedCode" parameter="AuthorizersTable" style="width:100%">          </table>      </div>  </div>  
https://stackoverflow.com/questions/67420869/datatable-scrollbar-scrolling-is-table-column May 06, 2021 at 11:06PM

Possible to use/layout a compose view in and Activity written in Java?

Google gives the following example of how to use a ComposeView in XML and inflate it in a fragment.

class ExampleFragment : Fragment() {        override fun onCreateView(          inflater: LayoutInflater,          container: ViewGroup?,          savedInstanceState: Bundle?      ): View {          // Inflate the layout for this fragment          return inflater.inflate(              R.layout.fragment_example, container, false          ).apply {              findViewById<ComposeView>(R.id.compose_view).setContent {                  // In Compose world                  MaterialTheme {                      Text("Hello Compose!")                  }              }          }      }  }  

I have an activity written in java, not kotlin. Is it possible to use setContent from a Java activity? If so I am struggling with the syntax.

https://stackoverflow.com/questions/67423907/possible-to-use-layout-a-compose-view-in-and-activity-written-in-java May 07, 2021 at 02:20AM

How to do an OUTER join with a spatial join in BigQuery to be able to get a count value of 0 where there is no intersection?

I'm doing a fairly conventional point/polygon spatial join in order to determine the number of points that fall in each polygon. The result (from the left join) includes all of the polygons + the count where there is an intersection. But it doesn't return the polygon + 0 or null where there is no intersection. I'd like to still have the polygon geometry as it looks better on a map (vs. just a missing area).

 WITH    geoidandcount AS(    SELECT      a.geo_id,      COUNT(b.latitude) AS count    FROM      `polygon_dataset` a    LEFT OUTER JOIN -- ERROR      `point_dataset` b    ON      st_contains(a.the_geom,        ST_GEOGPOINT(b.longitude,          b.latitude))    GROUP BY      a.geo_id )  SELECT    a.*,    b.the_geom,    a.count,  FROM    geoidandcount a  JOIN    `polygon_dataset` b  USING    (geo_id)  

I had to do the CTE as you can't group by geography.

enter image description here

https://stackoverflow.com/questions/67391073/how-to-do-an-outer-join-with-a-spatial-join-in-bigquery-to-be-able-to-get-a-coun May 05, 2021 at 03:34AM

Firestore Cross origin request blocked

I'm working on a react js chat app. I want to list the sub collections of document in fire store from front end react. On internet few people said it's not possible to access the list of sub collection through front end. And some how I came to find out the following code which uses the httpsCallable() to access the list of sub collections

const getSubCollections = firebase        .functions()        .httpsCallable("getSubCollections");              getSubCollections({ docPath: "users/JOtnZTNsc1dRUvmohgO7tNCotsk2" })        .then(function (result) {          var collections = result.data.collections;          console.log(collections);        })        .catch(function (error) {          // Getting the Error details.          var code = error.code;          var message = error.message;          var details = error.details;          // ...        });  

When I'm running this it's saying cross origin request blocked. How can I resolve this.

Or else is there any other way to list all the sub collections inside of a document in the firestore using the front end of react js only.

https://stackoverflow.com/questions/67443983/firestore-cross-origin-request-blocked May 08, 2021 at 12:05PM

Tkinter: how to bind scale hotkeys?

I'd like to bind Control+MouseWheelUp combination. I tried to do so:

import tkinter as tk    root = tk.Tk()  root.bind('<Control-Button-4>',print)  

This gives no reaction? Why?

https://stackoverflow.com/questions/67443993/tkinter-how-to-bind-scale-hotkeys May 08, 2021 at 12:06PM

css style not working on aspx but working on html

why does this css works when i code it with html and stay checked when i select the radio button but not when i use aspx

.btn-check:checked + .btn-secondary, .btn-check:active + .btn-secondary, .btn-secondary:active, .btn-secondary.active, .show > .btn-secondary.dropdown-toggle {    color: #fff;    background-color: #80D2DA;    border-color: #80D2DA;  }  

aspx code

<div class="col-lg-4 col-6 pt-lg-0 pt-2">                    <asp:RadioButton ID="RadioButton1" runat="server" class="btn-check"  GroupName="Testing" Text="1"  />                     <label class="btn btn-secondary w-100 p-lg-3 p-3" for="RadioButton1">above 37&deg;C</label>                  </div>  
https://stackoverflow.com/questions/67443992/css-style-not-working-on-aspx-but-working-on-html May 08, 2021 at 12:06PM

Issue processing large JSON request into multiple files

I'm trying to get a request from Elasticsearch, and from that request, return it as a JSON response, process that JSON response, hash a number of fields within that response, and then break that JSON response, which is exceptionally large, into many files for ML processing. Normally I would just request, process, and ship API, but I am required to write the data to static files.

My attempts so far has have led me to believe there are 2-3 potential solutions, one is to break the JSON request itself into many pieces via TimeDelta, and just make many smaller requests, but that would likely generate many files.

The second/third is to use what I was told is chunking, which I think would most likely be implemented via the snippet I put together below with open, using files, and an iterating loop, or using streams=true with requests, for which I found this regarding that solution: How to get large size JSON files using requests module in Python

Im not familiar with using chunking with requests, so any advice if that is the best option would be great.

Ive been working on this on and off for a while now as priorities have continued to shift, but I would love to close this item out so I can focus on my main projects, so any assistance anyone could provide would be great!

my_dict = resp.json()  ​  ​  x = 0  y = 0  listfile = "listfile{}.txt".format(y)  with open(listfile, "w+") as file:      for index, resp in enumerate(my_dict["hits"]["hits"]):          # ACCOUNT NUMBER          path = my_dict["hits"]["hits"][index]["_source"]["account_number"]          hashed = hashlib.md5(path.encode()).hexdigest()          my_dict["hits"]["hits"][index]["_source"]["account_number"] = hashed                    # CARDHOLDER NAME          path = my_dict["hits"]["hits"][index]["_source"]["cardHolderName"]          hashed = hashlib.md5(path.encode()).hexdigest()  ​          my_dict["hits"]["hits"][index]["_source"]["cardHolderName"] = hashed  ​          # CARDHOLDER ADDRESS          path = my_dict["hits"]["hits"][index]["_source"]["cardHolderAddress"]          hashed = hashlib.md5(path.encode()).hexdigest()  ​          my_dict["hits"]["hits"][index]["_source"]["cardHolderAddress"] = hashed  ​          # PRESENTATION INSTRUMENT ID          path = my_dict["hits"]["hits"][index]["_source"]["presentation_instrument_id"]          hashed = hashlib.md5(path.encode()).hexdigest()  ​          my_dict["hits"]["hits"][index]["_source"]["presentation_instrument_id"] = hashed  ​          # PRESENTATION INSTRUMENT IDENTIFIER          path = my_dict["hits"]["hits"][index]["_source"]["presentation_instrument_identifier"]          hashed = hashlib.md5(path.encode()).hexdigest()  ​          my_dict["hits"]["hits"][index]["_source"]["presentation_instrument_identifier"] = hashed   ​                file.seek(0)      json.dump(my_dict, file, indent=4)        enter code here  

################# Begin Snippet #2 #########################

# chunking learning attempt (Breaking 1 list or large set of data into many files)  ​  # define list of places  places = ['Berlin', 'Cape Town', 'Sydney', 'Moscow']  x = 0  y = 0  listfile = "listfile{}.txt".format(y)  ​  with open(listfile, 'w') as filehandle:      for listitem in places:          filehandle.write('%s\n' % listitem)          x += 1          # checking to see if x is iterating by 1          print(x)  ​          # checking to see if the filename is the same or iterating          print(listfile)  ​          # checking to see if the y value is same or iterating          print("this is the current y: {}".format(y))  ​          # checking to see x value, if x is equal to 3, then interate y by 1, which should change filename from listfile0 to listfile1, etc, and changes x back to 0, and continues loop until all items are processed.          if x == 3:              y += 1              listfile = "listfile{}.txt".format(y)              x = 0              print(y)              continue  
https://stackoverflow.com/questions/67443991/issue-processing-large-json-request-into-multiple-files May 08, 2021 at 12:06PM

Auto scroll after click action react-scroll

I am using react-scroll in react and i am trying to scroll the container div overflow-y after doing an action click in a button, but the function scrolls the body overflow not the container div. How can i do it?

The body has overflow: hidden, and the container div has overflow-y: scroll

https://stackoverflow.com/questions/67443990/auto-scroll-after-click-action-react-scroll May 08, 2021 at 12:06PM

Reset input type date value ReactJS

What i have in my project is a date picker with a reset button next to it, after user select date from date picker, the date picker will show the selected date. See this image if you have dont get it yet

And what i want is to reset the date value back to this by clicking reset button.

And here is my code

I did setting value back to null using useState hook onClick the button, using useRef hook, but nothing works. Any help?

https://stackoverflow.com/questions/67443988/reset-input-type-date-value-reactjs May 08, 2021 at 12:06PM

Laravel VerifyCsrfToken middleware

I ran this code snippet.

    /** @test */      public function unauthenticated_users_cannot_delete_articles()      {          $article = Article::factory()->create();          $this->delete($article->path())              ->assertRedirect(route('login'));          $this->signIn();          $this->delete($article->path())              ->assertStatus(403);      }  

And got this message: Response status code [419] is not a redirect status code. When I turned off the csrf middleware at the route, this test returned green.

Isn't csrf middleware disabled for all tests, then why this happened? (The Docs say so.)

By the way, my laravel version is 8.

https://stackoverflow.com/questions/67443987/laravel-verifycsrftoken-middleware May 08, 2021 at 12:06PM

Can't read embeds from discord message using discord.py

I am trying to read an embedded message but every time I try I try to print message.embeds I get an empty list.

Here's the function I am using. It used to work before but now it only prints []

bot = commands.Bot(command_prefix='!')    channels = {CHANNEL_ID}    @bot.event  async def on_message(message):      if message.channel.id in channels:          embeds = message.embeds  # return list of embeds          print(embeds)  

The embedded messages and what's being printed

https://stackoverflow.com/questions/67443985/cant-read-embeds-from-discord-message-using-discord-py May 08, 2021 at 12:06PM

SSL Certificate issue in Docker Linux Container

I have a simple website by .net core and hosted in a Linux docker container. I had an error "the SSL connection could not be established" when trying to upload files to digital ocean spaces. I configured my localhost certificate to nginx but not work

Docker compose file:

version: '3.4'    services:    nginx:      image: nginx:alpine      hostname: 'nginx'      volumes:        - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro        - ./nginx/proxy.conf:/etc/nginx/proxy.conf:ro        - ./nginx/client.cert:/etc/ssl/certs/client.cert:ro        - ./nginx/client.key:/etc/ssl/certs/client.key:ro        - ./nginx/logs/:/var/log/nginx/      ports:        - 8080:8080        - 443:443      depends_on:        - web      restart: always      web:     image: ${DOCKER_REGISTRY-}web-client     ports:        - "5000"     build:       context: .       dockerfile: src/web/Dockerfile    

nginx config

user nginx;    worker_processes    auto;    events { worker_connections 1024; }    http {        include             /etc/nginx/proxy.conf;      include             /etc/nginx/mime.types;      limit_req_zone      $binary_remote_addr zone=one:10m rate=5r/s;      # server_tokens       off;      sendfile            on;      keepalive_timeout   29; # Adjust to the lowest possible value that makes sense for your use case.      client_body_timeout 10; client_header_timeout 10; send_timeout 10;        upstream web_clients {          server          web:5000;      }        server {          listen     *:8080 default_server;          add_header Strict-Transport-Security max-age=15768000;          return     301 https://$host$request_uri;      }        server {          listen                      443 ssl;          server_name                 $hostname;          ssl_certificate             /etc/ssl/certs/client.cert;          ssl_certificate_key         /etc/ssl/certs/client.key;          ssl_protocols               TLSv1.1 TLSv1.2;          ssl_prefer_server_ciphers   on;          ssl_ciphers                 "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";          ssl_ecdh_curve              secp384r1;          ssl_session_cache           shared:SSL:10m;          ssl_session_tickets         off;          ssl_stapling                on; #ensure your cert is capable          ssl_stapling_verify         on; #ensure your cert is capable            add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" always;          add_header X-Frame-Options DENY;          add_header X-Content-Type-Options nosniff;          add_header X-Frame-Options "SAMEORIGIN";            location / {              proxy_pass http://web_clients;              limit_req  zone=one burst=10 nodelay;          }      }  }  

My upload function

public static async Task UploadFile(IFormFile file)          {              string bucketName = "mybucket";              string endpoingURL = "https://mybucket.sgp1.digitaloceanspaces.com/";              IAmazonS3 s3Client;                using (var newMemoryStream = new MemoryStream())              {                  file.CopyTo(newMemoryStream);                  var s3ClientConfig = new AmazonS3Config                  {                      ServiceURL = endpoingURL                  };                  s3Client = new AmazonS3Client(s3ClientConfig);                  try                  {                      var fileTransferUtility = new TransferUtility(s3Client);                      var fileTransferUtilityRequest = new TransferUtilityUploadRequest                      {                          BucketName = bucketName + @"/files",                          InputStream = newMemoryStream,                          StorageClass = S3StorageClass.StandardInfrequentAccess,                          PartSize = 6291456, // 6 MB                          Key = file.FileName,                          CannedACL = S3CannedACL.PublicRead,                      };                      fileTransferUtility.Upload(fileTransferUtilityRequest);                  }                  catch (AmazonS3Exception e)                  {                      Console.WriteLine("Error encountered ***. Message:'{0}' when writing an object", e.Message);                  }                  catch (Exception e)                  {                      Console.WriteLine("Unknown encountered on server. Message:'{0}' when writing an object", e.Message);                  }              }            }  

Any ideas are welcome, many thanks.

https://stackoverflow.com/questions/67443981/ssl-certificate-issue-in-docker-linux-container May 08, 2021 at 12:05PM

How to perform atomic increments in rails

How to perform atomic increments in rails, what would be the best way to achieve this

user = User.find(id)   invited_count = user.invited_count + 1   user.update!(invited_count: invited_count)  
https://stackoverflow.com/questions/67443980/how-to-perform-atomic-increments-in-rails May 08, 2021 at 12:04PM