Sunday, 2 October 2022

Marquee speed up and slow down in intervals

I have a css marquee where I need to change speed in intervals.

For example: Current speed for animation is set for 120 seconds. What do I need is to change the animation speed like this: First 3 seconds animation speed: 120s, after 3-8 seconds speed up to animation speed 20s, after 8 seconds stop for 2 seconds to animation speed 0, after it repeat again in the loop. The transitions should be not visible in speed change, it should be smooth.

My current demo

.marquee {
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    white-space: nowrap;
    box-sizing: border-box;
    animation: marquee 120s linear infinite;
    background: red;
    color:white;
}
@keyframes marquee {
    0%   { text-indent: -150em }
    100% { text-indent: 0em }
}
<p class="marquee">creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits • creativity without limits<span style="white-space: pre-wrap;"></span></p>

Thanks in advance



from Marquee speed up and slow down in intervals

Firebase Web Read from Real-Time Database

I'm trying to display the user's price that they entered in the database, but I'm getting "undefined' back instead of the value that was entered. I didn't get any errors in the console either. How can I fix this? I am using html, js, and css. I have provided a screenshot and my code. Thanks!

Studio Dashboard JS:

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

// Initialize variables
const database = firebase.database();
const auth = firebase.auth();

//const auth = getAuth();
firebase.auth().onAuthStateChanged((user) => {
    if (user) {
        readData();
        // ...
    } else {
        window.location.href = "login.html?error";
        alert("No active user please sign or sign up.");
    }
});

function readData() {

    const user = firebase.auth().currentUser;

    database.ref('/studiopick/studio/users/' + user.uid).get().then(snapshot => {

        //Tab One Display
        document.getElementById("studioName").innerText = snapshot.val().studioName;
        document.getElementById("profile-name").innerText = snapshot.val().studioName;
        document.getElementById("firstName").innerText = snapshot.val().firstName;
        document.getElementById("lastName").innerText = snapshot.val().lastName;
        document.getElementById("lastName").innerText = snapshot.val().lastName;
        document.getElementById("email").innerText = snapshot.val().email;
        document.getElementById("phoneNumber").innerText = snapshot.val().phoneNumber;

        //Tab Two Display
        document.getElementById("servicePrice").innerText = snapshot.val().numberInput;
    }).catch(e => { console.log(e) })
}

function updatePrice() {
    //Get data
    numberInput = document.getElementById("numberInput").value;

    const user = firebase.auth().currentUser;

    //Enter database location
    firebase
        .database()
        .ref('/studiopick/studio/users/' + user.uid + "/prices/roomA/serviceOne")
        .update({
            //studioName : studioName,
            numberInput: numberInput,
        });
}

enter image description here

enter image description here



from Firebase Web Read from Real-Time Database

Saturday, 1 October 2022

Instantiate threading within a class

I have a class within a class and want to activate threading capabilities in the second class. Essentially, the script below is a reproducible template of my proper project.

When I use @threading I get that showit is not iterable, so the tp.map thinks I do not have a list.

However, when I run:

if __name__ == '__main__':
    tp = ThreadPoolExecutor(5)
    print(tp.map(testit(id_str).test_first, id_int))
    for values in tp.map(testit(id_str).test_first, id_int):
        values

I get no issues, besides that I want the expected output to print out each number in the list. However, I wanted to achieve this within the class.

Something like the following:

from concurrent.futures import ThreadPoolExecutor
from typing import List

id_str = ['1', '2', '3', '4', '5']
id_int = [1, 2, 3, 4, 5]

def threaded(fn, pools=10):
    tp = ThreadPoolExecutor(pools)
    def wrapper(*args):
        return tp.map(fn, *args)  # returns Future object
    return wrapper

class testit:
    def __init__(self, some_list: List[str]) -> None:
        self._ids = some_list
        print(self._ids)

    def test_first(self, some_id: List[int]) -> None:
        print(some_id)

class showit(testit):
    def __init__(self, *args):
        super(showit, self).__init__(*args)
    
    @threaded
    def again(self):
        global id_int
        for values in self.test_first(id_int):
            print(values)

a = showit(id_str)
print(a.again())

Error:

  File "test_1.py", line 32, in <module>
    print(a.again())
  File "test_1.py", line 10, in wrapper
    return tp.map(fn, *args)  # returns Future object
  File "/Users/usr/opt/anaconda3/lib/python3.8/concurrent/futures/_base.py", line 600, in map
    fs = [self.submit(fn, *args) for args in zip(*iterables)]
TypeError: 'showit' object is not iterable

Expected output:

1
2
3
4
5



from Instantiate threading within a class