Thursday, July 7, 2022

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Is there a way to solve Apache HTTP Server Source Code Disclosure?

Posted: 07 Jul 2022 09:21 AM PDT

I have just received an Acunetix report from the network security section for my Apache server on 64-bit Windows 10, with Moodle 4.0 installed. Such issue is only observed in the Windows version of Apache but not the Ubuntu one. The report also states that this is a 0day issue but I wonder is there a way to get it resolved manually, as it is no longer possible for me to migrate the entire LMS to another OS/host.

The report states the following:

Apache HTTP Server Source Code Disclosure

Due to a flaw in Apache HTTP Server, an attacker can read the source code of web application by sending a specially crafted request. An attacker can gather sensitive information (database connection strings, application logic) by analyzing the source code. This information can be used to conduct further attacks.

Request

GET /index.php HTTP/1.1  Content-Length: acx  Cookie: MoodleSession=(id)  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  Accept-Encoding: gzip,deflate,br  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)  Chrome/100.0.4896.127 Safari/537.36  Host: (domain)  Connection: Keep-alive  

Reference

https://web.archive.org/web/20210909012535/https://zeronights.ru/wp-content/uploads/2021/09/013_dmitriev-maksim.pdf

Text filled with blurred background image

Posted: 07 Jul 2022 09:21 AM PDT

I'm trying to create a title that has a glass looking visual which blurs the background image.

I was able to do it but I had to make references to the background image 3 times and it doesn't seem very optimal.

Here is the code I used.

<div class="title">    <div id="bimage" class="bimage"></div>    <h2 class="mask">MARIO</h2>    <h2 id="h2">MARIO</h2>  </div>    body {    background: blue url("https://images5.alphacoders.com/318/318370.jpg") no-repeat center center fixed;    background-size: cover;  }    .bimage {    position: absolute;    top: 0;    left: 0;    width: 100%;    height: 100%;    background: url("https://images5.alphacoders.com/318/318370.jpg") no-repeat center center fixed;    filter: blur(10px);    background-size: cover;  }    .title {    position: relative;    width: 100%;    height: 500px;    overflow: hidden;  }    h2 {    font-family:Verdana;    position: absolute;    top: 0;    left: 0;    //display: flex;    align-items: center;    justify-content: center;    width: 100%;    height: 500px;    margin: 0;        font-weight: bold;    font-size: 18vw;    text-align: center;    text-transform: uppercase;    mix-blend-mode: screen;  }    .mask {    background: #fff;  }    #h2 {      background: url("https://images5.alphacoders.com/318/318370.jpg") no-repeat center center fixed;    color: rgba(255,255,255,1);    background-size: cover;    mix-blend-mode: multiply;    -webkit-text-stroke-width: 1px;    -webkit-text-stroke-color: rgba(255, 255, 255, 0.4);    text-shadow: 3px 3px 10px black;  }  

https://codepen.io/marceltoma/pen/zYWGYwp

I wonder if there's a better way to do this.

cant get twitch clip download link in Python

Posted: 07 Jul 2022 09:21 AM PDT

I am trying to get the downloadable link for twitch clips using requests-html and Beautifulsoup,
but whenever I get the video tag it doesn't have a src attribute.

session = HTMLSession()  r = session.get(link)  r.html.render()    doc = BeautifulSoup(r.html.raw_html, "html.parser")    tag = doc.find("video")  print(tag)  

What I get back is: <video playsinline="" webkit-playsinline=""></video>

Does anyone know what's going on?

Upgrading legacy signing key to a new signing key

Posted: 07 Jul 2022 09:21 AM PDT

After a new update in my app i got a warning on google play console asking me to upgrade the apps signature to a stronger one. OK, but now i can't update my app with my old keystore.jks

Your Android App Bundle was signed with an incorrect key. Use the correct signing key and try again. It should be signed with a certificate with the following fingerprint

what should i do to fix this? I have the old keystore.jks and the privatekey. Can i create a new keystore with the new certificates?

I tried to import the new certificate in the keystore but no success.

Thanks in advance

Trying to test Wallet instantiation in Solana JS

Posted: 07 Jul 2022 09:21 AM PDT

new to .js so sorry for the noob question around syntax. I'm trying to follow some code to test out instantiating a wallet in code. I'm hardcoding private key (will not do this in prod obviously) just to see how everything works. I'm getting this error : throw new Error('bad secret key size'); ^ Error: bad secret key size

My code is as below :

import { Connection, Keypair, Transaction } from '@solana/web3.js'  

import fetch from 'cross-fetch' import { Wallet } from '@project-serum/anchor' import bs58 from 'bs58'

const connection = new Connection('https://ssc-dao.genesysgo.net')

const PRIVATE_KEY = 'my secret key is this very dumb long confusing and unnecessary string' const wallet = new Wallet(Keypair.fromSecretKey(bs58.decode(process.env.PRIVATE_KEY || '')))

Thanks

how to get email notification while created new user in splunk server

Posted: 07 Jul 2022 09:21 AM PDT

"how to get email notification while created new user in splunk web server, that receipts should get notification that user has been created for you. I am using splunk enterprise 9.0.

How to execute PostgreSQL functions with PSQL-specific arguments as stored procedures with Npgsql 6?

Posted: 07 Jul 2022 09:20 AM PDT

I'm having some trouble porting C# code from Npgsql 2.2.7 to Npgsql 6.0.5 (PostgreSQL is version 12.x). Following code works just fine with Npgsql 2.2.7:

using (var conn = OpenConnection())  using (var cmd = conn.CreateCommand())  {      cmd.CommandType = CommandType.StoredProcedure;      cmd.CommandText = "plainto_tsquery";      cmd.Parameters.Add(new NpgsqlParameter(null, "german"));      cmd.Parameters.Add(new NpgsqlParameter(null, "some test text"));      var result = cmd.ExecuteScalar();      Console.WriteLine(result);      //result is string "'som' & 'test' & 'text'"  }  

It doesn't work with Npgsql 6, ExecuteScalar throws following exception (translated, maybe not exactly the same text):

Npgsql.PostgresException: '42883: Function plainto_tsquery(text, text) doesn't exists.

I've read about the breaking changes in Npgsql and yes, the behavior is more ore less expected, as some implicit conversions doesn't occur anymore. But how to specify the first argument of type regconfig to match the function signature? Following throws an exception:

cmd.Parameters.Add(null, NpgsqlDbType.Regconfig).Value = "german";  

System.InvalidCastException: 'Can't write CLR type System.String with handler type UInt32Handler'

Changing the CommandType to Text and issuing a SELECT statement works, but I'm not fully happy with it:

using (var conn = OpenConnection())  using (var cmd = conn.CreateCommand())  {      cmd.CommandType = CommandType.Text;      cmd.CommandText = "SELECT plainto_tsquery($1::regconfig, $2)";      cmd.Parameters.AddWithValue(NpgsqlDbType.Text, "german");      cmd.Parameters.AddWithValue(NpgsqlDbType.Text, "some test text");      var result = cmd.ExecuteScalar();      Console.WriteLine(result);      //result is NpgsqlTypes.NpgsqlTsQueryAnd, ToString() gives: "'som' & 'test' & 'text'"  }  

Is there a way to call such functions with PostgreSQL-specific type arguments as stored procedures and not as SELECT statements? How did Npgsql 2.x convert the parameters and/or command text?

Using case_when with vector outputs of different length - can I avoid this doubling behaviour?

Posted: 07 Jul 2022 09:20 AM PDT

When I use case_when as below, I end up with an unwanted doubling of outputs that were intended to be of length 1 - presumably because case_when matches the length of vectors

a <- 1  b <- 2  decision <- case_when(    a == b ~ c("A", "B"),    a > b ~ "A",    TRUE ~ "B")    result <- decision %>% str_c("+") %>% paste(collapse = " ")  

The result is "B+ B+", when I just want "B+" When a=b, I get "A+ B+", which is what I want.

Is there any way to stop this behaviour, or an alternative function? Please note that the above is just the simplest parallel I could write. I am using case_when as part of a custom function to define rules applied to numerous input variables to generate a result call. I had been using multiple if_else statements chained together, but that has significant readability/editing issues and I had been excited to discover case_when and use it instead.

I can't login as admin in wordpress site it shows me this link is faulty

Posted: 07 Jul 2022 09:20 AM PDT

Iam trying to get access through c panel but it shows page not found and this link is faulty i have so many things to solve 1. Deactivating plugin and themes 2. Changing url 3.tried uploading backup to /wp folder 4.loginn from domain name/login.php this shows the login form page but after giving credentials it shows can't acces page and etc etc... But this can't help my website is working properly but the thing is I can't login as admin. Pls help

Site url- https://tractoragricultureimplement.com

Link which should open my wordpress dashboard(without id and password) from cpanel - https://tractoragricultureimplement.com/sapp-wp-signon.php?pass=helghzy7hqfakrhnsby8v1iyamckipwr

how to specify hourly time range in djagno?

Posted: 07 Jul 2022 09:20 AM PDT

I want to accept orders within specific timeframe, simply i want to validated orders if they are within 8:00-19:00 no matter what day it is or what date it is.

Sharing memory when using tokio Rust

Posted: 07 Jul 2022 09:20 AM PDT

I am new to async Rust, and find myself stuck.

I am trying to share memory for two WebSocket clients using tokio::mpsc. I want my WebSocket clients to be the producers / senders over the channel. However, I want the receiver / consumer to be stateful, acting somewhat like a filter for messages read from the channel.

I use tungstenite::WebSocket for the clients, and the Websocket::read_message() implementation I use, returns a custom struct called Summary, in example it looks like this:

In my main.rs file, I use tokio to make my main function async (async fn main()). However, because I have to socket.read_message() in a loop {} block in my client implementation, I have to exit the loop in the client by returning an instance of Summary, for exaple:

...  impl Client {    pub fn new() -> Self {      ... // Some builder logic    }      pub fn subscribe(&mut self) -> Summary {      loop {        let mut summary: Summary = Summary::new(          some_value: 0.00,          some_vec_1: Vec<_> = vec![];          some_vec_2: Vec<_> = vec![];        );          let msg: Message = self.socket.read_message().expect("Failed to read Message");          ... // Some logic to get x, ys, zs from Message          summary.some_value = x;        summary.some_vec_1 = ys;        summary.some_vec_2 = zs;        return summary       };    }  }  

Because I want to return a Summary struct, I have to use a return statement at the end of the loop, which means the client's subscribe function only passes on 1 Summary object. This makes it a bit tricky to get the main.rs file correct, and it is primarily there I am stuck.

Currently, I am trying the following:

#[tokio::main]  async fn main() {    loop {        let (p1, mut consumer) = tokio::mpsc::channel(100); // bounded channel      let p2 = p1.clone(); // need to clone producer for client number 2        let client1 = my_module::Client::new();      let client2 = my_module::Client::new();        let t1 = tokio::spawn(async move {          if let Err(_) = p1.send(client1.subscribe()).await {              println!("Channel dropped")              return;          }      });        let t2 = tokio::spawn(async move {          if let Err(_) = p2.send(client2.subscribe()).await {              println!("Channel dropped")              return;          }      });        while let Some(summary) = consumer.recv().await {         ... // Stateful logic goes here      }    }  }    

As you might have guessed, this clears the state in the consumer for every new message that is produced. I suspect this is because they are "re-created" every time the loop starts at the top, but I am not entirely sure. Any details would be helpful.

I have also tried moving the loop {} in my main.rs file around, but I am encountering some problems due to Rust's lifetimes since p1 and p2 are moved into the tokio::spawn(async move {}) block in previous loop iterations.

I am thinking that maybe I have used the library, but I am not sure, hence why I came here. :-)

Thanks in advance.

Flutter getting stuck in "Syncing files to device SM T550..." when running app on real SamSung device

Posted: 07 Jul 2022 09:20 AM PDT

I am first time trying to run app on Samsung real device. But the app getting stuck at Syncing files to device SM T550...

Here is the complete report:

Launching lib\main.dart on SM T550 in debug mode...  Running Gradle task 'assembleDebug'...  √  Built build\app\outputs\flutter-apk\app-debug.apk.  Installing build\app\outputs\flutter-apk\app.apk...  Debug service listening on ws://127.0.0.1:62531/u537WKCNS68=/ws  Syncing files to device SM T550...  

Doctor report is:

[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1766], locale en-US)  [√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)  [√] Chrome - develop for the web  [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.5)  [√] Android Studio (version 4.2)  [√] Connected device (4 available)  [√] HTTP Host Availability    • No issues found!  

Elasticsearch _cluster/stats api vs _stats API

Posted: 07 Jul 2022 09:20 AM PDT

I am a bit confused on why I would be getting a relatively drastic different amounts for each of this api calls for doc count (Primary and Total), shard amounts, and even the amount of indices.

Does anyone know why these two API calls would return different statistics for a given elasticsearch cluster?

Thanks

Azure Logic App Condition is not evaluating as True or False

Posted: 07 Jul 2022 09:20 AM PDT

I'm trying to create an Azure Logic API that calls API1, gets a list of IDs then passes those IDs into another API call to API2 to see if the ID already exists. If it does not I want it to create the ID in API2.

I've set it up as a timer-base trigger. When triggered I have it making an API request to get a list of IDs from the first API. It then parses the JSON so that I can use the IDs in a Foreach loop to take the IDs from one API and compare them with IDs from another API. It's then parsing the JSON response for another foreach loop to evaluate if it exists then skip and if it doesn't create the new IDs.

The problem I'm having is when it doesn't exist in the second API it never kicks off the API request to create the IDs in the second API. The most logical way to set it up is if API1-ID does not equal API2-ID, then true otherwise false. The problem is, if the ID doesn't exist in API2 there's nothing to evaluate for true/false so the API call to create never execute. I had assumed that if ID didn't exists then it wasn't equal, so it would be true.

I've even tried to use the empty expression or length if the JSON response body is zero, but I cannot get this fire off the API request to create the missing IDs. I feel like this can work because I've flipped it to where if ID = ID then it creates the ID (which gives me duplicates).

If anyone can help that would be awesome!

enter image description here enter image description here

Summing hours worked for a week, over the month - c# & LINQ

Posted: 07 Jul 2022 09:20 AM PDT

I am wondering how i can simplify my queries as I know I am carrying out bad practice and going the long way about things.

Basically, I have shifts being entered into an app on a weekly basis, and i am calculating the hours worked each week. I am wanting to know how do I go about getting the start date of a week and the end date of a week based on a known shift, which has been entered into the app (ShiftDate).

Quick example below of 4 weeks, where I have worked out the start and end of the week using moment.js and passed them down to the c# function (represented by vStart, vEnd etc...).

I am struggling how to obtain start and end of a week that contains x.ShiftDate

Week1 = pg.Sum(x => x.ShiftDate >= vStart1 && x.ShiftDate <= vEnd1 ? x.HoursWorked : 0),                               Week2 = pg.Sum(x => x.ShiftDate >= vStart2 && x.ShiftDate <= vEnd2 ? x.HoursWorked : 0),                               Week3 = pg.Sum(x => x.ShiftDate >= vStart3 && x.ShiftDate <= vEnd3 ? x.HoursWorked : 0),                               Week4 = pg.Sum(x => x.ShiftDate >= vStart4 && x.ShiftDate <= vEnd4 ? x.HoursWorked : 0),    

I want to figure out how to just write the sum function once, without having to repeat for each week within the month

how to read the whole web page with Python - bs4 /response read only first part of the page

Posted: 07 Jul 2022 09:20 AM PDT

I am trying to scrape the page to get the term and its definition from the page https://dictionary.apa.org/caffeine-intoxication (or similar pages at dictionary.apa.org)

The following code (and bs4 too) gets only <head> part of the page (only html part?, 'save as html' in a browser gives the same result):

import requests  url = 'https://dictionary.apa.org/a-posteriori'  response = requests.get(url, allow_redirects=True)  print(response.text)  

But I really need to get other elements of the page (<body>):

<terms><term><dt><a href="/caffeine-intoxication"><h4>  <hw>caffeine intoxication</hw>  </h4></a></dt><dd>in <em>DSM–IV–TR</em> and <em>DSM–5</em>, intoxication due to recent consumption of large amounts of caffeine (typically over 250 mg), in the form of coffee, tea, cola, or medications, and involving at least five of the following symptoms: restlessness, nervousness, excitement, insomnia, flushed face, diuresis (increased urination), gastrointestinal complaints, muscle twitching, rambling thought and speech, rapid or irregular heart rhythm, periods of inexhaustibility, or psychomotor agitation. Also called <span style="font-family:arial;font-weight:bold">caffeinism</span>.</dd></term></terms>  

How can I get the rest of the page?

How can i apply a class to all elements inside a nested array but with an interval before apply the same class to the next nested array?

Posted: 07 Jul 2022 09:21 AM PDT

My Goal today is to apply a class to all elements inside a nested array and wait a 1-sec delay before applying the same class to all elements of the next nested array and removing the class applied to the previous nested array. At the moment my class is been applied to all elements of all nested arrays simultaneously. This is as far as I can get with my code as I don't know how to proceed. Any help on what to look for to solve this with JavaScript or Jquery will be much appreciated.

let sequencing = [["01-01", "02-01", "03-01"],["01-02", "02-02", "03-02"],["01-03", "02-03", "03-03"],["01-04", "02-04", "03-04"]];        // This loop is for outer array  for (let i = 0;  i < sequencing.length; i++) {        // console.log(sequencing[i]);        // This loop is for inner-arrays    for (var j = 0; j < sequencing[i].length; j++) {        //console.log(sequencing[j]);        // Accessing each elements of inner-array      $("#"+sequencing[i][j]).addClass("up");         }     }  

how do I access struct enum values for use with UIsearchbar?

Posted: 07 Jul 2022 09:20 AM PDT

I am struggling to learn about creating and using more complex structs with UITableView and UIsearchbar. I have a table that displays the following structs in 2 sections.

struct ReceiveInResponse: Codable {        var result: [ReceiveIn]    }    struct ReceiveIn: Codable {        var section: String      var items: [ReceiveInComp]        enum CodingKeys: String, CodingKey {          case section = "Section"          case items      }    }    struct ReceiveInComp: Codable {       let owner, barcode, quantity: String     let resultDescription, status: String       enum CodingKeys: String, CodingKey {        case owner = "Owner"        case barcode = "Barcode"        case quantity = "Quantity"        case resultDescription = "Description"        case status = "Status"     }    }  

I have implemented the searchbar many times. But this time I am getting an error when trying to search the value of case barcode. This is the error.

Type '[ReceiveInComp]' has no member 'barcode'  

Here is my code

func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {            self.filteredList = []        if (searchText == "") {          self.filteredList = self.ReviewList      } else {          for comp in self.ReviewList {                            let myitems = comp.items  

attempt 1

            switch myitems {                    case .barcode(let barcode): do { // error thrown here                      if (barcode.lowercased().contains(searchText.lowercased())) {                          self.filteredList.append(comp)                      }                  }              }  

attempt 2
var barcode = myitems.barcode // error thrown here

            if (barcode.lowercased().contains(searchText.lowercased())) {                  self.filteredList.append(comp)              }          }      }      self.tableView.reloadData()  }  

I can print myitems to console and see the values it contains. How do I access the value of barcode for comparison to searchtext?

Here is a sample of what I see when I do print(myitems) in console

App.ReceiveInComp(owner: "E3D Rental", barcode: "10021640", quantity: "1", resultDescription: "2X2. X42 BLK CABINET ", status: "missing"),  

SOLUTION

        for comp in self.ReviewList {                            let myitems = comp.items                            for item in myitems{                                    let barcode = item.barcode                  if (barcode.lowercased().contains(searchText.lowercased())) {                      self.filteredList.append(comp)                  }                                                  }  }  

this seems to work, getting duplicates in the search results for some reason but prior error is gone. thanks @shadowrun

Find first event occurring after given event

Posted: 07 Jul 2022 09:20 AM PDT

I am working with a table consisting of a number of web sessions with various events and event id:s. To simplify my question, let's say that I have 4 columns which are session_id, event_name and event_id, where the event id can be used to order the events in ascending/descending order. Let's also pretend that we have a large number of events and that I am particularly interest in 3 of the events with event_name: open, submit and decline. Assume that these 3 events can occur in any order.

What I would like to do, is that I would like to add a new column that for each session says which, if any, of the two events 'submit' and 'decline' that first follows the event 'open'. I have tried using the FIRST_VALUE partition function but have not made it successfully work yet.

So for a session with event sequence: 'open', ... (a number of different events happening in between), 'submit', 'decline', I would like to return 'submit', and for a session with event sequence: open, ... (a number of different events happening in between), 'decline', I would like to return 'decline', and for a sessions for which none of the events 'submit' nor 'decline' happens after 'open', I would like to return null.

You can use the following table with name 'events' for writing example SQL code:enter image description here

I hope the question and its formulation is clear. Thank you very much in advance!

Sincerely, Bertan

printed value for high numbers is wronger than it should?

Posted: 07 Jul 2022 09:20 AM PDT

When printing a high number in R I expect to see a rounded value due to floating point magic. Indeed :

options(scipen = 999)  x <- 10000000000000000000000000  x  #> [1]  9999999999999998758486016  

However I expected that this rounded number would be rounded to itself, and it appears it isn't

x ==  9999999999999998758486016  #> [1] FALSE    9999999999999998758486016  #> [1]  9999999999999996611002368  

I found manually the min number that rounds to the original rounded value

x ==  9999999999999998799999999  #> [1] FALSE    9999999999999998799999999  #> [1]  9999999999999996611002368    x ==  9999999999999998800000000  #> [1] TRUE    9999999999999998800000000  #> [1]  9999999999999998758486016  

While an explanation would be appreciated, I have a practical issue. I'd like to design a faithful dput() equivalent that would work with any number.

The constraint to satisfy is : x == as.numeric(my_deparser(x))

If mydeparser() could return "9999999999999998800000000" for the above for instance I'd be happy, because

10000000000000000000000000 == as.numeric("9999999999999998800000000")  #> [1] TRUE  

I've tried format(), dput(), deparse() with no luck.

How can I achieve this ?

Laravel groupBy and pluck some values

Posted: 07 Jul 2022 09:20 AM PDT

I am using laravel 8.x and building rest API project. I am stuck with a query.

I have a table

id name type color
1 Dog animal black
2 Dog animal yellow
3 Cat animal red
4 Cat animal white

I want to do something like that,

$animals->groupBy('name')->get()

and hope to get result like,

$animals=[            {             name: "dog",             type: "animal",             colors: ["black", "yellow"]            },            {             name: "cat",             type: "animal",             colors: ["red", "white"]            }           ]  

Anyone help me?

TypeError: Updater.__init__() got an unexpected keyword argument 'use_context'

Posted: 07 Jul 2022 09:21 AM PDT

It occurred when I perform this :
updater = Updater('5502935975:AAGcE8wtPOUMXVCOI3PXr0fygpXsdaEn-HI', use_context=True)
Many Thanks!

Ruby - Check the length of each words and group them

Posted: 07 Jul 2022 09:20 AM PDT

I can't find the methods used to check the length of each word and group them per length.

arr = ["john","roger","matt","john", "james", "Jennifer"]

The method should return:

There are 3 names with 4 characters
There are 2 names with 5 characters
There is 1 names with 1 character

I tried this one and it's working

arr.group_by(&:length).transform_values(&:count)  

Thank you

Oracle ORA_HASH alternative in Postgres(MD5)

Posted: 07 Jul 2022 09:21 AM PDT

I am trying to find an alternative to the ORA_HASH Oracle function in Postgres(edb). I know there are hashtext() and MD5(). Hashtext should be ideal, but it's not documented and so I can't use it for some reasons. I'd like to know if there is any way of using MD5() and getting the same value that you'd get in ORA_HASH giving the same value for both of them.

For example, this is how I use it and what I get in Oracle:

SELECT ORA_HASH('huyu') FROM dual;  ----------------------------------  3284595515  

I'd like to do something similar in postgres, so that if I pass the 'huyu' value, I'd get the exact same '3284595515' value.

Now, I know that ORA_HASH restores a number and MD5 restores hexadecimal value. I think I'd need the function that converts the hexadecimal 32 into a number, but I can't get the same value and I'm not sure if it is possible.

Thank you in advance for any suggestions

How to reference the value of an environment variable with using another environment variable in variable name?

Posted: 07 Jul 2022 09:21 AM PDT

I know that similar questions have been asked before and I have seen them but neither does !var[%Z%]! nor %var[!Z!]% work here:

@echo off  set Z=0  setlocal enabledelayedexpansion  set count=0  for /f "tokens=*" %%x in (Data) do (      set /a count+=1      set var[!count!]=%%x  )  :end  cls   echo %var[!Z!]%  choice  /N /C QE  IF %errorlevel% == 1 GOTO ZP  IF %errorlevel% == 2 GOTO ZM  pause >nul  goto :end    :ZP  set /a Z=%Z%+1  goto :end  :ZM  set /a Z=%Z%-1  goto :end  

I tried them and they don't work. What can I do?

Data is a file with following lines:

A  B  C  D  E  F  AA  AB  AC  AD  

DIV fade in onscroll with JQuery but without triggering on each pixel

Posted: 07 Jul 2022 09:21 AM PDT

I have an SVG inside a DIV that is supposed to start at 0% opacity and then fade in to 100% via jQuery when I scroll down to 800px. Currently, it's:

  1. Loading at full opacity (instead of 0%) before fading out and back in again and
  2. Firing repeatedly (ex. fade in on pixel 800, and again at 801, 802, etc.).

How would I fix this to only fire once?

Edit: I've adapted code that Johannes posted and replaced it below. Issue 2 is now resolved but issue 1 still remains.

$var status_1 = "closed";  $(window).scroll(function() {    var scrollposition = $(this).scrollTop();    if ((scrollposition > 800) && (status_1 == "closed")) {      $('.verticallogoFixed .stickyMPlogo').fadeIn(1000);      status_1 = "open";    }    if ((scrollposition < 800) && (status_1 == "open")) {      $('.verticallogoFixed .stickyMPlogo').fadeOut(1000);      status_1 = "closed";    }  });
.verticallogoFixed {    width: 5vh;    height: 80vh;    position: fixed;    top: 50%;    transform: translatey(-50%);    left: 2.25em;    z-index: 700;    margin: 0;  }    .verticallogoFixed .stickyMPlogo {    position: absolute;    top: 50%;    transform: translatey(-50%);    /* display: none; */    margin: 0;  }    .stickyMPlogo {    fill: #07372F;    transition: 0.3s;  }    .stickyMPlogo:hover {    fill: #D5E900;  }    .svgLogo a {    overflow: hidden;    padding-left: 0.1vw;    padding-right: 0.1vw;  }    .containerDemo {    height: 2000px;  }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>  <div class="containerDemo">    <div class="verticallogoFixed">      <a href="http://melanie-patterson.com/" class="svgLogo">        <svg class="stickyMPlogo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 1200" fill="#D5E900">          <path d="M1.743 1096.853l68.161-32.474-68.16-25.37v-14.883h.845c0 7.273 6.005 7.78 22.665 7.78H62.8c16.66 0 22.664-.508 22.664-7.78h.846v22.833h-.846c0-7.273-6.004-7.78-22.664-7.78H4.534l75.602 28.076c-26.546 14.613-45.364 21.15-72.388 34.503l36.279.084c20.889.682 41.93-1.119 41.437-14.207h.846v22.833h-.846c0-7.272-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.508-22.664 7.78h-.846zm0-77.804v-60.55H13.16v.846c-10.478-.7-11.12 29.485-10.571 44.65h36.364c-9.416-10.07.946-20.246 1.353-30.274 0-3.213-1.861-6.258-4.82-6.258v-.846c4.989 0 9.302 4.144 9.302 10.825 0 10.317-7.273 14.63-7.442 20.634a7.175 7.175 0 0 0 2.96 5.92h45.158c-.446-10.818 2.366-42.783-13.108-44.65v-.847H86.31v60.55h-.846c0-7.273-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78zm0-88.459h.846c0 7.274 6.005 7.78 22.664 7.78h60.211c-.498-10.964 2.456-42.495-13.108-44.566v-.845H86.31v60.465h-.846c0-7.273-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78h-.846zm32.22-76.533c-1.607 0-2.283.93-2.283 2.03 0 4.059 8.88 6.596 8.88 11.416 0 2.368-2.283 2.791-4.482 1.945L.052 855.833v-.846l71.459-27.061c9.302-3.721 13.953-6.427 13.953-11.585h.846v27.737h-.846c0-11.924-6.85-11.5-15.39-8.287L42.42 846.276c49.873-7.207 58.144 40.325 29.09 41.608-20.803 0-28.752-33.827-37.547-33.827zm49.979 13.361c-.622-20.07-31.318-23.743-47.103-19.027L9.862 858.623l25.877 9.726c2.96 1.099 3.975.422 3.975-.93 0-3.89-8.88-7.02-8.88-11.501 0-1.608 1.1-2.791 3.298-2.791 11.332 0 14.884 27.568 35.772 27.568 7.949 0 14.038-4.99 14.038-13.277zM1.743 799.002l72.22-47.357c-17.211.588-72.082-4.438-71.374 14.208h-.846v-22.834h.846c0 7.273 6.005 7.78 22.664 7.78h62.748c1.394 1.533-81.51 53.535-81.522 54.375 16.771-1.027 79.921 5.545 78.985-14.206h.846V813.8h-.846c0-7.274-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78h-.846zm0-61.059V715.11h.846c0 7.273 6.005 7.78 22.664 7.78H62.8c16.66 0 22.664-.507 22.664-7.78h.846v22.833h-.846c0-7.274-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78zm0-27.907v-60.55H13.16v.846c-10.478-.7-11.12 29.485-10.571 44.651h36.364c-9.416-10.07.947-20.247 1.353-30.274 0-3.214-1.861-6.258-4.82-6.258v-.846c4.989 0 9.302 4.143 9.302 10.824 0 10.317-7.273 14.63-7.442 20.635a7.175 7.175 0 0 0 2.96 5.92h45.158c-.446-10.818 2.366-42.783-13.108-44.651v-.846H86.31v60.55h-.846c0-7.273-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.508-22.664 7.78zm0-95.223c.59-12.335-1.283-22.719-1.692-35.265 1.257-46.321 70.636-32.988 49.05 20.296h13.7c16.66 0 22.664-.507 22.664-7.78h.845v22.749h-.846c0-7.273-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78zm49.64-32.897C49.89 545.64-13.2 551.842 3.944 599.844h44.312a48.422 48.422 0 0 0 3.129-17.928zm-17.42-59.198c-1.607 0-2.283.93-2.283 2.03 0 4.06 8.88 6.596 8.88 11.416 0 2.368-2.283 2.791-4.482 1.945L.052 524.494v-.846l71.459-27.061c9.302-3.72 13.953-6.427 13.953-11.586h.846v27.738h-.846c0-11.924-6.85-11.5-15.39-8.287L42.42 514.938c49.872-7.208 58.144 40.324 29.09 41.607-20.803 0-28.752-33.827-37.547-33.827zm49.979 13.361c-.622-20.07-31.318-23.743-47.103-19.027L9.862 527.284l25.877 9.726c2.96 1.099 3.975.422 3.975-.93 0-3.89-8.88-7.02-8.88-11.501 0-1.607 1.1-2.791 3.298-2.791 11.332 0 14.884 27.569 35.772 27.569 7.949 0 14.038-4.99 14.038-13.278zM1.743 434.344H13.16v.845c-6.041-.525-10.505 10.491-10.571 25.116h60.21c16.66 0 22.665.17 22.665-7.103h.846v22.072h-.846c0-7.273-6.004-7.78-22.664-7.78H2.59c.067 14.625 4.53 25.641 10.57 25.116v.845H1.744zm0-64.188H13.16v.846c-6.041-.525-10.505 10.49-10.571 25.116h60.21c16.66 0 22.665.17 22.665-7.104h.846v22.072h-.846c0-7.272-6.004-7.78-22.664-7.78H2.59c.067 14.626 4.53 25.642 10.57 25.117v.845H1.744zm0-5.076v-60.548H13.16v.845c-10.478-.699-11.12 29.486-10.571 44.651h36.364c-9.416-10.072.947-20.247 1.353-30.275 0-3.213-1.861-6.258-4.82-6.258v-.845c4.989 0 9.302 4.143 9.302 10.824 0 10.317-7.273 14.63-7.442 20.634a7.176 7.176 0 0 0 2.96 5.92h45.158c-.446-10.817 2.366-42.783-13.108-44.65v-.846H86.31v60.549h-.846c0-7.273-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78zm83.721-65.624c0-7.273-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78h-.846C2.332 287.12.461 276.739.051 264.192c-1.813-34.953 44.866-38.172 45.837-3.89-.001 7.949-5.413 13.361-5.413 16.913 0 1.015.254 2.452 2.198 2.452 5.497 0 6.681-17.843 17.337-24.693 10.401-6.68 25.454-14.545 25.454-24.186h.846c.051 20.223 3.24 13.081-25.37 32.558-12.347 8.203-12.685 17.167-18.435 17.167a2.722 2.722 0 0 1-2.876-2.96c0-4.99 4.82-8.88 4.82-16.744-2.227-27.942-56.286-24.068-40.507 23.678H62.8c16.66 0 22.664-.507 22.664-7.78h.846v22.748zM.052 192.9a70.913 70.913 0 0 1 3.89-24.1h11.332v.845S1.067 174.803 1.067 192.9c0 15.73 9.556 24.355 18.943 24.355 23.17 0 14.968-53.446 44.566-53.446 11.755 0 23.425 12.178 23.425 31.713 0 11.163-5.666 21.057-10.317 27.315H66.352c-.889-1.528 20.155-10.893 20.126-32.05 0-12.348-9.048-22.073-18.435-22.073-25.454 0-18.266 54.46-46.004 54.46C10.285 223.176.052 212.436.052 192.9zm43.975-39.24c-58.094-.207-58.089-75.063 0-75.264 58.094.206 58.088 75.062 0 75.263zm0-7.612c56.683-.588 56.678-59.456-.002-60.041-56.851-.33-56.846 60.376.002 60.041zM1.743 55.983l72.22-47.357C56.752 9.213 1.882 4.188 2.59 22.833h-.846V0h.846c0 7.272 6.005 7.78 22.664 7.78h62.748C89.392 9.309 6.494 61.318 6.48 62.156 23.251 61.129 86.4 67.7 85.464 47.949h.846v22.833h-.846c0-7.273-6.004-7.78-22.664-7.78H25.253c-16.66 0-22.664.507-22.664 7.78h-.846z" />        </svg>      </a>    </div>      <div class="content">    </div>  </div>

revised jsFiddle, original version jsFiddle

Thanks!

Delphi IOS Iphone TWebbrowser (Wkwebview) setAllowsInlineMediaPlayback(true) does not work

Posted: 07 Jul 2022 09:21 AM PDT

I try to inbound a fmx.TWebbrowser (Delphi 11) for displaying an youtube stream in an iphone app. If I click the stream picture, the stream opens in the iphone movieplayer-window. So I have to zoom out, to view the video in the app. On Android devices it works fine. Also, when I write the app in Xcode, I can set "plays inline" and the stream works inline at the wkwebview.

In Delphi / RAD, I can modify the FMX.Webbrowser.Cocoa. It is possible to use the function configuration.setAllowsInlineMediaPlayback(true). If I check this afterwards, configuration.allowsinlineMediaPlayback remains false.

Example:

constructor TCommonWebBrowserService.Create;   var test:Boolean;  begin   FWebView := TNativeWebViewHelper.CreateAndInitWebView;   FWebView.configuration.setAllowsInlineMediaPlayback(True);   test:=FWebView.configuration.AllowsInlineMediaPlayback;  

test remains False.

Apple writes: setAllowsInlineMediaPlayback must be set at creation.

At FMX.Webbrowser.Delegate.IOS there is

class function TNativeWebViewHelper.CreateAndInitWebView: WKWebView;  begin   Result := TWKWebView.Create();  end;  

but there is no way to set .configuration.setAllowsInlineMediaPlayback(True);

At FMX.Webbrowser.delegate.ios there is a function called

function TWebViewDelegate.webViewCreateWebViewWithConfigura tion(webView: WKWebView; configuration: WKWebViewConfiguration;navigationAction: WKNavigationAction; windowFeatures: WKWindowFeatures): WKWebView;  

but Delphi does not use this function.

Is there an override or a solution to this problem?

Thanks a lot.

Amazon Managed Airflow (MWAA) import custom plugins

Posted: 07 Jul 2022 09:20 AM PDT

I'm setting up an AWS MWAA instance and I have a problem with import custom plugins.

My local project structure looks like this:

airflow-project  ├── dags   │   └── dag1.py    └── plugins      ├── __init__.py      └── operators          ├── __init__.py          └── customopertaor.py  

I tried to match this structure in the s3 bucket:

s3://{my-bucket-name}  └── DAGS      ├── dags       │   └── dag1.py        └── plugins          ├── __init__.py          └── operators              ├── __init__.py              └── customopertaor.py  

However when I use the custom operator on the local project the import works like this -

from operators import customOperators  

and on the MWAA it only recognize imports like this -

from plugins.operators import customOperators  

Is there a way to get the MWAA recognize the import as the local (from operators)? should I upload the files in certain way to the s3?

I also tried to upload a plugins.zip file but it didn't work:

s3://{my-bucket-name}  ├── DAGS  │   └── dags   │       └── dag1.py    └── plugins.zip  

How to test a Faust agent that sends data to a sink?

Posted: 07 Jul 2022 09:21 AM PDT

I am trying to write unit tests using pytest for my Faust application. I have referred to the documentation here but it does not mention what to do when my Faust agent is sending data to a sink.

Without a sink, my tests are working fine but when I use a sink, I get this error:

RuntimeError: Task <Task pending name='Task-2' coro=<Agent._execute_actor() running at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/faust/agents/agent.py:647> cb=[<TaskWakeupMethWrapper object at 0x7fc28967c5b0>()]> got Future <Future pending> attached to a different loop  INFO     faust.agents.agent:logging.py:265 [^-AgentTestWrapper: ml_exporter.processDetections]: Stopping...  

I have tried various methods: such as patching out the decorator in my Faust app that sends the data to the sink, trying to test my function without the decorator (by trying to bypass it), patching out the sink parameter in my Faust app to have a None value (so it doesn't send my data to the sink), etc. I have had no luck with any of these.

Here is my Faust agent:

app = faust.App('ml-exporter', broker=dx_broker, value_serializer='json')    detection_topic = app.topic(dx_topic)  graph_topic = app.topic(gwh_topic)    @app.agent(detection_topic, sink=[graph_topic])  async def processDetections(detections):      detection_count = 0      async for detection in detections:          detection_count += 1          # r.set("detection_count", detection_count)          yield detection  

Here is my current testing code:

import ml_exporter    patch('ml_exporter.graph_topic', None)    def create_app():      return faust.App('ml-exporter', value_serializer='json')    @pytest.fixture()  def test_app(event_loop):      app = create_app()      app.finalize()      app.flow_control.resume()      return app    @pytest.mark.asyncio()  async def test_processDetections(test_app):      async with ml_exporter.processDetections.test_context() as agent:          event = await agent.put('hey')          assert agent.results[event.message.offset] == 'hey'  

I get the same error as mentioned above when I run this test. Is there any way to test my Faust app successfully?

Thank you!

How to determine if a Rails object is marked_for_destruction?

Posted: 07 Jul 2022 09:21 AM PDT

I have some objects which happen to be nested_attributes of something else. When they are marked to be deleted, Rails creates a property "marked_for_destruction". How do I read this var?

Sample Yaml dump:

--- &id001 !ruby/object:LineItem   attributes:     name:Pay    created_at: 2009-10-12 16:30:51    updated_at: 2009-10-12 16:30:51    statement_id: "8"    amount: "234"    id: "33"  attributes_cache: {}    errors: !ruby/object:ActiveRecord::Errors     base: *id001    errors: {}    marked_for_destruction: true  

No comments:

Post a Comment