how to write the simple short code for parsing
Tag : php , By : hlpimfalling
Date : March 29 2020, 07:55 AM
help you fix your problem I'm working on my PHP to get the list of time. I'm using DomDocument to get the time, I want to find a way to reduce the code as I have got the 69 tags of time in my get-listing.php script. , Update the code to following, $time_arr = array();
for ($i = 1; $i < 70; $i++){
$time_arr[] = $xpath->query("*/span[@id='time".$i."']");
}
foreach($time_arr as $time){
echo $time->item(0)->nodeValue;
}
|
jQuery refactoring, how to make simple short code for this
Date : March 29 2020, 07:55 AM
like below fixes the issue They are different selectors and functions. But they are very similar. , Try toggleClass const toggle = function(what, on) {
$(".doc__footer__menu__" + what) .toggleClass('active', on);
$(".doc__footer__" + what) .toggleClass('active', on);
$(".doc__footer__" + what + "-close").toggleClass('active', on);
$('body').toggleClass('lock-scroll', on);
$('html').toggleClass('lock-scroll', on);
}
toggle('detail',true);
toggle('rel',true);
toggle('detail',false);
toggle('rel',false);
|
A simple, short code for movement
Date : March 29 2020, 07:55 AM
|
simple nltk sentiment analysis code using python3
Date : March 29 2020, 07:55 AM
|
How can I play an mp3 as a background process with Python3?
Date : October 04 2020, 04:00 AM
hop of those help? You need to call pygame.init() to initialize everything else. Also, use pygame.mixer.play(-1) to loop the song indefinitely. I don't know Daemonize, but based on the name, it probably spawns a detached thread. You're immediately exiting the main thread, forcing your song to stop. Try adding while 1: pass after daemon.start() import pygame
pygame.init()
from daemonize import Daemonize
from time import sleep
pid = '/tmp/mpee3.pid'
def startSong():
pygame.mixer.init()
pygame.mixer.music.load('test.mp3')
pygame.mixer.music.play(-1)
def main():
while pygame.mixer.music.get_busy():
sleep(0.1)
if __name__ == '__main__':
startSong()
daemon = Daemonize(app='mpee3', pid=pid, action=main)
daemon.start()
while 1:
pass
|