instruction
stringlengths
0
30k
|powerbi|deneb|
hi here is my code which is used to convert docx to pdf `$pythonPath = '/usr/bin/python'; $unoconvPath = '/usr/bin/unoconv'; $command = sprintf( '"%s" "%s" -f pdf "%s" 2>&1', $pythonPath, $unoconvPath, $docx_file_path ); exec($command, $output, $return); if (is_array($output) && !empty($output[0])) { throw new Exception(json_encode(implode('; ', $output), true)); } return true;` the image is visible when downloading docx using phpword with setImageValue function $document = new \PhpOffice\PhpWord1\TemplateProcessor($docx_temp_file_path);` $value = '/www/wwwroot/vss/webrootimages//b6e176e4b84968f6cda8d28b17394bf2.png'; $document->setImageValue($key, $value); the image is not visible when i convert docx to pdf
I'm trying to get my first Laravel project running with a freshly installed SQL Server instance, and my normal connections work. However, in Laravel, I get the error message "could not find driver" when I run the environment server with `php:artisan serve`. > Illuminate >  \  > Database >  \  > QueryException > PHP 8.2.15 > 11.0.8 > could not find driver > SELECT > top 1 * > FROM > [ sessions ] > WHERE > [ id ] = FnziuCl4Bh7mfDbUW4F3E0OQKfryNLEd21vPSyF3 php.ini shows me that SQL Server is enabled: sqlsrv sqlsrv support enabled ExtensionVer 5.11.1+17301 Directive Local Value Master Value sqlsrv.ClientBufferMaxKBSize 10240 10240 sqlsrv.LogSeverity 0 0 sqlsrv.LogSubsystems 0 0 sqlsrv.WarningsReturnAsErrors On On` **.env** DB_CONNECTION=sqlsrv DB_HOST=192.168.xx.xx DB_PORT=1433 DB_DATABASE=webdev_laravel DB_USERNAME=webdev_applikation DB_PASSWORD=password I tried the following: - server restart - clear cache I read a lot of other threads with the same error, but I don't want to use PDO, and I think it's optional, or isn't it?
{"Voters":[{"Id":421705,"DisplayName":"Holger Just"},{"Id":466862,"DisplayName":"Mark Rotteveel"},{"Id":3001150,"DisplayName":"Raildex"}],"SiteSpecificCloseReasonIds":[18]}
We can do that with a [lifecycle precondition][1] in a null_resource see sample code below ``` lang-hcl variable "sc1_default" { type = bool default = "false" } variable "sc2_default" { type = bool default = "false" } variable "sc3_default" { type = bool default = "true" } variable "sc4_default" { type = bool default = "true" } resource "null_resource" "validation" { lifecycle { precondition { condition = ( (var.sc1_default ? 1 : 0) + (var.sc2_default ? 1 : 0) + (var.sc3_default ? 1 : 0) + (var.sc4_default ? 1 : 0) ) < 2 error_message = "Only one sc can be true" } } } ``` You can see I set the `sc3_default` and `sc4_default` both to true just to trigger the error ... the condition is the core of this validation we are just adding all the true with the help of shorthand if syntax `(var.sc_default ? 1 : 0)` and the total should be less than two, I'm assuming that all false is OK, but if not you can change that logic to check that is precisely one. a terraform plan on that code will error out with the following message: ``` lang-txt Planning failed. Terraform encountered an error while generating this plan. ╷ │ Error: Resource precondition failed │ │ on main.tf line 22, in resource "null_resource" "validation": │ 22: condition = ( │ 23: (var.sc1_default ? 1 : 0) + │ 24: (var.sc2_default ? 1 : 0) + │ 25: (var.sc3_default ? 1 : 0) + │ 26: (var.sc4_default ? 1 : 0) │ 27: ) < 2 │ ├──────────────── │ │ var.sc1_default is "false" │ │ var.sc2_default is "false" │ │ var.sc3_default is "true" │ │ var.sc4_default is "true" │ │ Only one sc can be true ``` [1]: https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#custom-condition-checks
I am working on a streaming application which streams video and audio from a Raspberry Pi. I want to overlay some sensor data on the video and after many attempts with textoverlay I am trying to use imagesequencesrc instead, with the intent of having my sensor script output an image with the sensor data at regular intervals and then displaying that on top of the video with imagesequencesrc. I have gotten this to work on the Raspberry's desktop with this pipeline: <gst-launch-1.0 imagesequencesrc location=/home/pi/amazon-kinesis-video-streams-webrtc-sdk-c/build/samples/image-%05d.png start-index=1 stop-index=-1 framerate=1/1 ! decodebin ! compositor name=comp ! autovideosink videotestsrc ! video/x-raw, framerate=\(fraction\)5/1, width=320, height=240 ! comp.> But in my application I am using the <gst_parse_launch> function as instructed in the Gstreamer documentation, and I just can't get it to work. I have tried several pipelines, to no avail: ``` pipeline = gst_parse_launch("imagesequencesrc location=/home/pi/amazon-kinesis-video-streams-webrtc-sdk-c/build/samples/image-%05d.png start-index=1 stop-index=-1 framerate=1/1 ! decodebin ! videoconvert ! compositor name=comp !" "appsink sync=TRUE emit-signals=TRUE name appsink-imageseq autovideosrc ! clockoverlay ! queue ! videoconvert ! video/x-raw,width=1280,height=720,framerate=25/1 !" "x264enc bframes=0 speed-preset=veryfast bitrate=2048 byte-stream=TRUE tune=zerolatency !" "video/x-h264,stream-format=byte-stream,alignment=au,profile=baseline ! appsink sync=TRUE emit-signals=TRUE " "name=appsink-video autoaudiosrc ! " "queue leaky=2 max-size-buffers=400 ! audioconvert ! audioresample ! opusenc ! " "audio/x-opus,rate=48000,channels=2 ! appsink sync=TRUE emit-signals=TRUE name=appsink-audio ! comp. !" , &error); ``` Results in ``` GStreamer-CRITICAL **: 10:57:36.916: gst_element_link_pads_filtered: assertion 'GST_IS_BIN (parent)' failed ``` Moving the comp. command before the x264 encoding to have compositor merge the imagesequence and video before encoding has the application run without errors, but no video or audio is displayed. ``` pipeline = gst_parse_launch("imagesequencesrc location=/home/pi/amazon-kinesis-video-streams-webrtc-sdk-c/build/samples/image-%05d.png start-index=1 stop-index=-1 framerate=1/1 ! decodebin ! videoconvert ! compositor name=comp !" "appsink sync=TRUE emit-signals=TRUE name appsink-imageseq autovideosrc ! clockoverlay ! queue ! videoconvert ! video/x-raw,width=1280,height=720,framerate=25/1 ! comp. !" "x264enc bframes=0 speed-preset=veryfast bitrate=2048 byte-stream=TRUE tune=zerolatency !" "video/x-h264,stream-format=byte-stream,alignment=au,profile=baseline ! appsink sync=TRUE emit-signals=TRUE " "name=appsink-video autoaudiosrc ! " "queue leaky=2 max-size-buffers=400 ! audioconvert ! audioresample ! opusenc ! " "audio/x-opus,rate=48000,channels=2 ! appsink sync=TRUE emit-signals=TRUE name=appsink-audio !" , &error); ``` Using autovideosink instead of appsink to link the imagesequencesrc element to autovideosrc results in a working video and audio stream that is transmitted to the webservice (AWS KVS WebRTC), but the imagesequence is displayed on the Raspberry's desktop in a 1280x720 window, without the video. So the imagesequence is not merged with the video/audio, only rendered locally. I expected compositor to at least merge the images with the x-raw video before encoding and linking audio, but I was wrong. I have attempted to move the comp. command throughout different stages of the pipeline, but it does not work as intended. I feel like I am just misusing the compositor syntax, but I can't figure it out despite hours in the GStreamer documentation. Grateful for any suggestions or insight.
``` import { GoogleMap, Marker } from '@react-google-maps/api'; return ( <div className="student-page"> <div className='student-page-top-half'> {studentId && <StudentInfoBox studentId={studentId} />} {/* Map section */} {studentCoordinates && ( <GoogleMap id="student-map" mapContainerStyle={{ width: '100%', height: '400px' }} center={studentCoordinates} zoom={15} > <Marker position={studentCoordinates} /> </GoogleMap> )} </div> <div className='student-page-bottom-half'> {/* Current Classes section */} </div> </div> ); ``` I am writing a react component to render a map. I get this deprecation warning and I have seen some documentation but I am confused how to import Advanced Marker Element.
Unsure what imports to use for Advanced Marker Element
|google-maps|
null
I am working on automating a silverlight application and executing it from jenkins. **Problem:** I am trying to access the folder "SandboxRefresh" present at the bottom of the page in the silverlight application that I am working on. **Code below:** SilverlightElement jobfolder2 = extab .GetFirstOrDefaultUIElement(criteria.ByName("SandboxRefresh") .AndByClassName("TextBlock")); **Issue Observed:** Executing the above java code in Eclipse resulted in Arithmetic overflow exception as it could not find the element at the bottom of the page. **Please note:** I tried many approaches that worked for me in my machine but it did not work on Jenkins. ex: Button bt= new Button(); Screen scr= new Screen(); scr.wheel(bt.WHEEL_DOWN, 2); The above code worked well to scroll to the bottom of the page but it is not always successful. Sometimes the code gets executed but scroll does not happen. Can anyone help me with an approach to scroll to the desired element in silverlight application when launched the code from jenkins?
How to pass the results of one SQL query to another query
|sql|
As [documentation](https://github.com/hapijs/joi/blob/master/API.md#anycustommethod-description) said: > **any.custom(method, [description])** Adds a custom validation function to execute arbitrary code where: > - **method** - the custom (synchronous only) validation function using signature function(value, helpers) In your case, **isUniqueEmail** is not synchronous. I suggest to move your validation in your business layer code.
It should be possible to handle full line reading with keys suppression by taking advantage of [ReadKey(bool intercept)][1] with some custom solution like: public static string? ReadLine(bool intercept) { if (!intercept) { return Console.ReadLine(); } StringBuilder sb = new(); int position = 0; ConsoleKeyInfo c; do { c = Console.ReadKey(true); if (!char.IsControl(c.KeyChar)) { sb.Insert(position++, c.KeyChar); } else { switch (c.Key) { case ConsoleKey.Delete: if (position < sb.Length) sb.Remove(position, 1); break; case ConsoleKey.Backspace: if (position > 0) sb.Remove(--position, 1); break; case ConsoleKey.LeftArrow: position = Math.Max(position - 1, 0); break; case ConsoleKey.RightArrow: position = Math.Min(position + 1, sb.Length); break; case ConsoleKey.End: position = sb.Length; break; case ConsoleKey.Home: position = 0; break; default: if (c.KeyChar == 26) // Ctrl+Z { Console.WriteLine(); // End of input. Move to next line return null; } break; } } } while (c.Key != ConsoleKey.Enter); Console.WriteLine(); // End of input. Move to next line return sb.ToString(); } static void Main(string[] args) { Console.Write("Insert something: "); var input = ReadLine(true); Console.WriteLine($"You typed: {input}"); } [1]: https://learn.microsoft.com/en-us/dotnet/api/system.console.readkey?view=net-8.0#system-console-readkey(system-boolean)
I created `person` table as shown below: ```sql CREATE TABLE person ( id INTEGER, name VARCHAR(20) ); ``` Then, I created `my_func()` which returns a table as shown below: ```sql CREATE FUNCTION my_func() RETURNS TABLE(id INTEGER, name VARCHAR) AS $$ BEGIN RETURN QUERY SELECT id, name FROM person; END; -- ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ $$ LANGUAGE plpgsql; ``` Finally, calling `my_func()` got the same error as shown below: ```sql postgres=# SELECT my_func(); ERROR: column reference "id" is ambiguous LINE 1: SELECT id, name FROM person ^ DETAIL: It could refer to either a PL/pgSQL variable or a table column. QUERY: SELECT id, name FROM person CONTEXT: PL/pgSQL function my_func() line 3 at RETURN QUERY ``` So, I set the table name `person` with `.` just before `id` and `name` as shown below: ```sql CREATE FUNCTION my_func() RETURNS TABLE(id INTEGER, name VARCHAR(20)) AS $$ BEGIN RETURN QUERY SELECT person.id, person.name FROM person; END; -- ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ $$ LANGUAGE plpgsql; ``` Finally, I could call `my_func()` without error as shown below. *Omitting `FROM` clause from [SELECT statement][1] gets [the error][2]: ```sql postgres=# SELECT my_func(); my_func ----------- (1,John) (2,David) (2 rows) ``` [1]: https://www.postgresql.org/docs/current/sql-select.html [2]: https://stackoverflow.com/questions/19975755/missing-from-clause-entry-for-a-table/77810473#77810473
PHP Laravel SQLServer could not find driver
|php|sql-server|laravel|
{"Voters":[{"Id":5468463,"DisplayName":"Vega"},{"Id":839601,"DisplayName":"gnat"},{"Id":874188,"DisplayName":"tripleee"}],"SiteSpecificCloseReasonIds":[13]}
I want to get live weather data with web scrapping. But I'm facing a problem I can not find the solution for. I was thinking about using BeautifulSoup for this. <span class="Column--precip--3JCDO"> <span class="Accessibility--visuallyHidden--H7O4p">Chance of Rain</span> 3% </span> I want to get the 3% out of this container. I already managed to get data from the website using this code snippet for another section. temp_value = soup.find("span", {"class":"CurrentConditions--tempValue--MHmYY"}).get_text(strip=True) I tried the same for the rain_forecast rain_forecast = soup.find("span", {"class": "Column--precip--3JCDO"}).get_text(strip=True) But the output my console is delivering is: "--" for print(rain_forecast). The only difference I can see is, that between the "text" that should be get from the span, there is another span. Another way I came across stackoverflow is to use Selenium, because the data has not yet been loaded into the variable and therefore the output is "--". But I don't know if this is overkill for my application, or if there is an simpler solution for this problem.
Python Web scraping information in a span, located under nested span
|python|web-scraping|
{"Voters":[{"Id":8620333,"DisplayName":"Temani Afif","BindingReason":{"GoldTagBadge":"css"}}]}
I'll start by saying that I'm not a Java expert, and I'm facing a really strange problem that I'm not able to solve. I'm working on an application to which I decided to add a telegram bot in order to give some remote information. When I run the application from the IDE (currently I'm using IntelliJ IDEA) all works fine, as soon as I create an excecutable version of the same application the telegram bot stops to working without throw any exception and I cannot figure out what I'm doing wrong. Now in order to isolate the problem I created a dummy project that implement only the telegram bot (that I've extracted from the first project) but the behavior is the same: from IDE no problem, from excecutable the bot don't work. In the following section you can find all the details about the code and all the dependencies that I'm using. Basically I created a JavaFX project that is made by only one scene whit 2 buttonsç - **Connect**: used to open the connection with the telegram bot - **Send**: used to send a "Test" message over the bot channel. [Application View](https://i.stack.imgur.com/i569O.png) # Code Here you can find the FX controller class: ``` package com.example.telegrambotui; import javafx.fxml.FXML; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; import javafx.scene.control.Label; import javafx.stage.Stage; import org.telegram.telegrambots.meta.exceptions.TelegramApiException; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Optional; public class HelloController { @FXML private Label welcomeText; private TelegramBot telegramBot; @FXML protected void connectClick() throws IOException { try { telegramBot = new TelegramBot("My_test_bot"); welcomeText.setText("Connected"); } catch (Exception e) { File file = new File("C:\\Users\\luca-\\IdeaProjects\\TelegramBotUI\\Installer\\ConnectException.txt"); file.createNewFile(); PrintWriter pw = new PrintWriter(file); e.printStackTrace(pw); } } @FXML protected void onTestButtonClick() throws IOException { try { telegramBot.sendMessage("Test"); welcomeText.setText("Sent \"Test\""); } catch (TelegramApiException e) { welcomeText.setText("Excetion!!"); fireAlarm(Alert.AlertType.ERROR, HelloApplication.stage, "Error", "Connection Info not set!", e.getMessage()); File file = new File("C:\\Users\\luca-\\IdeaProjects\\TelegramBotUI\\Installer\\TestButtonException.txt"); file.createNewFile(); PrintWriter pw = new PrintWriter(file); e.printStackTrace(pw); pw.close(); } } private Optional<ButtonType> fireAlarm(Alert.AlertType type, Stage owner, String title, String headerText, String contentText) { Alert alert = new Alert(type); alert.initOwner(owner); alert.setTitle(title); alert.setContentText(contentText); if (!headerText.equals("")) { alert.setHeaderText(headerText); } return alert.showAndWait(); } } ``` Here you can find the TelegramBot class: ``` package com.example.telegrambotui; import org.telegram.telegrambots.bots.TelegramLongPollingBot; import org.telegram.telegrambots.meta.TelegramBotsApi; import org.telegram.telegrambots.meta.api.methods.send.SendMessage; import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.exceptions.TelegramApiException; import org.telegram.telegrambots.updatesreceivers.DefaultBotSession; import java.util.Arrays; import java.util.HashMap; import java.util.List; public class TelegramBot extends TelegramLongPollingBot { private final static HashMap<String, TelegramChannel> AvailableBots = new HashMap<>(){{ put("My_test_bot", new TelegramChannel("My_test_bot", <Here I've have put the bot Token>)); }}; private TelegramChannel telegramChannel; private final String INIT; private final String HELLO_WORLD = "/hello"; private final String IS_ALIVE = "/alive"; private final List<String> COMMANDS = Arrays.asList( IS_ALIVE, HELLO_WORLD); private TelegramBotsApi telegramBotsApi; public TelegramBot(String channel) throws TelegramApiException { telegramChannel = AvailableBots.get(channel); telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class); telegramBotsApi.registerBot(this); INIT = "<strong>[" + telegramChannel.username() + "]</strong>\n"; } public static String[] getAvailableBot() { String[] bots = new String[AvailableBots.keySet().size()]; int i = 0; for(String k: AvailableBots.keySet()){ bots[i] = k; i++; } return bots; } @Override public void onUpdateReceived(Update update) { if (update.hasChannelPost() && update.getChannelPost().hasText()) { if (COMMANDS.contains(update.getChannelPost().getText())){ try { switch (update.getChannelPost().getText()){ case HELLO_WORLD -> sendMessage("Hello World!"); case IS_ALIVE -> sendMessage("I'm alive!!"); } } catch (TelegramApiException e) { throw new RuntimeException(e); } } } } public void sendMessage(String mex) throws TelegramApiException { if(!mex.startsWith(INIT)){ mex = INIT + mex; } SendMessage toSend = new SendMessage(telegramChannel.chat_id(), mex); toSend.enableHtml(true); execute(toSend); } @Override public String getBotUsername() { return telegramChannel.username(); } @Override public String getBotToken() { return telegramChannel.token(); } } ``` # Dependencies Here you can find all the dependencies: [Dependencies](https://i.stack.imgur.com/sA90M.png) And this is the Artifacts file: [Artifacts part 1](https://i.stack.imgur.com/A8yLQ.png) [Artifacts part 2](https://i.stack.imgur.com/1W8RS.png) # Excecutable script In order to generate the excecutable file Im using the following script: ``` jpackage -t exe --name "TelegramBotUI" --icon ".\MyIcon.ico" --input "../out/artifacts/TelegramBotUI_jar" --dest "./" --main-jar "TelegramBotUI.jar" --main-class "com.example.telegrambotui.HelloApplication" --module-path "C:\Program Files\Java\javafx-jmods-17.0.2" --add-modules javafx.controls,javafx.fxml --win-menu --win-dir-chooser ``` Since I didn't catch any exception from the executable version, I tried to save any kind of exception in the txt file if there was one but none was caught. I think that Im doing some mistakes in the way I generate the excecutable because from the IDE the application works without any problem. I've tried to change the Telegram bot version with a new one (6.9.7.1) but nothing has changed. What am I doing wrong?
Java, Telegram Bot runtime problems
|java|runtime-error|telegram|telegram-bot|long-polling|
null
In C# I have a class like this public class BClass { public int Ndx { get; set; } public string Title { get; set; } } This is then used within this class public class AClass { public int Ndx { get; set; } public string Author { get; set; } public BClass[] Titles { get; set; } } Now when I populate author I do not know how many titles they have until run time so the number of instances of `AClass.Titles` there will be, so my question is how do I initialise this everytime please? Thanks in advance
I have the following pieces of nodejs code: const watcher = chokidar.watch(path, { persistent: true }); watcher .on('add', path=> { // func1(); }) .on('change', path=> { // func2(); }) .on('unlink', path=> { // func3(); }); I need to use mocha to write some unit test cases to test the above code, but I'm not familiar with mocha and not sure how to trigger these add/change/unlink events. I've tried to use mock-fs, but it seems like it can only simulate the 'add' event. Can somebody help me if you have any idea? it('should read file when file is added or changed, log error when file is removed', function () { // on 'add' event chai.assert.isTrue(func1.isCalled); // on 'change event chai.assert.isTrue(func2.isCalled); // on 'unlink' chai.assert.isTrue(func3.isCalled); });
How to setup indexer tier in Apache Druid version 28.0.0? Need to change this _Default_tier to new_tier [enter image description here](https://i.stack.imgur.com/tG3tk.png) I tried adding below parameter and then restarted druid, but no change was found [enter image description here](https://i.stack.imgur.com/nt8Yq.png)
Steps to add indexer tiers in druid
|druid|indexer|data-ingestion|
null
I am trying to subtract a date column from another column which is not a date. Generally, I would use ```select date - interval '3' month from table_name``` This would then give me the date 3 months before the date column but this time around I want the '3' to come from a column within the same table. This column would have different numbers say 3, 4 etc. I have tried a couple of methods using concatenation but it has not worked. (This is an Oracle SQL developer query) Edit: Example - I have two columns, one column is a date format and the other is number format with numbers such as 1, 2, 3 and so on. I want to take the date in column 1 for example, 01/Jan/2024 and use column 2 to subtract the months from the date. For example, where the number is 1, the output should return 01/DEC/2023, where it is 2, output should return 01/Nov/2023 and so on
how to pull data automatically from iFace 702 and update it in the database? i only tried the manual backup. im using vb.net. it is already displaying in my system but i want it to be automatically backup. is there any suggestion for me to do?
how to pull data automatically from iFace 702 and update it in the database?
|vb.net|database-backups|biometrics|
null
Found the answer to this issue here : https://litmus.com/community/discussions/5286-mysterious-white-line-in-outlook Basically, with MSO, you wouldn't want to handle the direction and padding on the same table. Nesting is the key. So using a mj-wrapper for the padding and then the section for the direction did the trick and the bug disappeared. ```html <mjml> <mj-body background-color="red"> <mj-wrapper padding="16px"> <mj-section direction="rtl" background-color="#ffffff" padding="0"> <mj-column vertical-align="middle"> <mj-image src="https://picsum.photos/536/354"></mj-image> </mj-column> <mj-column vertical-align="middle"> <mj-text font-size="20px" color="red" font-family="helvetica">text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </mj-text> </mj-column> </mj-section> </mj-wrapper> </mj-body> </mjml> ```
To achieve the appending of a new row from the column index you want, you must use the Apps Script method [setValues](https://developers.google.com/apps-script/reference/spreadsheet/range#setvaluesvalues) on the right range. Here is the code implementation with self explanatory comments to achieve this: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> // you can pass a column index to this function as a new parameter (or inside rowData) function addNewRow(rowData,column) { const ss = SpreadsheetApp.getActiveSpreadsheet(); const ws = ss.getSheetByName("Recruitment_Contacts"); // Set as the data what we want to insert to then be able to know how many // columns will this fill // We need to wrap the data into [] as it is expecting a nested array for [cols] and [rows] var data = [[rowData.LnRT,rowData.FnRT,rowData.Gn,rowData.St,rowData.Dtr,rowData.Trn,rowData.Td]]; // Set the values on the first row of the sheet (reproducing the behaviour of appendRow) // and starting from the row index you want (5 for example). // It will be 1 row and the length of the data // long in terms of columns. ws.insertRows(1,1); ws.getRange(1, column,1,data[0].length).setValues(data); return true; } <!-- end snippet -->
{"OriginalQuestionIds":[56717184],"Voters":[{"Id":5577765,"DisplayName":"Rabbid76","BindingReason":{"GoldTagBadge":"pygame"}}]}
2 problems with the code: 1. Functional. By default, disk is closed when its corresponding handle is (which happens automatically when the program ends). So, the disk was opened (and shown in *Explorer*), but only for a very short period of time (after the *AttachVirtualDisk* call till program end), so you were not able to see it. To be able to use the disk, either: - Don't stop the program until you're done using the disk (add an *input* statement at the very end) - Detach the disk lifetime from its handle's one (use *ATTACH\_VIRTUAL\_DISK\_FLAG\_PERMANENT\_LIFETIME* flag from [\[MS.Learn\]: ATTACH\_VIRTUAL\_DISK_FLAG enumeration (virtdisk.h)](https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ne-virtdisk-attach_virtual_disk_flag)).<br> Needless to say that now, you'll have to detach the disk yourself, by either: - Eject it from *Explorer* - Enhancing code to call *DetachVirtualDisk* Also, not sure what are the implications of repeatedly attaching the disk (without detaching it) 2. Coding - *Undefined Behavior* generator. Check [\[SO\]: C function called from Python via ctypes returns incorrect value (@CristiFati's answer)](https://stackoverflow.com/a/58611011/4788546) for a common pitfall when working with *CTypes* (calling functions) *code00.py*: ``` #!/usr/bin/env python import ctypes as cts import sys from ctypes import wintypes as wts class GUID(cts.Structure): _fields_ = ( ("Data1", cts.c_ulong), ("Data2", cts.c_ushort), ("Data3", cts.c_ushort), ("Data4", cts.c_ubyte * 8), ) class VIRTUAL_STORAGE_TYPE(cts.Structure): _fields_ = ( ("DeviceId", wts.ULONG), ("VendorId", GUID), ) ERROR_SUCCESS = 0 VIRTUAL_STORAGE_TYPE_DEVICE_ISO = 1 VIRTUAL_DISK_ACCESS_READ = 0x000D0000 OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00000000 ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = 0x00000001 ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = 0x00000004 VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT = GUID(0xEC984AEC, 0xA0F9, 0x47E9, (0x90, 0x1F, 0x71, 0x41, 0x5A, 0x66, 0x34, 0x5B)) def main(*argv): path = r"l:\Kit\Linux\Ubuntu\pc064\20\ubuntu-20.04.1-desktop-amd64.iso" virtdisk = cts.WinDLL("VirtDisk") OpenVirtualDisk = virtdisk.OpenVirtualDisk OpenVirtualDisk.argtypes = (cts.POINTER(VIRTUAL_STORAGE_TYPE), cts.c_wchar_p, cts.c_int, cts.c_int, cts.c_void_p, wts.HANDLE) OpenVirtualDisk.restype = wts.DWORD AttachVirtualDisk = virtdisk.AttachVirtualDisk AttachVirtualDisk.argtypes = (wts.HANDLE, cts.c_void_p, cts.c_int, wts.ULONG, cts.c_void_p, cts.c_void_p) AttachVirtualDisk.restype = wts.DWORD kernel32 = cts.WinDLL("Kernel32.dll") GetLastError = kernel32.GetLastError GetLastError.argtypes = () GetLastError.restype = wts.DWORD CloseHandle = kernel32.CloseHandle CloseHandle.argtypes = (wts.HANDLE,) CloseHandle.restype = wts.BOOL vts = VIRTUAL_STORAGE_TYPE(VIRTUAL_STORAGE_TYPE_DEVICE_ISO, VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT) handle = wts.HANDLE() res = OpenVirtualDisk(cts.byref(vts), path, VIRTUAL_DISK_ACCESS_READ, OPEN_VIRTUAL_DISK_FLAG_NONE, None, cts.byref(handle)) if res != ERROR_SUCCESS: print(f"OpenVirtualDisk error: {GetLastError()}") return -1 attach_flags = ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY permanent = bool(argv) # Any argument was passed if permanent: attach_flags |= ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME res = AttachVirtualDisk(handle, None, attach_flags, 0, None, None) if res != ERROR_SUCCESS: print(f"AttachVirtualDisk error: {GetLastError()}") CloseHandle(handle) return -2 input(f"Press <Enter> to continue{'' if permanent else ' (this also closes the ISO drive)'}") CloseHandle(handle) # Performed automatically if __name__ == "__main__": print( "Python {:s} {:03d}bit on {:s}\n".format( " ".join(elem.strip() for elem in sys.version.split("\n")), 64 if sys.maxsize > 0x100000000 else 32, sys.platform, ) ) rc = main(*sys.argv[1:]) print("\nDone.\n") sys.exit(rc) ``` **Output**: > ``` > [cfati@CFATI-5510-0:e:\Work\Dev\StackExchange\StackOverflow\q078246936]> sopr.bat > ### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ### > > [prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.10_test0\Scripts\python.exe" ./code00.py > Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] 064bit on win32 > > Press <Enter> to continue (this also closes the ISO drive) ... > > Done. > > > [prompt]> > [prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.10_test0\Scripts\python.exe" ./code00.py perm > Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] 064bit on win32 > > Press <Enter> to continue ... > > Done. > ``` In each of the 2 runs above, the effect is visible in *Explorer* (according to explanations from the beginning): [![Img00][1]][1] [1]: https://i.stack.imgur.com/S7vAH.png
Three bugs that I can see, including some spotted in comments. ---- ``` MOV AH, 09H LEA AX, msg3 INT 21H ``` Looks like a typo for `LEA DX, msg3`. As it stands you will have a random value in AH (the high byte of the address of `msg3` and will be executing some random DOS function. That might be what crashes DosBox. Also, more efficient than `LEA` here (and in the other similar instances) would be `MOV DX, OFFSET msg3` which has the same effect and saves one byte. ---- ``` XOR AX, AX MOV DX, 10H DIV DX ``` First, you zeroed out `AX` thus discarding the total value you so carefully computed (remember, `AX` emcompasses both `AH` and `AL`). Second, `DIV r/m16` is a 32 by 16 bit division: it divides the 32-bit unsigned value in `DX:AX` by the value in `r/m16`, with the quotient placed in `AX` and the remainder in `DX`. So here you are dividing `100000H` by `10H`; the quotient is `10000h` which overflows 16 bits, and so you will get a divide overflow exception. This could also be the cause of the crash, though I seem to recall that real MS-DOS had a handler for the divide overflow interrupt that would print a message and terminate the program, without crashing the system. I'm not sure if DosBox provides that, however. Also, `10H` is hex, so you're dividing by sixteen. I'm assuming you probably wanted decimal output, so you want to divide by ten (`10`) instead. Thus, I think you probably meant ``` XOR AH, AH ; zero-extend AL into AX MOV DL, 10 DIV DL ``` to do a 16 by 8 bit divide of the number from `AL` (extended with zeros to produce a 16-bit value in `AX`) by `10H`, placing the quotient in `AL` and the remainder in `AH`. ---- ``` MOV AH, 02H MOV DL, Q INT 21H ``` You need to add `0` to the values `Q` and `R` to create printable ASCII characters for output.
If I have the following ``` <AppBar elevation={0} > ``` The app bar will be blue. I would like to make that blue transparent while allowing me to update the theme to a different color and still have it show up as that color only with transparency. I tried the following... ``` <AppBar elevation={0} sx={{ backdropFilter: "blur(10px)", // Add this line backgroundColor: 'transparent', // And this line }} > ``` But of course this doesn't maintain the theme color and just makes it plain transparent. Can I make a MUI app bar transparent with the color from the theme still added?
Can I use a transparrent version of the MUI AppBar with the original color from theme?
|material-ui|
First set Bracket pair colorization off `"editor.bracketPairColorization.enabled": false` then set the color you want. ```json { "scope": [ "punctuation.brackets.curly", "punctuation.brackets.round", ], "settings": { "foreground": "#f1bff4", "fontStyle": "bold" } }, ```
I am having a problem with low text-to-HTML ratio of pages on wordpress sites. I could not find a permanent solution in my research. I use the Wp-Rocket plugin. I removed unused css codes. The theme is clean and I use little code. I used the Fast Velocity Minify plugin to compress html, but it always breaks the site. I tested it on many themes. Has anyone found a permanent solution? My site: [https://barisdayak.com/](https://barisdayak.com/) I am looking for a permanent solution to the Wordpress - pages have low text-HTML ratio problem.
Wordpress Site - pages have low text-HTML ratio
|wordpress|
null
URLSession requesting JSON array from server not working
|ios|swift|
I am reading Mastering STM32 by Carmine Noviello and got to the chapter where I am about to work on the hello-nucelo project. I followed everything to the letter and still got the following error (see attachment): *23:33:25 **** Incremental Build of configuration Debug for project hello-nucleo **** make all process_begin: CreateProcess(NULL, echo "Building file: ../system/src/stm32f7-hal/stm32f7xx_hal.c", ...) failed. make (e=2): Le fichier sp�cifi� est introuvable. make: *** [system/src/stm32f7-hal/subdir.mk:57: system/src/stm32f7-hal/stm32f7xx_hal.o] Error 2 "make all" terminated with exit code 2. Build might be incomplete. 23:33:26 Build Failed. 1 errors, 0 warnings. (took 522ms)* What can be the problem in this case? I tried playing around with the settings and tool chain editor tabs based on things I have seen online but nothing worked.
Build issue in my STM32-NUCLEO project using the Eclipse IDE
|eclipse|cmake|build|stm32|nucleo|
null
You can specify eager loading via chaining and also with multiple options together. So here we load via outer join from User to UserProjectRoleLink to Project. Then we after that query is loaded we lookup the roles via the role ids we fetched in the first query. So this should result in exactly 2 `SELECT` statements. ```python q = select( User ).options( joinedload( User.user_project_roles ).options( joinedload(UserProjectRoleLink.project), selectinload(UserProjectRoleLink.role) ).where(User.id == user_id) ``` There is an example that uses these suboptions here [specifying-sub-options-with-load-options](https://docs.sqlalchemy.org/en/20/orm/queryguide/relationships.html#specifying-sub-options-with-load-options) As long as you don't reference `project.documents` then the documents should not be eager loaded. Depending on how your serialization works, ie. jsonify, or whatever, you will need to exclude that property. Then you could dump out your data like this: ```python return [{ "id": user.id, "username": user.username, "project_roles": [{ "project_name": upr.project.project_name, "project_id": upr.project.id, "role": upr.role.name, "role_id": upr.role.id, } for upr in user.user_project_roles], } for user in session.scalars(q)] ``` async I think is the same just with a wrapped `await` `[{} for user in (await session.scalars(q))]`
I have linked properly the `List-Adapter` and the other `list-item` components. It didn't getting the `android:id` of `activity_main_cake_items.xml` and giving this error. Cannot resolve symbol 'listviewCakes' This is my files : > **MainCakeItems.java** ``` package com.example.dessertshop; import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Adapter; import android.widget.AdapterView; import com.example.dessertshop.databinding.ActivityMainBinding; import java.util.ArrayList; public class MainCakeItems extends AppCompatActivity { ActivityMainBinding binding; ListAdapterCakes listAdapterCakes; ArrayList<ListDataCakes> dataCakesArrayList = new ArrayList<>(); ListDataCakes listDataCakes; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivityMainBinding.inflate(getLayoutInflater()); // setContentView(R.layout.activity_main_cake_items); setContentView(binding.getRoot()); int[] imageCakeList = {R.drawable.vanilla_cake, R.drawable.chocolate_cake, R.drawable.strawberry_cake}; int[] idCakeList = {R.string.vanillaCakeId, R.string.chocolateCakeId, R.string.strawberryCakeId}; int[] titleCakeList = {R.string.vanillaCakeTitle, R.string.chocolateCakeTitle, R.string.strawberryCakeTitle}; int[] detailsCakeList = {R.string.vanillaCakeDetails, R.string.chocolateCakeDetails, R.string.strawberryCakeDetails}; String[] titleList = {"Vanilla Cake", "Chocolate Cake", "Strawberry Cake"}; String[] idList = {"01", "02", "03"}; for (int i = 0; i < imageCakeList.length; i++) { listDataCakes = new ListDataCakes(titleList[i],idList[i], imageCakeList[i],idCakeList[i], titleCakeList[i], detailsCakeList[i]); dataCakesArrayList.add(listDataCakes); } listAdapterCakes = new ListAdapterCakes(MainCakeItems.this,dataCakesArrayList); binding.listviewCakes.setAdapter(listAdapterCakes); // ERROR binding.listviewCakes.setClickable(true); // ERROR binding.listviewCakes.setOnItemClickListener(new AdapterView.OnItemClickListener() { // ERROR @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l){ Intent intent = new Intent(MainCakeItems.this, DetailsCakes.class); intent.putExtra("image", imageCakeList[i]); intent.putExtra("id", idCakeList[i]); intent.putExtra("title", titleCakeList[i]); intent.putExtra("details", detailsCakeList[i]); intent.putExtra("title", titleList[i]); intent.putExtra("id", idList[i]); startActivity(intent); } }); } } ``` > **activity_main_cake_items.xml** ``` <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background_image" tools:context=".MainCakeItems"> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listviewCakes" // Here it should get the value of the variable from android:scrollbars="vertical" android:layout_marginStart="10dp" android:layout_marginEnd="10dp" android:layout_marginTop="12dp" tools:listitem="@layout/list_item_cakes" android:divider="@android:color/transparent" android:dividerHeight="10.0sp"> </ListView> </androidx.constraintlayout.widget.ConstraintLayout> ``` > **ListAdapterCakes.java** ``` package com.example.dessertshop; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.ArrayList; public class ListAdapterCakes extends ArrayAdapter<ListDataCakes> { public ListAdapterCakes(@NonNull Context context, ArrayList<ListDataCakes> dataCakesArrayList) { super(context, R.layout.list_item_cakes, dataCakesArrayList); } @NonNull @Override public View getView(int position, @Nullable View view, @NonNull ViewGroup parent) { ListDataCakes listDataCakes = getItem(position); if (view == null) { view = LayoutInflater.from(getContext()).inflate(R.layout.list_item_cakes, parent, false); } ImageView listImageCakes = view.findViewById(R.id.listImageCakes); TextView listTitleCakes = view.findViewById(R.id.listTitleCakes); // TextView listDetails = view.findViewById(R.id.listCakeDetails); TextView listCakesId = view.findViewById(R.id.listCakesId); listImageCakes.setImageResource(listDataCakes.image); listTitleCakes.setText(listDataCakes.title); // listDetails.setText(listDataCakes.details); listCakesId.setText(listDataCakes.id); return view; } } ```
For the past few weeks, I've been trying to figure out how to generate platforms just like how they're generated in the Pou minigame "Sky Hop"(Referring to [this game](https://www.youtube.com/watch?v=KAT6dCAM1fw)). I've only succeeded in generating them when I assumed that only one platform can spawn in each row. However, in the minigame I'm trying to replicate, multiple platforms have a chance of spawning (maximum of 3 in the row that can hold 4 platforms, maximum of 2 in the row that can hold 3 platforms), which ruins the current code I have, which you can see below: ```python import pygame,random # Initialize Pygame pygame.init() # Create a screen object screen = pygame.display.set_mode((800, 600)) # Define the color of the rectangles color = (255, 0, 0) # Define the number of rows and columns rows = 6 cols = 4 # Define the distance between the rectangles dist = 10 running = True # Define the width and height of each rectangle width = 100 height = 50 platforms = [] platforms_alt = [] seed = [] rng = 0 #test_class class Platform(): def __init__(self, x,y,width,height): self.rect = pygame.Rect(x,y,width,height) def draw(self,color): pygame.draw.rect(screen,pygame.Color(color),self.rect) # Generates the odd row platforms for i in range(rows-1): rng = 0 if i > 1 and rng % 2 == 0: rng = 1 else: rng = random.randint(0,cols-2) for j in range(cols-1): left = 105 + j * (width *2) top = i * (height *2) if i % 2 != 0 and j == rng: platform = Platform(left,top,width,height) platforms.append(platform) seed.append(j) seed.append(seed[1]) #Generates the even row platforms based on the index of the odd row platforms for l in range(rows): for m in range(cols): left = m * (width *2) top = l * (height * 2) if l % 2 == 0: if seed[0] - seed[1] < 0 and m == seed[int(l/2)]: platform_alt = Platform(left,top,width,height) platforms_alt.append(platform_alt) if seed[0] - seed[1] >= 0 and m == seed[int(l/2)]+1 or random.randint(0,100) <= 5 and (m == seed[int(l/2)] or m > seed[int(l/2)]): platform_alt = Platform(left,top,width,height) platforms_alt.append(platform_alt) while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: pass # Odd row platforms painted red for p in range(platforms.__len__()): platforms[p].draw("red") # Even row platforms painted blue for q in range(platforms_alt.__len__()): platforms_alt[q].draw("blue") pygame.display.flip() ``` [Result of the code above](https://i.stack.imgur.com/W5aaL.png) I've tried adding a condition that checked if a random number got to a specific value, and when it did, it would spawn an additional platform, however, that often resulted in the platform being isolated from all the other platforms, and generating an additional red platform broke the spawning of the blue platforms.
This is my xAxis chart options in the chart xAxis: { type: 'datetime', startOnTick: true, labels: { useHTML: true, align: 'center', rotation: 0, style: { fontSize: "10px" }, formatter: function () { var date = new Date(this.value); var quarter = Math.floor((date.getUTCMonth()) / 3) + 1; var year = date.getUTCFullYear().toString().substr(-2); return 'Q' + quarter + '-' + year; } }, minPadding: 0.05, maxPadding: 0.05 }, my x axis looks like this [![enter image description here][1]][1] how to display these ticker labels in between tick marks, rather than right under the tick marks. Thaks in advance. [![enter image description here][2]][2] [1]: https://i.stack.imgur.com/hAPFj.png [2]: https://i.stack.imgur.com/gHfRd.png
How to position x axis ticker labels, between tickers in Highcharts.js
|angular|highcharts|
I cleared the browser cache, but it had no effect. I was only able to log in when I cleared my cookies.
It looks like you may be referring to a compile-time error. However, the `On Error` statement only handles a run-time error. So you should manually compile your code before trying to run it. This way you'll avoid a compile-time error when running it. First, make sure that you have the following statement at the very top of your module before any procedures. This will force you to declare all variables. So, if you try to use an undeclared variable, you'll get a compile-time error. Option Explicit Then compile your code, and fix any errors that pop-up. Once any errors are fixed and your workbook is saved, any errors that pop-up will occur a run-time, which your `On Error` statement will catch. Visual Basic Editor (Alt+F11) >> Debug >> Compile VBAProject
***EDIT 4*** Ok, I hope this additional info seals it. Firefox DOES bubble the synthetic CLICK that I generate on SPACEBAR / ENTER, but it DOES NOT bubble the mouse CLICK. CHROME and EDGE work as expected. (both events bubble) All Browsers bubble INPUT events for both mouse and synthetic clicks. Both events are COMPOSED, CANCELLABLE, and BUBBLE. The only difference I have seen is the synthetic CLICK event has had its TARGET set to ABC-TOGGLE#myToggle whereas the TARGET for the mouse CLICK is still input checkbox. Note: I do understand that SPACEBAR is normally a first class CLICK event for checkboxes but I have stopPropagation() for uniformity with CR. Why won't the mouse CLICKs traverse the DOMs? ***END EDIT 4*** **EDIT 3** Ok, I'm an idiot! Never knew spacebar *is* an intrinsic click :-( **END EDIT 3** **EDIT 2** More info: Chrome triggers both a Click and an Input event in that order. Firefox agrees with spacebar/synthetic event but won't surface a Click to the light DOM when the mouse is clicked. [This][1] now works for FireFox and Chrome both TickBox and Toggle. But the SpaceBar CarrriageReturn functionality does not work. Still on it. **END EDIT 2** **EDIT 1** Firefox does in fact bubble an event through to the light DOM but it is an INPUT event; not a CLICK event. Why? **END EDIT 1** The documentations says events triggered on elements in the Shadow DOM that make up a Web Component should pass from shadow to light DOM with the target, currentTarget, originalTarget et al coalesced into the Web-Component tagName, id, and so on. This is not happening with FireFox in this [exaple][1] in test_toggle.html I wish to be notified of a "click" event on my "disTick" tickbox so that I can disable the Toggle: - document.getElementById("disTick").addEventListener("click", (e) => { if (e.target.checked) myToggle.disabled=true; else myToggle.disabled=false; }); document.body.addEventListener("change", (e) => {console.log("****"+e.target.tagName);}); It gets called on Chrome, Edge, Opera, but not FireFox. (I have tried to trap click, input, and chang events on BODY but nothing bubbles.) Curiously enough, my synthetic event does bubble up (from toggle.js) this.#toggle.addEventListener('keyup', (e) => { if (e.altKey || e.ctrlKey || e.isComposing || e.metaKey || e.shiftKey) return; if (e.keyCode == 32 || e.keyCode == 13) { console.log("key = " + e.keyCode); e.preventDefault(); this.#toggle.click(); } }); What am I missing/ Why isn't the original click bubbling through light DOM on FireFox? [1]: https://richardmaher.github.io/CustElements/test_toggle.html
Platform Generation for a Sky Hop clone
|python|python-3.x|pygame|
null
I am trying to cache some private custom rest endpoints using WP Rest Cache and whenever i try it makes them public? Not sure if anyone has come across this but i need it to remain private in the cache to authenticated users. register_rest_route( 'v1', 'get-report-summary/',array( 'methods' => 'GET', 'callback' => 'get_report_summary', 'permission_callback' => function () { return is_user_logged_in(); }, )); function get_report_summary(){ $data = "Some code"; $response = new WP_REST_Response($data); $response->set_status(200); return $response; } Adding the endpoint to the cache function wprc_add_endpoint( $allowed_endpoints ) { if ( ! isset( $allowed_endpoints[ 'v1' ] ) || ! in_array( 'get-report-summary', $allowed_endpoints[ 'v1' ] ) ) { $allowed_endpoints[ 'v1' ][] = 'get-report-summary'; } return $allowed_endpoints; } add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_endpoint', 10, 1);
I'm using the following IIS Rewrite Rule to block as many bots as possible. <rule name="BotBlock" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_USER_AGENT}" pattern="^$|bot|crawl|spider" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> This rule blocks all requests with an empty User-Agent string or a User-Agent string that contains `bot`, `crawl` and `spider`. This works great but it also blocks `googlebot`, which I do not want. So how do I exclude the `googlebot` string from the above pattern so it does hit the site. I've tried `^$|!googlebot|bot|crawl|spider` `^$|(?!googlebot)|bot|crawl|spider` `^(?!googlebot)$|bot|crawl|spider` `^$|(!googlebot)|bot|crawl|spider` But they either block all User-Agents or still do not allow googlebot. Who has a solution and knows a bit about regex? **So thanks to The fourth bird the solution becomes:** <add input="{HTTP_USER_AGENT}" pattern="^$|\b(?!.*googlebot.*\b)\w*(?:bot|crawl|spider)\w*" />
I am trying to scrape multi page pdf using textract. Need to scrape pdf and format to json based on its sections, sub sections, tables. while trying to UI demo with LAYOUT and Table it is exactly able to show layout title, layout section, layout text, layout footer, page number same info can be observed in csv downloaded file from UI Demo: layout.csv file. same in json file: analyzeDocResponse.json too but it has all (LINES, WORDS, LAYOUT_TITLE, and all layout related data), i think textract does all kind of block types in sequence. for debugging purpose, i am using below code to print entire dictionary of block. and also block type followed by its corresponding text. if interested in pdf file: its SmPC of Drugs: [SmPC file](https://www.nafdac.gov.ng/wp-content/uploads/Files/SMPC/Covid19/Pfizer-BioNTech-SmPC-For-Covid-19-Vaccine.pdf) code 1: printing each block in json format. ``` def start_textract_job(bucket, document): response = textract.start_document_analysis( DocumentLocation={ 'S3Object': { 'Bucket': bucket, 'Name': document } }, FeatureTypes=["LAYOUT"] # You can adjust the FeatureTypes based on your needs ) return response['JobId'] def print_blocks(job_id): next_token = None while True: if next_token: response = textract.get_document_analysis(JobId=job_id, NextToken=next_token) else: response = textract.get_document_analysis(JobId=job_id) for block in response.get('Blocks', []): print(json.dumps(block, indent=4)) next_token = response.get('NextToken', None) if not next_token: break ``` it is printing similiar info as per UI Demo, block type LINES, WORDS, LAYOUT_ but if i try to print text for each block type using below code, it fails to print for LAYOUT_ related , not sure why, am i missing anything? code 2: to print block type followed by its content. ``` def start_textract_job is same as above, LAYOUT. def print_blocks(job_id): next_token = None while True: if next_token: response = textract.get_document_analysis(JobId=job_id, NextToken=next_token) else: response = textract.get_document_analysis(JobId=job_id) for block in response.get('Blocks', []): print(f"{block['BlockType']}: {block.get('Text', '')}") next_token = response.get('NextToken', None) if not next_token: break ``` I can see values for block type LINES, WORDS but coming empty for LAYOUT as below, i think, it is identifying in block types but not its values. LAYOUT_TITLE: LAYOUT_FIGURE: LAYOUT_TEXT: LAYOUT_SECTION_HEADER: LAYOUT_TEXT: LAYOUT_SECTION_HEADER: LAYOUT_TEXT: LAYOUT_TEXT: LAYOUT_TEXT: LAYOUT_TEXT: LAYOUT_TEXT: LAYOUT_PAGE_NUMBER: LAYOUT_FOOTER: any help is highly appreicated, went thru doc and few other StackOverflow questions but couldnt find any help. New to Tetract, sorry for noob Q?, if it is :)
Any time you invoke `get()` on a document reference, you will be billed 1 read if the program was able to reach the Firestore backend. The document data behind a reference is not cached after a write: it will be read again for each call to `get()`.
null
{"Voters":[{"Id":3706016,"DisplayName":"jarlh"},{"Id":16076,"DisplayName":"Mitch Wheat"},{"Id":9214357,"DisplayName":"Zephyr"}]}
I don't know if there's any way to detect it via the properties Python exhibits. But you can simply query to see if it's a version that is known to implement the PEP. ```Python def has_pep528(): try: import platform import sys if platform.python_implementation() == 'CPython' and tuple(sys.version_info) >= (3, 6): return True except: pass return False ``` You can add additional `if` statements as other implementations become known.
Solution that works on start of 2024 with latest available Flutter + lib versions: 1.generic class (paging object in our case) import 'package:json_annotation/json_annotation.dart'; part 'page_dto.g.dart'; @JsonSerializable(explicitToJson: true, genericArgumentFactories: true) class PageDto<T> { List<T> content; int totalPages; int totalElements; int number; int numberOfElements; bool last; bool first; bool empty; PageDto( {required this.content, required this.totalPages, required this.totalElements, required this.number, required this.numberOfElements, required this.last, required this.first, required this.empty}); factory PageDto.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) => _$PageDtoFromJson<T>(json, fromJsonT); Map<String, dynamic> toJson(Object Function(T) toJsonT) => _$PageDtoToJson<T>(this, toJsonT); } 2.class that goes as generic in paging: @JsonSerializable() class WalletAccountRecord { String id; String accountId; RecordAmount amount; String date; OperationType operationType; String? category; String? note; List<String>? labels; TransferDetails? transferDetails; WalletAccountRecord(this.id, this.accountId, this.amount, this.date, this.operationType, this.category, this.note, this.labels, this.transferDetails); static WalletAccountRecord fromJsonModel(Object? json) => WalletAccountRecord.fromJson(json as Map<String,dynamic>); factory WalletAccountRecord.fromJson(Map<String, dynamic> json) => _$WalletAccountRecordFromJson(json); Map<String, dynamic> toJson() => _$WalletAccountRecordToJson(this); } 3.example of usage in service: Future<PageDto<WalletAccountRecord>> walletRecords(String walletId) async { var url = '/wallets/$walletId/records'; var response = await get(url); if (response.statusCode != 200) { throw Exception('Request failed. Status: ${response.statusCode}'); } debugPrint('Wallet json: ${response.body}'); dynamic data = json.decode(response.bodyString!); return PageDto<WalletAccountRecord>.fromJson(data, WalletAccountRecord.fromJsonModel); }
I am reading Mastering STM32 by Carmine Noviello and got to the chapter where I am about to work on the hello-nucelo project. I followed everything to the letter and still got the following error (see attachment): *23:33:25 **** Incremental Build of configuration Debug for project hello-nucleo **** make all process_begin: CreateProcess(NULL, echo "Building file: ../system/src/stm32f7-hal/stm32f7xx_hal.c", ...) failed. make (e=2): Le fichier sp�cifi� est introuvable. make: *** [system/src/stm32f7-hal/subdir.mk:57: system/src/stm32f7-hal/stm32f7xx_hal.o] Error 2 "make all" terminated with exit code 2. Build might be incomplete. 23:33:26 Build Failed. 1 errors, 0 warnings. (took 522ms)* What can be the problem in this case? I tried playing around with the settings and tool chain editor tabs based on things I have seen online but nothing worked.
As I am using an old mac that doesn't have 'system settings' and I don't have any external speakers, I will provide what works on my system to choose an alert sound, from Sound's Sound Effects. You should be able to map it to your setup and the output. ``` tell application "System Preferences" activate set ankor to anchor "effects" of pane id "com.apple.preference.sound" of application "System Preferences" reveal ankor end tell tell application "System Events" tell process "System Preferences" set spk to "Glass" -- desired alert sound -- collect the higher level ui elements in a single variable set t1 to table 1 of scroll area 1 of tab group 1 of window "Sound" -- list of table elements to select sound from set rowRef to rows of t1 -- cycle through list of rows and compare each row's `value of text field 1` repeat with ear in rowRef if value of text field 1 of ear is equal to spk then set matchingItem to contents of ear -- get row number of matching value exit repeat end if end repeat select matchingItem --> row 6 of table 1 of scroll area 1 of tab group 1 of window "Sound" of application process "System Preferences" of application "System Events" end tell end tell ``` Now you have the result you need to create a more focused script: ``` tell application "System Preferences" activate set ankor to anchor "effects" of pane id "com.apple.preference.sound" of application "System Preferences" reveal ankor end tell tell application "System Events" tell process "System Preferences" set glassAlert to row 6 of table 1 of scroll area 1 of tab group 1 of window "Sound" of application process "System Preferences" of application "System Events" select glassAlert end tell end tell ``` If you find that the syntax differs from a more modern OS version, let me know.
I am reading Mastering STM32 by Carmine Noviello and got to the chapter where I am about to work on the hello-nucelo project. I followed everything to the letter and still got the following error (see attachment): *23:33:25 **** Incremental Build of configuration Debug for project hello-nucleo **** make all process_begin: CreateProcess(NULL, echo "Building file: ../system/src/stm32f7-hal/stm32f7xx_hal.c", ...) failed. make (e=2): Le fichier sp�cifi� est introuvable. make: *** [system/src/stm32f7-hal/subdir.mk:57: system/src/stm32f7-hal/stm32f7xx_hal.o] Error 2 "make all" terminated with exit code 2. Build might be incomplete. 23:33:26 Build Failed. 1 errors, 0 warnings. (took 522ms)* What can be the problem in this case? I tried playing around with the settings and tool chain editor tabs based on things I have seen online but nothing worked.
I've figured out the issue, and it wasn't an issue with the spec in question, although the behaviour was unexpected. The underlying data that the page under tests relies on was not present. That's because in other specs I tested the same Stripe form-filling functionality and the assertions made in those tests **made the application wait until they were true**. In this test, however, the page was redirected with `visit subscription_path` before the result from the Stripe API were saved, thus causing an error. The error raised in the test threw me off because it led me to believe that there was a dialogue box open that should not have been, whereas the actual issue was that **no dialogue box was open even though it was expecting one to be**. The cancel button was not present on the page because the subscription page was showing empty. The test now looks like: ```ruby RSpec.describe 'CancelSubscriptions', js: true do it 'cancels an active subscription' do email = sign_up_and_subscribe expect(page).to have_current_path('/subscription/success', ignore_query: true) # making sure the Stripe return_url was hit and so the data is saved in my DB click_on 'dropdown-toggle' click_on 'Subscription' expect(page).to have_content 'Your subscription' accept_confirm do click_button 'Cancel' end expect(page).to have_content 'We are cancelling your subscription.' subscription = User.find_by(email:).current_subscription expect(subscription.cancelled?).to be(true) end end ``` Takeaway: make sure the page is rendered as expected before making assertions on accepting confirmation or prompt dialogue boxes with Capybara/Selenium. Not doing can cause unexpected errors.
I host two WordPress sites on a Windows 2019 Server, IIS 10, PHP 8.2 with FastCGI. The two sites use exactly the same themes and plugins, in same versions. One site works fine and the other generates 500 error on FastCGI with PHP 8.2, even when I deactivate all themes and plugins and use the default WordPress 2024 theme. But it works fine if I swicth the FastCGI to use PHP 7.4. When set with PHP 8.2: I have enabled PHP error log: only deprecation level errors, and on both sites. I have enabled WordPress debug log: only deprecation level errors, and on both sites. I have enables Failed Trace Request log on IIS, I get this but I can't find any valuable information inside. [error log file][1] You may need to view this error log file with Microsoft Edge and Internet Explorer compatibility mode. If someone can give me a clue, or tell me which additionnal error logging feature I can use, it would be very helpful, as I am completely stucked here. [1]: https://demo.knowledgeplaces.com/error500/fr000271.xml
error 500 on IIS FastCGI but no clue despite multiple error loggings activated
|php|wordpress|iis|fastcgi|
To your original code: MOCK_METHOD(const int&, value, (), (const)); To the updated code MOCK_METHOD(const int&, RefOp, ());
I got some problems with how i have to start writing the code. The problem is how i write fortran code to input the data of river section coordinates like using 'READ' as the command to input many coordinates in every sections with different shape. Maybe you guys can help me with that problems?. i've tried writing the codes, but it doesnt work. I was expecting that the program work with just input the coordinate in many different river cross section while the code is compiling in fortran.
{"OriginalQuestionIds":[76840113],"Voters":[{"Id":807126,"DisplayName":"Doug Stevenson"},{"Id":466862,"DisplayName":"Mark Rotteveel"},{"Id":209103,"DisplayName":"Frank van Puffelen","BindingReason":{"GoldTagBadge":"flutter"}}]}
net and to machine learning in general. I've been trying to load an object detection model on my local gpu but it tells me to load a vott json. now I've downloaded the program and did all the steps excluding tagging all the hundreds of images that I have. Instead, I changed the asset state in the export setting to all images. Is that bad? because when I tried to load the exported vott json into visual studio it didn't do anything. it didn't even show me an error.
Loading object detection model in visual studio ml.net
|ml.net|ml.net-model-builder|
null
null
I am working on an IoT application with over 15K lines of code using PlatformIO IDE, Espressif 6.2.0, and the Arduino framework. I left the device running for about 28 hours, and everything was working fine until I encountered the following exception, which simply stated that the ISR WDT (Interrupt Service Routine Watchdog Timer) had timed out, which is understandable. However, what happened next really confused me. The device attempted to reboot **97** times, and each attempt resulted in the same error. On the 98th attempt, the device got stuck in the reboot process and did not proceed further. It seemed as if the CPU was halted, but I do not know why or how exactly. I have a single ISR in my program attached to a digital input. In that ISR, I only increment an integer variable by one and nothing else. My question is, why might this have happened? Let's consider that my program has a major problem that occurs after 28 hours, but why doesn't the issue stop after rebooting? Has anyone had a similar experience, and if so, what were the possible solutions? Here is the start and end of the log for your reference: ```[T-97928] [N] Free Heap Size: 55432, Min Heap Size: 16372 [T-97929] [N] Free Heap Size: 55464, Min Heap Size: 16372 [97929352][E][Wire.cpp:513] requestFrom(): i2cRead returned Error 263 Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1). Core 1 register dump: PC : 0x40081467 PS : 0x00050a35 A0 : 0x4008522c A1 : 0x3ffbfaac A2 : 0x00000000 A3 : 0x3ffbe12c A4 : 0x3ffbe14c A5 : 0x00000000 A6 : 0x3ffbe14c A7 : 0x00000000 A8 : 0x00000001 A9 : 0x3ffbfa8c A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000001 A13 : 0x00000001 A14 : 0x00000001 A15 : 0x3ffb8ff0 SAR : 0x0000001b EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x4008a468 LEND : 0x4008a47e LCOUNT : 0xffffffff Core 1 was running in ISR context: EPC1 : 0x400f6137 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000 Backtrace: 0x40081464:0x3ffbfaac |<-CORRUPTED Core 0 register dump: PC : 0x4018d46a PS : 0x00060735 A0 : 0x800f4bcc A1 : 0x3ffcc580 A2 : 0x00000000 A3 : 0x80000001 A4 : 0x800921f8 A5 : 0x3ffaf660 A6 : 0x00000003 A7 : 0x00060023 A8 : 0x800f46ae A9 : 0x3ffcc550 A10 : 0x00000000 A11 : 0x80000001 A12 : 0x800921f8 A13 : 0x3ffaf670 A14 : 0x00000003 A15 : 0x00060023 SAR : 0x0000001d EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000 Backtrace: 0x4018d467:0x3ffcc580 0x400f4bc9:0x3ffcc5a0 0x400902c4:0x3ffcc5c0 ELF file SHA256: ed76320984d99ab6 Rebooting... [T-0] [N] Setup Started. Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1). Core 1 register dump: PC : 0x4008520c PS : 0x00050035 A0 : 0x4000bff0 A1 : 0x3ffbfadc A2 : 0x00000000 A3 : 0x00000040 A4 : 0x00001000 A5 : 0x3ffbfaac A6 : 0x00000000 A7 : 0x3ffbe12c A8 : 0x0002566a A9 : 0x3ffbfaac A10 : 0x00000001 A11 : 0x00000804 A12 : 0x00000001 A13 : 0x3ffbfa8c A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001b EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x4008a5d0 LEND : 0x4008a5db LCOUNT : 0xffffffff Core 1 was running in ISR context: EPC1 : 0x400f6137 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000 Backtrace: 0x40085209:0x3ffbfadc |<-CORRUPTED Core 0 register dump: PC : 0x4018d46a PS : 0x00060735 A0 : 0x800f4bcc A1 : 0x3ffcc580 A2 : 0x00000000 A3 : 0x4008981c A4 : 0x00060520 A5 : 0x3ffbcfb0 A6 : 0x007bfaf8 A7 : 0x003fffff A8 : 0x800f46ae A9 : 0x3ffcc550 A10 : 0x00000000 A11 : 0x3ffbfaf4 A12 : 0x3ffbfaf4 A13 : 0x00000000 A14 : 0x00060520 A15 : 0x00000000 SAR : 0x0000001d EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000 Backtrace: 0x4018d467:0x3ffcc580 0x400f4bc9:0x3ffcc5a0 0x400902c4:0x3ffcc5c0 ELF file SHA256: ed76320984d99ab6 . . . . 97 Exception Like This . . . . Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1). Core 1 register dump: PC : 0x40085204 PS : 0x00050a35 A0 : 0x4008182e A1 : 0x3ffbfadc A2 : 0x00000000 A3 : 0x3ffb78e0 A4 : 0x00001000 A5 : 0x3ffbfaac A6 : 0x00000000 A7 : 0x3ffbe12c A8 : 0x3ffbe168 A9 : 0x00000000 A10 : 0x3ffbe14c A11 : 0x00000001 A12 : 0x00000001 A13 : 0x3ffbfa8c A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001b EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x4008a468 LEND : 0x4008a47e LCOUNT : 0xffffffff Core 1 was running in ISR context: EPC1 : 0x400f6137 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000 Backtrace: 0x40085201:0x3ffbfadc |<-CORRUPTED Core 0 register dump: PC : 0x4018d46a PS : 0x00060935 A0 : 0x800f4bcc A1 : 0x3ffcc580 A2 : 0x00000000 A3 : 0x80000001 A4 : 0x800921f8 A5 : 0x3ffcc4a0 A6 : 0x00000003 A7 : 0x00060023 A8 : 0x800f46ae A9 : 0x3ffcc550 A10 : 0x00000000 A11 : 0x80000001 A12 : 0x800921f8 A13 : 0x3ffaf630 A14 : 0x00000003 A15 : 0x00060023 SAR : 0x0000001d EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000 Backtrace: 0x4018d467:0x3ffcc580 0x400f4bc9:0x3ffcc5a0 0x400902c4:0x3ffcc5c0 ELF file SHA256: ed76320984d99ab6 Rebooting... [T-0] [N] Setup Started. ```
ESP32 Consequtive Interrupt WDT Timeout Exception
|arduino|microcontroller|esp32|arduino-esp32|platformio|
I am a beginner trying to learn software, I wanted to make a project, but after running the project I made, it closes instantly and I cant solve the problem. ``` import pygame import random import os # Ekran boyutları WIDTH = 800 HEIGHT = 600 # Renkler WHITE = (255, 255, 255) RED = (255, 0, 0) # Oyuncu sınıfı class Player(pygame.sprite.Sprite): def __init__(self): super().__init__() self.image = pygame.Surface((50, 50)) self.image.fill(RED) self.rect = self.image.get_rect() self.rect.center = (WIDTH // 2, HEIGHT // 2) self.health = 3 def update(self): keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: self.rect.x -= 5 if keys[pygame.K_RIGHT]: self.rect.x += 5 if keys[pygame.K_UP]: self.rect.y -= 5 if keys[pygame.K_DOWN]: self.rect.y += 5 # Ekran dışına çıkmasını engelle self.rect.x = max(0, min(self.rect.x, WIDTH - self.rect.width)) self.rect.y = max(0, min(self.rect.y, HEIGHT - self.rect.height)) # Düşman sınıfı class Enemy(pygame.sprite.Sprite): def __init__(self, game_folder): super().__init__() self.image = pygame.image.load(os.path.join(game_folder, "Enemy.png")).convert() # enemy.png resmini yükle self.image.set_colorkey(WHITE) self.rect = self.image.get_rect() self.rect.x = random.randrange(WIDTH - self.rect.width) self.rect.y = random.randrange(HEIGHT - self.rect.height) # Oyun dosyasının bulunduğu klasör game_folder = os.path.abspath(os.path.dirname(__file__)) # Kalp resmini yükleyen fonksiyon def load_image(name, width, height): fullname = os.path.join(game_folder, name) # Oyun klasöründe doğrudan arama image = pygame.image.load(fullname).convert() image.set_colorkey(WHITE) return image # Oyunu başlatma pygame.init() screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Space War") clock = pygame.time.Clock() all_sprites = pygame.sprite.Group() enemies = pygame.sprite.Group() player = Player() all_sprites.add(player) for _ in range(8): enemy = Enemy(game_folder) all_sprites.add(enemy) enemies.add(enemy) # Kalp resmini yükleme heart_image = load_image('Heart.png', 25, 25) # Oyun döngüsü running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False all_sprites.update() # Düşmanlarla çarpışma kontrolü hits = pygame.sprite.spritecollide(player, enemies, True) for hit in hits: player.health -= 1 if player.health <= 0: running = False enemy = Enemy(game_folder) all_sprites.add(enemy) enemies.add(enemy) screen.fill((0, 0, 0)) # Siyah renkle arka planı doldur all_sprites.draw(screen) # Kalpleri çiz heart_spacing = 40 # Kalpler arasındaki boşluğu belirle max_hearts_per_row = (WIDTH - 20) // heart_spacing # Bir satırda maksimum kaç kalp sığabileceğini hesapla for i in range(player.health): row = i // max_hearts_per_row # Kaçıncı satırda olduğumuzu belirle col = i % max_hearts_per_row # Kaçıncı sütunda olduğumuzu belirle screen.blit(heart_image, (10 + col * heart_spacing, 10 + row * heart_spacing)) pygame.display.flip() clock.tick(60) pygame.quit() ``` I tried to make a game, but instead of drawing the enemy, I wanted to make it with .png. After updating the code, it stopped opening. please help me to solve that
## Short Answer In practice, the measured histogram discrepancy with a 4:2:2 jpg is ~1%, therefore one would expect about 16,609,443 colors—this is mainly due to factors other than YCbCr, such as the DCT compression. # Longer Answer The above value based on compressing using 4:2:2, and 100% quality. DCT artifacts are certainly part of the discrepancies. The measurement was using a histogram of the pure RGB image and compared to the 4:2:2 jpg, using DIFFERENCE transfer mode. Some of the loss is due to the DCT algorithm, and some due to the spatial subsampling. That considered, the total colors would be no less than 16,579,244 to 16,642,998, but the difference is at worst effectively dithered. I.e. we are splitting hairs here. Using Bruce Lindbloom's ["every possible color" image][1], an uncompressed RGB array of all possible colors, exported to a jpg at **100% quality** out of GIMP at **4:2:2**. Then importing as a layer and setting it to difference transfer mode, to find any differences between the pure RGB and the 4:2:2 jpg. For the following examples, I cropped to a small area of the full image. ## 100% Quality, 4:2:2 ### The original: [![RGB16MillionCLIPorig][2]][2] #### The 4:2:2 jpeg laid on top, using difference mode: [![RGB16MillionCLIP422DIFF][3]][3] #### A histogram of that result (16bpc was used): [![enter image description here][4]][4] #### Expanding that 1% range to full range, to show the nature of the differences: [![RGB16MillionCLIP422DIFFexpanded][5]][5] ## Discussion In playing with this, including using 4:4:4 and 4:2:0 variants, it appears clear the main cause of the variations is the DCT compression, not so much the YCbCr. Perhaps it's useful to point out: we are never viewing YCbCr, we are always viewing RGB, thus the YCbCr is only the intermediate encoding for storage. For every color stored in YCbCr it must be converted to a color in RGB. The only question then regards "round trips" in and out. I.e. for any given RGB color, mapped to a given YCbCr color, come back out to the exact same RGB color? Here this is the difference with a jpeg that was exported five times consecutively: [![RGB16Million422pass5DIFF][9]][9] And expanded to show the bottom 1%: [![RGB16Million422pass5DIFFexpanded][10]][10] The vertical bars are due to the 4:2:2 subsampling. But otherwise, the discrepancy is essentially the same. This is consistent with the fact that after the first pass through DCT at 100% quality, subsequent passes at 100% quality have minimal effect. ## 50% Quality, 4:2:2 #### For reference, here is the difference using a 4:2:2 at 50% quality: [![RGB16MillionCLIP422QUAL50DIFF][6]][6] #### In this case the histogram of the difference indicates up to 25% discrepancy: [![enter image description here][7]][7] #### And expanded for detail: [![RGB16MillionCLIP422QUAL50DIFFexpanded][8]][8] ## Conclusion **We are always viewing RGB**. There is no reason to think that the round trip RGB->YCbCr->RGB results in lost colors per se, assuming an appropriate reverse transform, and working in floating point (if working in int, some rounding may result in some round trip errors). However, the addition of DCT compression and chroma subsampling certainly does add errors, the degree of which are largely dependent on the quality settings. The errors introduced due to DCT and subsampling are greater than those due purely to the color space transform. [1]: http://www.brucelindbloom.com/index.html?RGB16Million.html [2]: https://i.stack.imgur.com/4SCcg.png [3]: https://i.stack.imgur.com/GmpzX.png [4]: https://i.stack.imgur.com/9SbK3.png [5]: https://i.stack.imgur.com/nDrIz.png [6]: https://i.stack.imgur.com/QB2Gm.png [7]: https://i.stack.imgur.com/j7BKK.png [8]: https://i.stack.imgur.com/xWl3u.png [9]: https://i.stack.imgur.com/k8i0U.png [10]: https://i.stack.imgur.com/LyhKd.png
Writing code for River Section Coordinates in Fortran
|fortran|gfortran|fluid-dynamics|
null