06 September, 2024
Python Web scraping [D:websockets.client] > GET %s HTTP/1.1 [D:websockets.client] > %s: %s doesn't show all the results
Programing Coderfunda September 06, 2024 No comments
winrt::hresult_class_not_registered - AudioEffectDefinition with custom effect
Programing Coderfunda September 06, 2024 No comments
#include "MyAudioEffect.g.h"
auto effectName = winrt::name_of();
auto effect = winrt::Windows::Media::Effects::AudioEffectDefinition(effectName);
// Exception thrown
// winrt::hresult_class_not_registered
// 80040154 - Class not registered
I made a MRE:
https://github.com/tom-huntington/MRE_ClassNotRegistered
/>
To create the .idl .h .cpp files for the MyAudioEffect class, I used the template
-> Add -> New Item -> Custom Control (WinUI 3)
How do I register the class? Can someone fix my MRE please?
05 September, 2024
Why does emptyArray.every() return true in Javascript?
Programing Coderfunda September 05, 2024 No comments
Error with uno module when using unoconv for file conversion in Python: 'Cannot find a suitable pyuno library' despite venv setup
Programing Coderfunda September 05, 2024 No comments
I am doing this with Python and LibreOffice. I have installed everything, but it always gives me an error message with uno, although I have inhaled it. With Python, I actually always need venv.
I once asked ChatGPT for a Python script:
import subprocess
import os
def convert_pdf_to_odt(pdf_file):
# Überprüfen, ob die Datei existiert
if not os.path.exists(pdf_file):
print(f"Die Datei {pdf_file} wurde nicht gefunden.")
return
# Zielpfad: gleiche Datei mit der Endung .odt
output_file = os.path.splitext(pdf_file)[0] + '.odt'
try:
# Verwende unoconv, um das PDF in ODT zu konvertieren
subprocess.run(['unoconv', '-f', 'odt', pdf_file], check=True)
print(f"Erfolgreich konvertiert: {pdf_file} -> {output_file}")
except subprocess.CalledProcessError as e:
print(f"Fehler bei der Konvertierung: {e}")
if __name__ == "__main__":
# Beispiel-PDF-Datei (Pfad zur Datei anpassen)
pdf_file = '/home/ben/convert-commander/test/pdfs/Bild4.pdf'
# Konvertiere die PDF-Datei in ODT
convert_pdf_to_odt(pdf_file)
When executing, it gives me the error message:
unoconv: Cannot find a suitable pyuno library and python binary combination in /usr/lib/libreoffice
ERROR: No module named 'uno'
unoconv: Cannot find a suitable office installation on your system.
ERROR: Please locate your office installation and send your feedback to:
http://github.com/dagwieers/unoconv/issues
/> Fehler bei der Konvertierung: Command '['unoconv', '-f', 'odt', '/home/ben/convert-commander/test/pdfs/Bild4.pdf']' returned non-zero exit status 1.
As I said, I am in a venv
Can you help me?
Thanks!
(translated with deepl from german)
How to Locate and Interact with Elements Inside Shadow DOM and iframe in Selenium?
Programing Coderfunda September 05, 2024 No comments
HTML elements
How do I locate Shadow DOM (either CSS Selector, XPATH, etc.)?
The page I am trying to scrape is: scrape.do
P.S. I was aiming for the iframe in this way:
iframe = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, 'cf-chl-widget-3kwf9'))
)
When to use livewire by understanding jetstream ? (See description)
Programing Coderfunda September 05, 2024 No comments
When I looked at the views (here's the link: views folder), it seems like they’re mixing traditional Blade templates with small Livewire components here and there, rather than going all-in with Livewire. The entry point for these routes tends to be a show.blade.php file, which centralizes the layout for the page.
Another thing I found curious is that the Http/Livewire directory is pretty flat (see it here: Livewire Directory). It doesn’t use a livewire folder inside the views directory like some other setups might. This got me thinking about how this might affect organization and scaling as the project gets bigger.
My Take on It:
I actually like the idea of organizing things by feature—it keeps everything focused and easy to find. And having that single entry point like show.blade.php makes the layout more predictable. If this were my own project, whether personal or for a company, I’d probably do something similar. However, I might lean towards using Volt instead of class-based Blade components because I like how everything stays in one place with Volt—it just feels tidier to me.
I’m also thinking about the approach of starting with a controller. It’s a good starting point, but the tricky part is deciding when to shift from Blade over to Livewire. Jetstream seems to mix actions with inline logic in places like DeleteUserForm.php, which can be pretty flexible. But it does raise questions about maintainability and where to draw the line between keeping things simple and being overly granular.
I’d love to hear how others are handling similar setups or any thoughts on where Jetstream could do things differently. What would you change if it was your personal/enterprise project? submitted by /u/Eznix86
[link] [comments]
gpg check fails when installing wp-cli using ansible role debops.wpcli
Programing Coderfunda September 05, 2024 No comments
I have this in my meta/main.yml:
---
dependencies:
- role: debops.debops.wpcli
I have this in my ansible log:
TASK [debops.debops.wpcli : Install required APT packages] *********************
ok: [webserver]
Thursday 05 September 2024 06:45:21 +0000 (0:00:02.504) 0:01:21.198 ****
Thursday 05 September 2024 06:45:21 +0000 (0:00:02.504) 0:01:21.197 ****
TASK [debops.debops.wpcli : Create wp-cli source directory] ********************
changed: [webserver]
Thursday 05 September 2024 06:45:21 +0000 (0:00:00.852) 0:01:22.051 ****
Thursday 05 September 2024 06:45:21 +0000 (0:00:00.852) 0:01:22.050 ****
TASK [debops.debops.wpcli : Download wp-cli release files] *********************
skipping: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.2.0/wp-cli-2.2.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.2.0.phar.gpg', 'checksum': 'sha256:6ed3c78adea2801ce900f3dc8f09ce799958955cc842b5f8d17d8ffb74eca7a2', 'version': '2.2.0'})
skipping: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.2.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.2.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.2.0'})
skipping: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.3.0/wp-cli-2.3.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.3.0.phar.gpg', 'checksum': 'sha256:24e16d96d22baec166ffb8807bf751cabd62b84e1716523f94d61b2a8d7e2255', 'version': '2.3.0'})
skipping: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.3.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.3.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.3.0'})
skipping: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.4.0/wp-cli-2.4.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.4.0.phar.gpg', 'checksum': 'sha256:c009a0d9e84436eab671272ca0d0a75b5aefd1af17177c83c2b33ad945976def', 'version': '2.4.0'})
skipping: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.4.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.4.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.4.0'})
changed: [webserver] => (item={'url': '
https://github.com/wp-cli/wp-cli/releases/download/v2.5.0/wp-cli-2.5.0.phar.gpg', 'dest': '/usr/local/src/wpcli/wp-cli-2.5.0.phar.gpg', 'checksum': 'sha256:a5faf98302ac3c96f0aad38e5d1a7142cfbd28fc2df03c687094b3fbf67a19a8', 'version': '2.5.0'})
changed: [webserver] => (item={'url': '
https://raw.githubusercontent.com/wp-cli/wp-cli/v2.5.0/utils/wp-completion.bash', 'dest': '/usr/local/src/wpcli/wp-cli-2.5.0.completion.bash', 'checksum': 'sha256:443ca0610ccae8d2d6aceba0ec4aa7929b87ed6cf54f666afed18d663a18a395', 'version': '2.5.0'})
Thursday 05 September 2024 06:45:24 +0000 (0:00:02.864) 0:01:24.916 ****
Thursday 05 September 2024 06:45:24 +0000 (0:00:02.864) 0:01:24.915 ****
TASK [debops.debops.wpcli : Verify and install wp-cli binary] ******************
fatal: [webserver]: FAILED! => changed=true
cmd: set -o nounset -o pipefail -o errexit && gpg --batch --decrypt --output /usr/local/src/wpcli/wp-cli-2.5.0.phar /usr/local/src/wpcli/wp-cli-2.5.0.phar.gpg && ( install --mode 755 --owner root --group root /usr/local/src/wpcli/wp-cli-2.5.0.phar /usr/local/bin/wp && install --mode 644 --owner root --group root /usr/local/src/wpcli/wp-cli-2.5.0.completion.bash /etc/bash_completion.d/wp-completion ) || ( rm -f /usr/local/src/wpcli/wp-cli-2.5.0.phar && exit 2 )
delta: '0:00:00.092231'
end: '2024-09-05 06:45:25.499750'
msg: non-zero return code
rc: 2
start: '2024-09-05 06:45:25.407519'
stderr: |-
gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: Signature made Wed May 19 15:24:41 2021 UTC
gpg: using RSA key 63AF7AA15067C05616FDDD88A3A2E8F226F0BC06
gpg: issuer "releases@wp-cli.org"
gpg: Can't check signature: No public key
stderr_lines:
stdout: ''
stdout_lines:
For me this reads as:
* I am using the debops role wpcli in the correct way because it starts installing WP-CLI
* But the currect public key that is used to sign WP-CLI is not found
Is my assumption correct?
How do I fix this problem?
04 September, 2024
GitHub Desktop is not signing GPG key automatically
Programing Coderfunda September 04, 2024 No comments
I also tried setting the path of the gpg program in .gitconfig to
[gpg]
program = "C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe"
However, if I try to open the repo in Command Prompt, it actually works (it allows me to commit and enter the passphrase). I have correctly installed gpg4win and I'm on Windows 10. Can anyone help me here?
Chaperone Eloquent Models in Laravel 11.22
Programing Coderfunda September 04, 2024 No comments
The Laravel team released v11.22 this week, with the chaperone() Eloquent method for inverse relations, support for passing backed Enums to Queuable methods, the ability to pass backed Enums to route ->name() and ->domain() methods, and more.
Chaperone Eloquent Relations
Samuel Levy contributed the Eloquent inverse/chaperone model relation that Taylor demonstrated in his 2024 Larcon US keynote during the open-source part of the talk.
public function comments(): HasMany
{
return $this->hasMany(Comment::class)->chaperone('post');
}
The chaperone()/inverse() method avoids unexpected N+1 queries by linking back to the parent after the relationship query has run. The above relationship will link the appropriate Post model in the correct relation on Comment instances (with scopes intact).
See Pull Request #51582 for more details.
Support Backed Enum in the Queueable Trait
Seth Phat contributed support for BackedEnum in Queuable trait methods:
*
onQueue()
*
onConnection()
*
allOnQueue()
*
allOnConnection()
Here's an example from the pull request:
use App\Enums\QueueConnection;
use App\Enums\QueueName;
// Before
public function register()
{
$user = User::create([...]);
SendWelcomeEmailJob::dispatch($user)
->withConnection(QueueConnection::REDIS->value)
->onQueue(QueueName::HIGH->value);
}
// After
public function register()
{
$user = User::create([...]);
SendWelcomeEmailJob::dispatch($user)
->withConnection(QueueConnection::REDIS)
->onQueue(QueueName::HIGH);
}
Allow Enums to be Passed to Routes
@NickSdot contributed passing BackedEnum to Route domain() and name() methods:
// Before
Route::domain(InterfaceDomain::Marketing->value)
->name(Routes::Home->value)
->get('/contact', ContactController::class);
// After
Route::domain(InterfaceDomain::Marketing)
->name(Routes::Home)
->get('/'contact, ContactController::class);
Release notes
You can see the complete list of new features and updates below and the diff between 11.21.0 and 11.22.0 on GitHub. The following release notes are directly from the changelog:
v11.22.0
* [11.x] Fix FoundationServiceProvider docblock by @seriquynh in
https://github.com/laravel/framework/pull/52542
/>
* [11.x] Fix ReflectionParameter @param type on Util::getContextualAttributeFromDependency() by @samsonasik in
https://github.com/laravel/framework/pull/52541
/>
* [11.x] More specific parameter type in CastsInboundAttributes by @lorenzolosa in
https://github.com/laravel/framework/pull/52536
/>
* [11.x] Unify prefetch API by @timacdonald in
https://github.com/laravel/framework/pull/52550
/>
* [11.x] Add PDO subclass support for PHP 8.4 by @ju5t in
https://github.com/laravel/framework/pull/52538
/>
* [11.x] Handle circular references in model serialization by @samlev in
https://github.com/laravel/framework/pull/52461
/>
* [11.x] Eloquent inverse relations by @samlev in
https://github.com/laravel/framework/pull/51582
/>
* [11.x] Feature/whereany closures by @liamduckett in
https://github.com/laravel/framework/pull/52555
/>
* [11.x] Update remaining workflows to run on latest possible ubuntu version by @Jubeki in
https://github.com/laravel/framework/pull/52566
/>
* Correct comments to better represent the updated method functionality by @dropweb in
https://github.com/laravel/framework/pull/52564
/>
* [11.x] Support CSP nonce by @timacdonald in
https://github.com/laravel/framework/pull/52558
/>
* [11.x] Allow enums to be passed to routes by @NickSdot in
https://github.com/laravel/framework/pull/52561
/>
* [11.x] SORT_NATURAL on Collection no longer throws warning for nulls by @Chaplinski in
https://github.com/laravel/framework/pull/52557
/>
* [11.x] Allow prefetch to start on custom event by @timacdonald in
https://github.com/laravel/framework/pull/52574
/>
* [11.x] Fix regression in database assertions with custom model connections by @devfrey in
https://github.com/laravel/framework/pull/52581
/>
* [11] Update DetectsLostConnections.php by @webartisan10 in
https://github.com/laravel/framework/pull/52614
/>
* Fix docblock for Model::getEventDispatcher() by @inmula in
https://github.com/laravel/framework/pull/52602
/>
* [11.x] Restore Request::HEADER_X_FORWARDED_PREFIX in TrustProxies by @taka-oyama in
https://github.com/laravel/framework/pull/52598
/>
* [11.x] Accepts BackedEnum for onQueue, onConnection, allOnQueue, and allOnConnection methods in the Queueable trait by @sethsandaru in
https://github.com/laravel/framework/pull/52604
/>
* [11.x] Use the same parameter type for 'throwUnless' as used for 'throwIf' by @pataar in
https://github.com/laravel/framework/pull/52626
/>
* [11.x] Pass iterable keys to withProgressBar in InteractsWithIO by @robinmoisson in
https://github.com/laravel/framework/pull/52623
/>
* [11.x] Fix docblock for Filesystem::hash() by @sunaoka in
https://github.com/laravel/framework/pull/52630
/>
* Fix Apostrophe Handling in SeeInOrder.php and Enhance Test Coverage by @nomitoor in
https://github.com/laravel/framework/pull/52627
/>
* [11.x] SQLite Error: "General error: 1 no such table" after adding a foreign key when using a table prefix. by @incrize in
https://github.com/laravel/framework/pull/52578
/>
The post Chaperone Eloquent Models in Laravel 11.22 appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Has Microsoft changed anything that could be causing DdeConnect to delay after the startup of the computer?
Programing Coderfunda September 04, 2024 No comments
When starting our appliction the DdeConnet makes it delay with 30 minutes eventhough it doens't fail. It wasn't like this before. It worked instantly.
Can we honoured Intent flag value over Manifest in launch mode when intent flag and manifest launch mode is different?
Programing Coderfunda September 04, 2024 No comments
So, if Activity A starts Activity B, Activity B can define in its manifest how it associates with the current task, and Activity A can use an intent flag to request how Activity B can associate with current task.
If both activities define how Activity B associates with a task, then Activity A's request, as defined in the intent, is honored over Activity B's request, as defined in its manifest.
when Activity B can define in its manifest how it associates with the current task is different(single Top) , and Activity A can use an intent flag to request how Activity B can associate with current task is different example(new task).
what will be honored over whom?
Multipart file is not present in SB3
Programing Coderfunda September 04, 2024 No comments
Endpoint is defined as RestController:
@PatchMapping(value = "/users/test", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public List userTest(
@Parameter(content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE))
@RequestPart(value = "file") MultipartFile file) {
System.out.println(file.getContentType());
return operationResourceService.parseFile(file);
}
The endpoint is designed only to print out the content of the CSV file. Since this is Spring Boot 3 there is no need to define any MultipartResolver, because the default resolver now is the StandardServletMultipartResolver.
After request is sent to the backend, exception is thrown:
org.springframework.web.multipart.support.MissingServletRequestPartException: Required part 'file' is not present.
After detail debug found out that this part of the code is throwing this same exception:
if (arg == null && isRequired) {
if (!MultipartResolutionDelegate.isMultipartRequest(servletRequest)) {
throw new MultipartException("Current request is not a multipart request");
}
else {
throw new MissingServletRequestPartException(name); // EXCEPTION
}
}
But main cause is that method resolveMultipartArgument is returning null from some strange reason...
Object mpArg = MultipartResolutionDelegate.resolveMultipartArgument(name, parameter, servletRequest); // Returns null
if (mpArg != MultipartResolutionDelegate.UNRESOLVABLE) {
arg = mpArg; // This is the line where arg is assigned as null
}
03 September, 2024
how to fix width of child div tag
Programing Coderfunda September 03, 2024 No comments
But is there a better way than this so that the child tag appears exactly inside the parent tag?
UPDATE
I want to keep position: fixed for child tag
.parent {
height: 300px;
padding: 10px;
border: 1px solid red;
}
.child {
position: fixed;
height: 100px;
width: 100%;
border: 1px solid black;
}
Function not showing up in list
Programing Coderfunda September 03, 2024 No comments
https://www.exceldemy.com/learn-excel/geocoding/ I created a new module and used Tools/References to check Microsoft XML, 6.0. Then I pasted this code into the new module:
Function Co_Ordinates(address As String) As String
Application.Caller.Font.ColorIndex = xlNone
Dim xDoc As New MSXML2.DOMDocument
xDoc.async = False
xDoc.Load ("
https://nominatim.openstreetmap.org/search?format=xml&q=" + WorksheetFunction.EncodeURL(address))
If xDoc.parseError.ErrorCode 0 Then
Application.Caller.Font.ColorIndex = vbErr
Co_Ordinates = xDoc.parseError.reason
Else
xDoc.SetProperty "SelectionLanguage", "XPath"
Dim loc As MSXML2.IXMLDOMElement
Set loc = xDoc.SelectSingleNode("/searchresults/place")
If loc Is Nothing Then
Application.Caller.Font.ColorIndex = vbErr
NominatimGeocode = xDoc.XML
Else
Application.Caller.Font.ColorIndex = vbOK
Co_Ordinates = loc.getAttribute("lat") & "," & loc.getAttribute("lon")
End If
End If
End Function
But when I select the top line in the function and click the run arrow, I get a pop-up list of macros that does not include Co_Ordinates. The image below shows what I see. Also, if I use that function in a cell (=Co_Ordinates(K12)), I get a Name? error. What am I doing wrong?
MinimumOSVersion in 'MyProject.app/Frameworks/hermes.framework' is ''. in react native
Programing Coderfunda September 03, 2024 No comments
Invalid minimumOSversion. Apps that only support 64-bit devices must
specify a deployment target of 8.0 later. MinimumOSVersion in
'CPOD_Recap_Revamp.app/Frameworks/hermes.framework' is ''.
I have tried several solutions, but nothing worked:
* Deleting and install node_modules folder
* Deleting and install package-lock.json
* Deleting and install Pods folder
* Deleting and install Podfile.lock
* Defining minimumOSVerion in info.plist
How do I pass data directly from Google Cloud TTS SynthesizeSpeechResponse object to sounddevice without creating a file on disk
Programing Coderfunda September 03, 2024 No comments
How do I pass data from google.cloud.texttospeech_v1.types.cloud_tts.SynthesizeSpeechResponse object to sounddevice play function without creating an audio file on disk
Problem
Data supplied by SynthesizeSpeechResponse has RIFF WAV header information in byte stream, but I do not know how to manipulate it as such. Can easily save file to disk, then read that file to play audio, but want to keep data in memory without write to disk.
err=LibsndfileError(2, 'Error opening b\'RIFF\\xcbt\\x00\
response.doc reminds us that "Note: as with all bytes fields, protobuffers use a pure binary representation, whereas JSON representations use base64.", but I do not find a way to access this JSON readily.
Environment
* torch base platform (CUDA 11.8)
* google-3.0.0
* google-cloud-texttospeech-2.17.2
* transformers-4.44.1
* soundfile-0.11.1
* sounddevice-0.5.0
* numpy-1.26.4
Code
import soundfile as sf
import sounddevice as sd
from transformers import pipeline
from google.cloud import texttospeech
text_to_speak = "The quick brown fox"
google_client = texttospeech.TextToSpeechClient()
input_text = texttospeech.SynthesisInput(text=text_to_speak)
selected_voice_name = "en-US-Standard-B"
voice = texttospeech.VoiceSelectionParams(
language_code=selected_voice_name[:4],
name=selected_voice_name,
ssml_gender=texttospeech.SsmlVoiceGender.FEMALE,
)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.LINEAR16 # MULAW # ALAW
)
response = google_client.synthesize_speech(
input=input_text, voice=voice, audio_config=audio_config
)
# The below works by creating file on disk, then reading and playing that file
output_file_name = "google_cloud_tts_output.wav"
with open(output_file_name, "wb") as out:
out.write(response.audio_content)
r_data, r_samplerate = sf.read(output_file_name)
sd.play(r_data, r_samplerate)
# The below does not work
# AttributeError: Unknown field for SynthesizeSpeechResponse: decode
sd.play(response.decode(response.audio_content), 16000)
# The below does not work because the data type is unsupported
# In this case the '674416' is subject to change, it could be a five or six digit number
# TypeError: Unsupported data type: 'bytes674416'
sd.play(response.audio_content, 16000)
# The below does not work because the data is malformatted
# File "c:\Projects\ventriloquist\.venv\lib\site-packages\soundfile.py", line 1216, in _open
# raise LibsndfileError(err, prefix="Error opening {0!r}: ".format(self.name))
# soundfile.LibsndfileError: Error opening b'RIFFFI\x01\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\xc0]\x00\x00\x80\xbb\x0
# ...
# xff\xf0\xff\xf2\xff\xee\xff': System error.
sd.play(sf.read(response.audio_content), 16000)
# The below does not work because the data is malformatted
# ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
import io
io_ir = io.BytesIO(response.audio_content)
sd.play(sf.read(io_ir), 16000)
When working with speech synthesis data returned by Hugging Face transformers, it is easy to convert this data object to what sounddevice is expecting:
speech = tts_model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
sd.play(speech.numpy(), 16000)
When working with the Google Cloud TTS SynthesizeSpeechResponse object, the expectation is to write the contents to a wave or MP3 file; details on the format of the data provided by the SynthesizeSpeechResponse object are not provided, but empirically we know that it is formatted to be readily saved to disk.
The below does not work
AttributeError: Unknown field for SynthesizeSpeechResponse: decode
sd.play(response.decode(response.audio_content), 16000)
The below does not work because the data type is unsupported
In this case the '674416' is subject to change, it could be a five or six digit number
TypeError: Unsupported data type: 'bytes674416'
sd.play(response.audio_content, 16000)
The below does not work because the data is malformatted
File "c:\Projects\ventriloquist.venv\lib\site-packages\soundfile.py", line 1216, in _open
raise LibsndfileError(err, prefix="Error opening {0!r}: ".format(self.name))
soundfile.LibsndfileError: Error opening b'RIFFFI\x01\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\xc0]\x00\x00\x80\xbb\x0
...
xff\xf0\xff\xf2\xff\xee\xff': System error.
sd.play(sf.read(response.audio_content), 16000)
Some methods already tried
The below does not work because the data is malformatted
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
import io
io_ir = io.BytesIO(response.audio_content)
sd.play(sf.read(io_ir), 16000)
Pinkary is now fully open source
Programing Coderfunda September 03, 2024 No comments
Pest creator and Laravel core team member Nuno Maduro announced recently that Pinkary is now fully open source, and you can also find us on it at @laravelnews.
Built with Laravel, Livewire, Tailwind, and more, Pinkary is an excellent example of a full Laravel application you can learn from and contribute to:
Pinkary is already a thriving project, with over 400+ submitted pull requests, and is encouraging open-source contributions and giving you the installation instructions you need to go from project setup to pull request. Pinkary is already using Pest 3, and as the creator of Pest, the code has plenty of examples you can learn from to level up your testing skills.
On the user side of this project, Pinkary is a landing page for all your links and a place where you can connect with like-minded people without the noise of other social media applications. It went from a new project to over a thousand users very quickly and is known for using a SQLite database for application data, sessions, queues, cache, etc.
Start learning from the Pinkary source code today! Visit pinkary-project/pinkary.com on GitHub and join this exciting open-source project.
The post Pinkary is now fully open source appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
02 September, 2024
Angular: how to call router.navigate() relative to target route in a RouteGuard?
Programing Coderfunda September 02, 2024 No comments
[
{ path: '', redirectTo: '/myApp/home(secondary:xyz)', pathMatch: 'full' },
{ path: 'myApp'
children: [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', ... },
...
{ path: 'product'
children: [
{ path: '', redirectTo: 'categoryA', pathMatch: 'full' },
{ path: 'categoryA', component: CategoryAComponent, canActivate: [CategoryACanActivateGuard]},
{ path: 'categoryB', component: CategoryBComponent},
...
]
},
...
]
},
...
]
Now, I want to control the access to www.myWeb.com/myApp/product/categoryA. If the user doesn't have enough permission, he/she will be redirected to ... /product/CategoryB. I have written a CanActivate RouteGuard to do this, the guard class looks like this:
import { Injectable } from '@angular/core';
import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute } from '@angular/router';
import { MyService } from '... my-service.service';
@Injectable()
export class CategoryACanActivateGuard implements CanActivate {
constructor(private myService: MyService, private router: Router) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise {
return this.myService.checkPermission()
.then(result => {
if (!result.hasAccess) {
//redirect here
this.router.navigate(['./myApp/product/categoryB']);
//works, but I want to remove hardcoding 'myApp'
//this.router.navigate(['../../categoryB']);
//doesn't work, redirects to home page
//this.router.navigate(['./categoryB'], { relativeTo: this.route});
//do not have this.route object. Injecting Activated route in the constructor did not solve the problem
}
return result.hasAccess;
});
}
}
Everything works fine, but I want redirect relative to the target route like the following:
this.router.navigate(['/product/categoryB'], { relativeTo: });
// or
this.router.navigate(['/categoryB'], { relativeTo: });
Unfortunately, relativeTo accepts only ActivatedRoute objects and all I have is ActivatedRouteSnapshot and RouterStateSnapshot. Is there a way to navigate relative to the target route (in this case categoryA)? Any help will be really appreciated.
Note:
* I can not change the route configuration other than adding some route-guards.
* I am not looking looking for this.router.navigateByUrl using state.url. I want to use router.navigate([...], { relativeTo: this-is-what-need}).
Control user to login from only specific device that provided to the user
Programing Coderfunda September 02, 2024 No comments
as per @Joundill In reality, it won't be possible for you to securely restrict access to individual devices through the web. We have made some extra level of authentications in our software to authenticate the users (Added client side certificate on each devices and based on that the user can't access the site from other devices: i.e: how to use client certificates to access website) now it's resolved.
Original Question
I am trying to develop the software for college students, we will provide device to the students (tab/laptops) they must need to log in their credentials using the device that we provided to the student. E.g. If student 1 tried to log in from student 2's tab/laptop, then it needs to be rejected.
Is there any way available to get the MAC address of the client's PC using PHP, and JavaScript?
We developed web applications using PHP 5.3 with jQuery and JS, also another is Laravel with PHP 8.1.
Is there any best way available to restrict the user to login from only the device specified?
I have tried by controlling the user via MAC address using this answer but it's not working in our case.
Is there a way to calculate "suggestedMaxPriorityFeePerGas and suggestedMaxFeePerGas", same way the INFURA Gas API do for BNB Network
Programing Coderfunda September 02, 2024 No comments
{
"low": {
"suggestedMaxPriorityFeePerGas": "4.7",
"suggestedMaxFeePerGas": "4.7",
"minWaitTimeEstimate": 15000,
"maxWaitTimeEstimate": 60000
},
"medium": {
"suggestedMaxPriorityFeePerGas": "4.85",
"suggestedMaxFeePerGas": "4.85",
"minWaitTimeEstimate": 15000,
"maxWaitTimeEstimate": 45000
},
"high": {
"suggestedMaxPriorityFeePerGas": "4.9",
"suggestedMaxFeePerGas": "4.9",
"minWaitTimeEstimate": 15000,
"maxWaitTimeEstimate": 30000
},
"estimatedBaseFee": "0.0",
"networkCongestion": 0,
"latestPriorityFeeRange": [
"4.85",
"4.85"
],
"historicalPriorityFeeRange": [
"4.85",
"5"
],
"historicalBaseFeeRange": [
"0",
"0"
],
"priorityFeeTrend": "down",
"baseFeeTrend": "down",
"version": "0.0.1"
}
suggestedMaxPriorityFeePerGas returned by API for low, medium and high are not static.
My question is how can I calculate the suggestedMaxFeePerGas when suggestedMaxPriorityFeePerGas is dynamic and the baseFee is zero too (not just in this case. it's always zero, for BNB).
I'm a beginner and what I know is that the
MaxFeePerGas = BaseFeePerGas + MaxPriorityFeePerGas
But in this case baseFeePerGas is 0 & MaxPriorityFeePerGas is dynamic (which I can't figure out, how to calculate)
How to cast an HTMLElement to a React element?
Programing Coderfunda September 02, 2024 No comments
let sub = React.createElement('p', null, 'Made with React'),
main = React.createElement('div', null, [sub])
React.render(main, document.getElementById('app'));
It renders with the content
Made with React. If I try it with document.createElement instead, nothing is rendered.
let sub = document.createElement('p');
sub.innerText = 'Not React';
let main = React.createElement('div', null, [sub])
React.render(main, document.getElementById('app'));
I have currently found a workaround using dangerouslySetInnerHTML.
let sub = document.createElement('p');
sub.innerText = 'Not React';
let main = React.createElement('div', {dangerouslySetInnerHTML: {__html: sub.outerHTML}});
React.render(main, document.getElementById('app'));
This renders but doesn't seem safe. What is the proper way to append HTMLElement as React child elements?
01 September, 2024
How to generate a parse error after exactly one expression
Programing Coderfunda September 01, 2024 No comments
start :
expression
;
expression
:
| dateOperatorExpression
| numberOperatorExpression
| stringOperatorExpression
| methodBooleanExpression
| doubleMethodOperatorExpression
| numberInExpression
| stringInExpression
| bracketExpression
| andExpression
| orExpression
| notExpression
;
numberInExpression:
| WS? METHOD WS? IN WS? '{' WS? NUMBER (WS? ',' WS? NUMBER)* '}' WS?
;
stringInExpression:
| WS? METHOD WS? IN WS? '{' WS? STRING (WS? ',' WS? STRING)* '}' WS?
;
dateOperatorExpression:
| WS? DATE WS? OPERATOR WS? DATE WS?
| WS? DATE WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? DATE WS?
| WS? DATE WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? DATE WS?
;
numberOperatorExpression:
| WS? NUMBER WS? OPERATOR WS? NUMBER WS?
| WS? NUMBER WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? NUMBER WS?
| WS? NUMBER WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? NUMBER WS?
;
stringOperatorExpression:
| WS? STRING WS? OPERATOR WS? STRING WS?
| WS? STRING WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? STRING WS?
| WS? STRING WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? STRING WS?
;
doubleMethodOperatorExpression:
| WS? METHOD WS? OPERATOR WS? METHOD WS?
| WS? METHOD WS? OPERATOR WS? NULLVALUE WS?
| WS? NULLVALUE WS? OPERATOR WS? METHOD WS?
;
methodBooleanExpression:
| WS? METHOD WS? OPERATOR WS? BOOLEAN WS?
| WS? BOOLEAN WS? OPERATOR WS? METHOD WS?
;
bracketExpression:
| '(' WS? expression WS? ')'
;
andExpression
:
| AND WS? '(' expression (',' expression)* WS? ')'
;
orExpression
:
| OR WS? '(' expression (',' expression)* WS? ')'
;
notExpression
:
| NOT WS? expression
;
WS: (' ' | '\t' | '\r' | '\n')+ -> skip;
AND: 'AND' | 'and';
OR: 'OR' | 'or';
NOT: 'NOT' | 'not' | '!';
IN: 'IN' | 'in';
OPERATOR: '==' | '!=' | '>' | '=' | '= 25), not(father.address.street != null)), firstName in {"John", "Pete"})
The parser only takes and((retired == true)) and ignores the rest. So, I thought about simply changing the grammar as follows, and then printing a warning of multiple expressions were parsed:
start :
(expression)+
;
But this gives the error: "rule start contains a closure with at least one alternative that can match an empty string". Why is that? How can (expression)+ match an empty string, if expression can't?
How can I achieve what I want?
Thanks,
Patented Private Label Seller in Amazon [closed]
Programing Coderfunda September 01, 2024 No comments
Must-Know Tips for Efficient Laravel Apps (Not just selecting only needed columns, eager loading instead of lazy loading, caching queries, using queues, indexes, and more)
Programing Coderfunda September 01, 2024 No comments
I recently wrote an article on some essential tips for making your Laravel apps more efficient. But this isn’t just the typical like selecting only needed columns, eager loading, caching, or using indexes. I dive into some lesser-discussed but highly impactful strategies that can really make a difference in your app’s performance.
If you’re looking to optimize your Laravel projects beyond the usual tips, check it out!
👉 Must-Know Tips for Efficient Laravel Apps
Would love to hear your thoughts and any additional tips you might have! submitted by /u/summonshr
[link] [comments]
How to put a header file curses.h/ncurses.h for work in vscode? [duplicate]
Programing Coderfunda September 01, 2024 No comments
I tried to install it using some popular methods (linking), but nothing worked.
How to set the shutter time but leave the ISO (sensitivity) on auto on android
Programing Coderfunda September 01, 2024 No comments
I can set the SENSOR_EXPOSURE_TIME without any problem. But I want to keep the ISO (SENSOR_SENSITIVITY) on auto mode.
To set the shutter speed I use the following code:
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
mPreviewRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, EXPOSURE);
mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), null, surfaceView.getmBackgroundHandler());
This code works OK, but because the CONTROL_AE_MODE is set to CONTROL_AE_MODE_OFF the ISO (SENSOR_SENSITIVITY) has to be set manually also. And this is what I don't want, I want to keep the ISO on auto.
Is there any way to accomplish this or is there a workaround?
11 August, 2024
Minimum number that can fit in a box [closed]
Programing Coderfunda August 11, 2024 No comments