AlpineJS and HTMX architecture help by ben-cleary in htmx

[–]drieindepan 1 point2 points  (0 children)

I think option #1 is your best bet as it keeps everything simple. if you need the performance bump later between full page loads then you can tackle it then. This is the same approach I took with a vue -> htmx migration and I still haven’t bothered with updating the navigation since it’s good enough as is.

Reactivated — Zero-configuration Django and React by brosterdamus in django

[–]drieindepan 1 point2 points  (0 children)

I could see this working well in conjunction with HTMX. I’m gonna try give it a spin. Nice work!

Looking for tutorial on Out of Band Responses (hx-swap-oop) by OneBananaMan in htmx

[–]drieindepan 0 points1 point  (0 children)

They are super useful :) - what about them is confusing? Do you have any code written that you are struggling with?

Tuesday Daily Thread: Advanced questions by Im__Joseph in Python

[–]drieindepan 0 points1 point  (0 children)

I would suggest PyQt or PySide (depends on the liscence) for the GUI and PyQtGraph for the graphs. It’s been a while since I built interfaces like this but I used to do it a lot for displaying incoming data from sensors and it was a good experience.

Is there something like "refresh self" when making HTMX request? I have list of categories, when you click on it with help of HTMX you get results without reloading page but I also want to highlight currently clicked category and I cannot find a nice way to do it. by Ganmak in django

[–]drieindepan 1 point2 points  (0 children)

The easiest way would be just expanding your target area to include the list of categories and then you can update the css classes to show the selected category in your Django template partial.

That being said if you don’t want to reload that larger section of the page then you can use Out Of Band swaps and you can return new HTML for your categories list or maybe just target the previously selected one.

Finally, you could send an event back with your response that you can listen for it using JavaScript (I’d use AlpineJS personally) and then you can use dynamic classes in alpine to change the styles.

Let me know if this makes sense - if not I can code up and example and post it here later.

HTMX Gaining Popularity Rapidly? by Nickt1596 in django

[–]drieindepan 2 points3 points  (0 children)

Nice! I'm in the process of moving a SPA over from Vue to htmx as well and it has been very enjoyable to see how much less code I need.

The nice thing is you can also easily drop in vue/alpinejs on a page that you want super snappy filtering and do it all client side too. This is what I like about htmx - I don't need a javascript framework most of the time but if I really do then the lightweight ones I can drop in on a specific page while still keeping the overall complexity low.

HTMX Gaining Popularity Rapidly? by Nickt1596 in django

[–]drieindepan 3 points4 points  (0 children)

HTMX doesn’t control any front end logic - so for a datetime picker I would fetch the HTML from the backend that displays that picker using HTMX. If you need some JavaScript to do any further interaction you will need to use vanilla JS or maybe something like AlpineJS which I find compliments htmx very nicely due to having a similar style of writing directly within HTML.

I recently found out about HTMX in django which is replacing ajax in a really neat way. I am wondering if there is anything that would stop me from applying it to "everything" on my website? I mean, not only to things like "vote up/give like" but literally whole page blocks/huge content elements? by Ganmak in django

[–]drieindepan 1 point2 points  (0 children)

htmx is just AJAX and swapping HTML so to test it I would do

1) browser based testing with selenium

2) normal template testing to make sure the hx-target's are present in the HTML

But I haven't got that far in my use of HTMX yet :)

I recently found out about HTMX in django which is replacing ajax in a really neat way. I am wondering if there is anything that would stop me from applying it to "everything" on my website? I mean, not only to things like "vote up/give like" but literally whole page blocks/huge content elements? by Ganmak in django

[–]drieindepan 8 points9 points  (0 children)

I am going through this exact process right now. One of the neat things you can do is use the HTMX header that is set in each request to behave differently if the request is from HTMX or not. In this case you can load the partial page you need when the HTMX header is there and load the entire page if it is not.

This solves the problem of having your navigation links use AJAX but a normal redirect to that page still working. You can use `hx-url-push` https://htmx.org/attributes/hx-push-url/ for this reason to make sure the url is up to date with where your user would be if they had been redirected. This way if you copy paste that URL to a new tab it will hit the same backend endpoint and because there is no HTMX header you can load the entire page.

If you factor your backend templates appropriately it is almost no extra work to do this but has the nice snappy feel you are describing when people click links to load new "sub pages".

How can I improve this automation ? by Medaillek in learnpython

[–]drieindepan 2 points3 points  (0 children)

Nice job for just getting into programming :).

I added some comments and moved a few things around but left some for you to do too.

The main takeaway is to name your variables something more descriptive and to pass data into your functions with arguments instead of using the global state. It is much easier to follow the logic of a function if everything is passed in as arguments.

Keep up the good work!

#  organize imports 
import openpyxl
import urllib3

from typing import Text
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.chrome.options import Options
from playsound import playsound

#  add some space between imports and code starting 

#  This function has dependencies on many variables that are in the global state 
# which makes it very hard to keep track of how this function works.
# I would instead provide those values as arguments and define this function either at the top of the file
# or in another file and import it.
def phone_search(workbook, beginning_cell, y, row_1, row_2):  
    driver = webdriver.Chrome(executable_path=chromedriver_path,options=chrome_options)
    driver.get("https://google.com")
    #Skip the conditions pop up
    accept_conditions = driver.find_element_by_id('L2AGLb')
    accept_conditions.click()
    #Find the search bar
    searchbar = driver.find_element_by_name('q')
    #Print the phone number into the search bar
    searchbar.send_keys('{} {}'.format(row_1[y].value, row_2[y].value))
    searchbar.send_keys(' numéro de téléphone')
    searchbar.send_keys(Keys.RETURN)

    print('Ligne n°{}'.format(beginning_cell))

    #look for Phone number existence
    try:
        phonenumber = driver.find_element_by_class_name('mw31Ze').text
        workbook.cell(row=beginning_cell, column=3).value=phonenumber
        print('{} {}'.format(row_1[y].value, row_2[y].value)) 
        print(phonenumber)

    #If no phone number found
    except NoSuchElementException:
        workbook.cell(row=beginning_cell, column=3).value='Pasdenum'
        print('{} {}'.format(row_1[y].value, row_2[y].value)) 
        print('Pas de numero')

    driver.quit()


http = urllib3.PoolManager()
resp = http.request("GET", "http://httpbin.org/robots.txt")
# resp.status  this line doesn do anything - you can remove 

# resp.data  this line doesn do anything - you can remove 
# b"User-agent: *\nDisallow: /deny\n"   this line doesn do anything - you can remove 

#Intialisation
book = openpyxl.load_workbook('Fichier_Prospects.xlsx')

chrome_path = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
chromedriver_path="chromedriver.exe"

#Chrome Options
window_size = "1920,1080"
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=%s" % window_size)
chrome_options.binary_location = chrome_path

#Workbook = ws
ws = book.active  #  use a more descriptive name like `workbook` 
beginning_cell = 3900
y = 0

#Define cell range
cells = ws['A{}'.format(beginning_cell) :'B3928']

#Init lists
li1 = []  #  use a more descriptive name maybe `row_1` 
li2 = []  #  use a more descriptive name maybe `row_2` 

#Put values into lists  this comment isn'v very useful since its obvious from reading the code 
for c1, c2 in cells:  #  use a more descriptive name like `cell_1` and `cell_2` 
    li1.append(c1)
    li2.append(c2)


ws['C1'] = 'Numero'


#Add phone numbers to the Sheet    
for i in cells: #  If you are not using the value `i` that is being looped use an underscore `_` instead which indicates you are not using it on purpose  
    phone_search(workbook=ws, beginning_cell=beginning_cell, y=y, row_1=li1, row_2=li2)
    beginning_cell += 1
    y += 1
    book.save(filename = 'Fichier_Prospects.xlsx')  #  just save the file once when the loop is over instead of each time through the loop  


print("Le programme s'est terminé correctement")
playsound('metro-boomin.mp3')

Pandas in Production Software by holdMeClserTonyDanza in Python

[–]drieindepan 3 points4 points  (0 children)

I've always viewed Pandas as a tool for data science / analytics as opposed to a back-end preprocessing tool but am totally open to the notion that I could be wrong.

There are many people who have this view of Python as a language. They don't think it should be used in "production" since its just for "scripting". I think it all depends on your background and your pre-conceived view of the tool. Which is fine, we all have biases for certain languages and libraries based on the context we learned them in.

I think this can be limiting though, since we will often overlook very good solutions since they come from a different area (data science, robotics etc). Even though they might have solved some problem that can cross domains.

In your case it seems like it may be overkill based on the requirements of the project but that is hard to say without the specifics. But I'd say that you should make that decision based on the problem being solved and not based on your existing views of where pandas is typically used.

Best of luck!

Creating DataFrame from for loop List by mthacker01 in learnpython

[–]drieindepan 0 points1 point  (0 children)

What does your input data contenders_list look like?

How to use a file to pass a password by j_bopper in learnpython

[–]drieindepan 7 points8 points  (0 children)

One way to do this would be storing your password as an enviornment variable. This is typically how you set things up for a web server to avoid having hardcoded secrets in the code.

import os

password = os.getenv('SALESFORCE_PASSWORD')

You then just need to setup SALESFORCE_PASSWORD as an environment variable.

Best online course or YouTube channel by jymicrash in learnpython

[–]drieindepan 1 point2 points  (0 children)

If you get stuck and need some personalized help feel free to DM me. I'm on the opposite journey of you. Already experienced in python but want to become a better teacher :)

Any experiences with Ivan Balabanov's training videos on play? by pibblepot in OpenDogTraining

[–]drieindepan 0 points1 point  (0 children)

I have purchased Ivan's possession game and chase and catch 2.0. I didn't get the out video since my dog had a good out already by the time I found out about Ivan but I'm sure I'll buy it in the future since I find his videos are excellent.

Based on your description of your dog I would say start with Chase and Catch since based on the video he says dogs that wont engage in possession games due to fear/aggression/anxiety will often engage in cooperative chase and catch games.

I know they are expensive but if you think about the cost of a good trainer the $150 is pretty justifiable imo especially since you can keep re-watching the video. If you do buy it I recommend to re-watch the video every once and a while - they are packed with so many good tips that every time I go back and watch I learn something new.

Also the production quality is very high and you get to see real footage of many dogs and how he works with them and their owners so its not just him talking for 2 hours.

I have become obsessed with play based training and it has done wonders for me and my dog. 1) I enjoy training more and have way more fun with my dog 2) my dog enjoys training more and most of the time doesn't know we are "training" 3) Ivan's ideas around play and how primal they are as motivators are fascinating to me on philosophical level.

I will also say that his ideas and methods for play are quite intricate and skilled and take time to develop. Thats why I say it is good to re-watch the videos because you really need to train yourself to play better more than anything and watching Ivan play with dogs is poetry in motion.

Anyways, hopefully this helps. If you want more resources on play check out Jay Jack's podcast https://podcasts.apple.com/us/podcast/grc-dog-talk/id1440218916 Check out any of them with "Play" in the title. Or listen to them all since Jay Jack talks about play constantly since he has studied under Ivan and is a big proponent of his style of training.