Reflection-based JSON in C++ at Gigabytes per Second – Daniel Lemire's blog
https://lemire.me/blog/2024/08/13/reflection-based-json-in-c-at-gigabytes-per-second/
3 Likes
https://lemire.me/blog/2024/08/13/reflection-based-json-in-c-at-gigabytes-per-second/
I recorded myself using ChatGPT to write me a Python program. It is honestly very simple, easy to use and in my case, gave me accurate information to use that saved me days worth of work.
github: https://github.com/AykutSarac/jsoncrack.com
Introducing JSON Crack – the open-source, free JSON #visualization app that will revolutionize the way you work with data. With its intuitive and user-friendly interface, JSON Crack makes it easy to explore, analyze, and understand even the most complex JSON structures. Whether you're a developer working on a large-scale project or a data enthusiast looking to uncover hidden insights, JSON Crack has the tools and features you need to unlock the full potential of your data. Best of all, because JSON Crack is open-source and free, you can use it without breaking the bank. Try JSON Crack today and experience the power of data visualization like never before.
#tool #floss #opensource #utility #data #structure #coder #developer #software
The reason i'd like to do this is because i want to have lists of items of the same type, and avoid storing the object type for each element. Instead i would like to store the type for the whole list and, i could do that by (for example) adding a suffix to the name of the list
Code:
from_file_dict: dict = json.load(read_file, object_hook=my_decode)
def my_decode(dct: dict):
if JSON_OBJ_TYPE in dct and dct[JSON_OBJ_TYPE] == MyClass.__name__:
my_class_obj = MyClass(dct["id"], dct["attribute_example_one"], dct["attribute_example_two"])
return my_class_obj
# ... elif other object types
return dct
Example data:
{
"example_list": [
{
"__obj_type__": "MyClass"
"id": 1,
"attribute_example_one": "Dennis Moore",
"attribute_example_two": 42,
},
{
"__obj_type__": "MyClass"
"id": 2,
"attribute_example_one": "Lupines",
"attribute_example_two": 3,
},
}
Posted here on stackoverflow, but my experience is unfortunately not the best when it comes to that network: https://stackoverflow.com/q/74081608/2525237
Source: https://nitter.eu/Laughing_Mantis/status/1512081814994575377
So what can you do with these and how can they be abused:
You can modify the JSON and JS files mentioned in order to:
- arbitrary download binaries
- ignore download checksums
- execute commands as SYSTEM
- C2 on the behalf of applications
- perform file I/O as SYSTEM
etc.
...
A good generic tool should scan the local appdata and program file folders for instances of NODE.JS or JSON files (Maybe not Microsoft Store instances) and then have templates for trojanizing each vendor's custom #NodeJS and #JSON.
#Microsoft #warning #danger #0day #software #news #Trojan #problem #hack #hacker #driver #install #fail #security
https://jsonplaceholder.typicode.com/
{JSON} Placeholder
Free fake API for testing and prototyping.Powered by JSON Server + LowDB. Tested with XV.
As of Oct 2021, serving ~1.7 billion requests each month.
Falls es jemand gebrauchen kann… #json
(So far)
This is a summary of my discoveries and learning over the past two months or so concerning Diaspora* data archives and references as well as JSON and tools for manipulating it, specifically jq
.
It is a condensation of conversation mostly at my earlier Data Migration Tips & Questions (2022-1-10) thread, though also scattered elsewhere. I strongly recommend you review that thread and address general questions there.
Discussion here should focus on the specific information provided, any additions or corrections, and questions on how to access/use specific tools. E.g., how to get #jq running on Microsoft Windows, which I don't have specific experience with.
I'm neither a maximalist nor minimalist when it comes to content archival. What I believe is that people should be offered the tools and choices they need to achieve their desired goal. Where preservation is preferred and causes minimal harm, it's often desirable. Not everything needs to be preserved, but too it isn't necessary to burn down every library one encounters as one journeys through life.
In particular, I'm seeking to preserve access for myself and others to previous conversations and discussions, and to content that's been shared and linked elsewhere. Several of my own posts have been submissions to Hacker News and other sites, for example, and archival at, say, the Internet Archive or Archive Today will preserve at least some access.
This viewpoint seems not to be shared by key members of the Diaspora* dev team and some pod administrators. As such, I'll note that their own actions and views reduce choice and agency amongst members of the Diaspora* community. The attitude is particularly incongruous given Diaspora*'s innate reliance on federation and content propagation according to the original specified intent of the content's authors and creators. This is hardly the first time Diaspora* devs have put their own concerns far above those of members of the Diaspora* community.
Information here is provided for those who seek to preserve content from their own profiles on Diaspora* servers likely to go offline, in the interest of maximising options and achieving desired goals. If this isn't your concern or goal, you may safely ignore what follows.
The discussion here largely addresses working with a downloaded copy of Diaspora* profile data in JSON format.
It presumes you have jq installed on your system, and have a Bash or equivalent command-line / scripting environment. Most modern computers can offer jq though you will have to install it: natively on Linux, any of the BSDs, MacOS (via Homebrew), Windows (via Cygwin or WSL), and Android (via Termux). iOS is the only mass-market exception, and even there you might get lucky using iSH.
Create your archive by visiting your Pod's /user/edit page and requesting EXPORT DATA at the bottom of that page.
If you have issues doing so, please contact your Pod admin or other support contact(s). Known problems for some Joindiaspora members in creating archives are being worked on.
## Diaspora* post URLs can be reconstructed from the post GUID
The Diaspora* data extract does not include a canonical URL, but you can create one easily:
Post URL = /posts/
So for the GUID 64cc4c1076e5013a7342005056264835
We can tack on:
https://
pluspora.com
Substitute your intended Pod's hostname here./posts/
to arrive at:
https://pluspora.com/posts/64cc4c1076e5013a7342005056264835
... which is the URL for a post by @Rhysy (rhysy@pluspora.com
) in which I'd initially witten the comment this post is based on, at that post's Pluspora Pod origin.
Given that Pluspora is slated to go offline a few weeks from now, Future Readers may wish to refer to an archived copy here:
https://archive.ph/Y8mar
Once you have the URL, you can start doing interesting things with it.
Using our previous example, links for the post on, e.g., diasp.org, diaspora.glasswings.com, diasp.eu, etc., can be generated by substituting for host_name
:
Simply having a URL on a pod does not ensure that the content will be propagated. A member of that pod must subscribe to the post first. In many cases this occurs through followers, though occasionally it does not.
You can trigger federation by specifically mentioning a user at that instance and having them request the page.
I'm not sure of when specifically federation occurs --- when the notification is generated, when the notification is viewed, or when the post itself is viewed. I've experienced such unfederated posts (404s) often as I've updated, federated, and archived my own earlier content from Joindiaspora to Glasswings. If federation occurs at some time after initial publication and comments the post URL and content should resolve, but comments made prior to that federation will not propagate.
(Pinging a profile you control on another pod is of course an excellent way to federate posts to that pod.)
Once a post is federated to a set of hosts it will be reachable at those hosts. If it has not yet been federated, you'll receive a "404" page, usually stating "These are not the kittens you're looking for. Move along." on Diaspora* instances.
(I'm not aware of other ways to trigger federation, if anyone knows of methods, please advise in comments.)
Note that comments shown on a post will vary by Pod, when and how it was Federated, and any blocks or networking issues between other Pods from which comments have been made. Not all instances necessarily show the same content, inconsistencies do occur.
Those will either show existing archives if they exist or provide links to submit the post if they do not.
Note that the Internet Archive does not include comments, though Archive.Today does, see: https://archive.is/almMw vs. https://web.archive.org/web/20220224213824/https://pluspora.com/posts/64cc4c1076e5013a7342005056264835
To include later comments, additional archival requests will have to be submitted.
See My current jq project: create a Diaspora post-abstracter.
https://diaspora.glasswings.com/posts/ed03bc1063a0013a2ccc448a5b29e257
That still has a few rough edges, but works to create an archive index which can be edited down to size. There's a fair bit of "scaffolding" in the direct output.
Note that the OLD and NEW hosts in the script specify Joindiaspora and Glasswings specifically. You'll want to adapt these to YOUR OWN old and newPod hostnames.
The script produces output which (after editing out superflous elements) looks like this in raw form:
## 2012
### May
**Hey everyone, I'm #NewHere. I'm interested in #debian and #linux, among other things. Thanks for the invite, Atanas Entchev!**
> Yet another G+ refuge. ...
<https://diaspora.glasswings.com/posts/cc046b1e71fb043d>
[Original](https://joindiaspora.com/posts/cc046b1e71fb043d) :: [Wayback Machine](https://web.archive.org/*/https://joindiaspora.com/posts/cc046b1e71fb043d) :: [Archive.Today](https://archive.is/https://joindiaspora.com/posts/cc046b1e71fb043d)
(2012-05-17 20:33)
----
**Does anyone have the #opscodechef wiki book as an ePub? Only available formats are online/web, or PDF (which sucks). I'm becoming a rapid fan of the #epub format having found a good reader for Android and others for Debian/Ubuntu.**
> Related: strategies for syncing libraries across Android and desktop/laptop devices. ...
<https://diaspora.glasswings.com/posts/e76c078ba0544ad9>
[Original](https://joindiaspora.com/posts/e76c078ba0544ad9) :: [Wayback Machine](https://web.archive.org/*/https://joindiaspora.com/posts/e76c078ba0544ad9) :: [Archive.Today](https://archive.is/https://joindiaspora.com/posts/e76c078ba0544ad9)
(2012-05-17 21:29)
----
Which renders as:
2012
May
Hey everyone, I'm #NewHere. I'm interested in #debian and #linux, among other things. Thanks for the invite, Atanas Entchev!
Yet another G+ refuge. ...
https://diaspora.glasswings.com/posts/cc046b1e71fb043d
Original :: Wayback Machine :: Archive.Today(2012-05-17 20:33)
Does anyone have the #opscodechef wiki book as an ePub? Only available formats are online/web, or PDF (which sucks). I'm becoming a rapid fan of the #epub format having found a good reader for Android and others for Debian/Ubuntu.
Related: strategies for syncing libraries across Android and desktop/laptop devices. ...
https://diaspora.glasswings.com/posts/e76c078ba0544ad9
Original :: Wayback Machine :: Archive.Today(2012-05-17 21:29)
I've been posting those in fragmenents by year as private posts to myself to facilitate both federation and archival of the content. In chunks as Diaspora* has a 2^16^ / 65,536 byte per-post size limit. It's a slow slog but I've only one more year (2021) to manually process at this point, with post counts numbering up to 535 per year.
If you submit a URL in the form of https://web.archive.org/save/<URL>
, the Wayback Machine will attempt to archive that URL.
This can be scripted for an unattended backup request if you can generate the set of URLs you want to save.
Using our previous example, the URL would be:
https://web.archive.org/save/https://pluspora.com/posts/64cc4c1076e5013a7342005056264835
Clicking that link will generate an archive request.
(IA limit how frequently such a request will be processed.)
Joindiaspora podmins discourage this practice. Among the more reasonable concerns raised is system load.
I suggest that if you do automate archival requests, as I have done, you set a rate-limit or sleep timer on your script. A request every few seconds should be viable. As a Bash "one-liner" reading from the file DIASPORA_EXTRACT.json.gz
(change to match your own archive file), which logs progress to the timestamped file run-log
with a YYYYMMDD-hms format, e.g., run-log.20220224-222158
:
time zcat DIASPORA_EXTRACT.json.gz |
jq -r '.user .posts[] | "https://joindiaspora.com/posts/\(.entity_data .guid )"' |
xargs -P4 -n1 -t -r ~/bin/archive-url |
tee run-log.$(date +%Y%m%d-%H%M%S)
archive-url
is a Bash shell script:
#!/bin/bash
url=${1}
echo -e "Archiving ${url} ... "
lynx -dump -nolist -width=1024 "https://web.archive.org/save/${url}" |
sed -ne '/[Ss]aving page now/,/^$/{/./s/^[ ]*//p;}' |
grep 'Saving page now'
sleep 4
Note that this waits 4 seconds between requests (sleep 4
), which limits itself to a maximum of 900 requests per hour. There is NO error detection and you should confirm that posts you think you archived actually are archived. (We can discuss methods for this in comments, I'm still working on how to achieve this.)
The script could be improved to only process public posts, something I need to look into. Submitting private posts won't result in their archival, but it's additional time and load.
There is no automated submission mechanism for Archive.Today of which I'm aware.
.json
to the end of a Diaspora* URL provides the raw JSON data for that post:https://joindiaspora.com/posts/64cc4c1076e5013a7342005056264835.json
That can be further manipulated with tools, e.g., to extract original post or comment Markdown text, or other information. Using jq
is useful for this as described in other posts under the #jq hashtag generally.
Notably:
jq -Mr '.text'
, excluding the sed
component (see comments on post).There are likely errors and omissions. Much of the behaviour and structure described is inferred. Corrections and additions are welcomed.
#DiasporaMigration #Migration #Diaspora #Help #Tips #JoindiasporaCom #jq #json #DataArchves #Archives
jq
recipes: Extract the last (or other specified) comment(s) on a postif you want to re-write the most recent comment on a thread, and retrieve the original Markdown, you can fetch the post using its GUID URL with .json
appended, then run it through a simple jq
recipe:
curl -s '<post_url>.json' |
jq -r '.interactions.comments[-1].text'
Say, for example, if you realise you'd just muffed your most recent contribution to a thread and wanted to rewrite it, but don't want to have to re-tag all the Markdown from scratch.
I'm using curl
as the web transport and piping output to jq
on a commandline. This is supported on Linux, the BSDs, MacOS, Windows (using Cygwin or WSL), and via Termux on Android. Sorry, iOS, here's a dime, go buy a real computer.
An example referencing a specific post:
curl -s 'https://diaspora.glasswings.com/posts/ed03bc1063a0013a2ccc448a5b29e257.json' |
jq -r '.interactions.comments[-1].text'
Note that comments are indexed from either the start (beginning with [0]) or via negative values, the last ([-1] instance), and you can provide another offset if you're trying to access a specific post some number of values from the start or end. The third comment would be [2], the fourth most recent would be [-4].
Leave the iterator unspecified to select all comments:
jq -r '.interactions.comments[].text`
As before, the -r
argument outputs raw text without JSON escaping of quotes and other characters. This avoids most post-retrieval processing, e.g., a sed
script to remove quoted characters and the like.
And as I've mentioned previously, jq itself is an extraordinarily useful, if occasionally opaque, command-line tool for processing and parsing JSON data. Which happens to be how Diaspora* delivers much of its content.
This post is of course based on a comment I'd made to this earlier jq thread ... as a comment. Edited and adapted, but substantially similar.
https://diaspora.glasswings.com/posts/ed03bc1063a0013a2ccc448a5b29e257
Given the lack of a search utility on Diaspora*, my evolved strategy has been to create an index or curation of posts, generally with a short summary consisting of the title, a brief summary (usually the first paragraph), the date, and the URL.
I'd like to group these by time segment, say, by month, quarter, or year (probably quarter/year).
And as I'm writing this, I'm thinking that it might be handy to indicate some measure of interactions --- comments, reshares, likes, etc.
My tools for developing this would be my Diaspora* profile data extract, and jq
, the JSON query tool.
It's possible to do some basic extraction and conversion pretty easily. Going from there to a more polished output is ... more complicated.
A typical original post might look like this, (excluding the subscribed_pods_uris
array):
{
"entity_type": "status_message",
"entity_data": {
"author": "dredmorbius@joindiaspora.com",
"guid": "cc046b1e71fb043d",
"created_at": "2012-05-17T19:33:50Z",
"public": true,
"text": "Hey everyone, I'm #NewHere. I'm interested in #debian and #linux, among other things. Thanks for the invite, Atanas Entchev!\r\n\r\nYet another G+ refuge.",
"photos": []
}
}
Key points here are:
entity_type
: Values "status_message" or "reshare".author
: This is the user_id of the author, yours truly (in this case in my DiasporaCom incarnation).guid
: Can be used to construct a URL in the form of https://<hostname>/posts/<guid>
created_at
: The original posting date, in UTC ("Zulu" time).public
: Status, values true
, false
. Also apparently missing in a significant number of posts.text
: The post text itself.A reshare looks like:
{
"entity_type": "reshare",
"entity_data": {
"author": "dredmorbius@joindiaspora.com",
"guid": "5bfac2041ff20567",
"created_at": "2013-12-15T12:45:08Z",
"root_author": "willhill@joindiaspora.com",
"root_guid": "53e457fd80e73bca"
}
}
Again, excluding the .subscribed_pods_uris
. In most cases, reshares are of less interest than direc posts.
Interestingly, I've a pretty even split between posts and reshares (52% status_message
, that is, post).
My theory in creating an abstract is:
Issues:
jq '.user.posts[].entity_data | .author, .guid, .created_at, text
Adding in selection and formatting logic gets ... more complicated.
Among other factors, jq
is a very quirky language.
I would like to produce output which renders something like this for any given posts:
Diaspora Tips: Pods, Hashtags & Following
For the many Google Plus refugees showing up on Diaspora and Pluspora, some pointers: ...
https://diaspora.glasswings.com/posts/a53ac360ae53013611b60218b786018b (2018-10-10 00:45)
What if any options are there for running Federated social networking tools on or through #OpenWRT or related router systems on a single-user or household basis?
I'm trying to coordinate and gather information for #googleplus (and other) users looking to migrate to Fediverse platforms, and I'm aware that OpenWRT, #Turris (I have a #TurrisOmnia), and several other router platforms can run services, mostly #NextCloud that I'm aware. ...
https://diaspora.glasswings.com/posts/91f54380af58013612800218b786018b (2018-10-11 07:52)
The original posts can of course be viewed at the URLs shown.
What this is doing is:
**
Markdown....
.Including the month and year where those change might also be useful for creating archives.
status_message
(that is, original) posts, rather than reshares.## .year
and ### .month
segments in output.\r\n
.There might be more, but that's a good start.
And of course, if I have to invoke other tools for part of the formatting, that's an option, though an all-in-jq solution would be handy.
● NEWS ● #Earthly #Programming ☞ Command Line #JSON Client In #Golang https://earthly.dev/blog/golang-command-line/
Die #taz war die erste online lesbare #Tageszeitung Deutschlands. Sie bietet nach wie vor alltäglich die Möglichkeit Dinge anders zu machen und ist immer noch konzernunabhängig. Willst Du mit uns die zunehmend digitale Zukunft des #Journalismus gestalten? Wir bieten ein kooperatives Umfeld, das Raum für #Weiterentwicklung und #Kreativität lässt, aber auch strategisches #Denken erfordert und die Bereitschaft, alltägliche Probleme auch eigenverantwortlich zu lösen.
Wir suchen für unsere #Webinfrastruktur zeitnah eine:n Kolleg:in mit praktischer Berufserfahrung in der Entwicklung im Bereich #DATENMANAGEMENT, -TRANSFORMATION UND -ANALYSE, gerne auch als Quereinsteiger:in. Wichtig ist uns, dass Du nicht nur teamfähig bist, sondern bevorzugt gemeinsam arbeitest, auch flexibel und mit technischen Laien.
Im Bereich DATENMANAGEMENT, -TRANSFORMATION UND -ANALYSE integrieren wir Backendsysteme in unser Frontend taz.de. Wir kennen die Anwendungsschnittstellen unserer #Backends und transformieren diese in ein einheitliches XML-Format. Dabei stehen wir in enger Kommunikation mit Unix-Systemadministration und #Frontendentwicklung sowie internen Anwender:innen, externen Auftraggeber:innen und IT-Spezialist:innen. Immer wieder fordern uns neue Backendsysteme und Techniken heraus und immer wieder gilt es, Umbauten oder Fehler in bestehender #Infrastruktur zu finden und zu optimieren. Wir sind für **Import und Export **von #Daten rund um taz.de verantwortlich.
Anforderungen:
* Sicherer Umgang mit XML, #XPath und XSLT (Version 1.0).
* Du kannst #Bash-Skripte lesen und schreiben.
* Du scheust Dich nicht, auch auf produktiven Debian-Maschinen, mit Hilfe der Kommandozeile zu operieren, Zeichenketten bis zu ihrer Hexadezimaldarstellung zu untersuchen sowie Logdateien von Servern zu analysieren und Stacktraces versuchen zu verstehen.
* Du hast Erfahrungen mit #SQL - sowie #NoSQL -/Dokumentenorientierten - #Datenbanken.
* Du hast Erfahrungen mit vernetzten Serversystemen und Schnittstellen, insb. mit #REST, #RPC, #AMQP und #HTTP.
* Du hast Verständnis für System- und #Datenbankarchitektur und behältst dabei den Blick für das große Ganze und insb. Themen wie #Performance, #Datensparsamkeit und #Datenschutz sowie Sicherheit und Wartbarkeit sind Dir ein Anliegen.
* Du hast Erfahrungen mit #Content-Management-Systeme n und diese im besten Fall auch schon #headless im Einsatz genutzt.
Prima wären Erfahrungen mit #Git, #SVN, #Apache HTTP Server-Konfiguration, Regulären Ausdrücken sowie #JSON. Auch Erfahrungen mit einer weiteren #Programmiersprache, insb. einer deklarativen/funktionalen sind von Vorteil.
* Analytisches Denken und die Fähigkeit komplexe Zusammenhänge zu überblicken.
* Sehr gute Selbstorganisation und Planungsfähigkeit, insb. kannst Du Dich selbstständig in Techniken mit Hilfe von technischen (und meistens englischsprachigen) #Dokumentationen einarbeiten.
* Eigenverantwortliches Arbeiten und Durchhaltevermögen, auch wenn es stressig wird.
* Erfahrungen im Nachrichten- und Verlagsumfeld sind von Vorteil.
Wenn Du Lust darauf hast, in einem nach wie vor politisch motivierten Umfeld, als Teil des Web-Entwickler:innen-Teams auch abteilungsübergreifend mit vielfältig interessanten Menschen, mit #Produktentwicklung, #EDV, #Redaktion und Verlag sowie externen Dienstleistern zusammenzuarbeiten, melde Dich.
Bei der taz bieten wir nicht nur ein kollegiales Arbeitsumfeld, sondern auch familienfreundliche Arbeitszeiten (flexible 36,5h Vollzeit Woche und 30 Tage/Jahr Urlaub) und es gibt ein ordentliches, subventioniertes #Mittagessen im #taz-Café sowie die Möglichkeit, ein Job Rad zu nutzen.
Wir wollen diverser werden. Deshalb freuen wir uns besonders über Bewerbungen von People of Color und Menschen mit Behinderung. Deine Perspektiven sind uns wichtig und sollen in der taz vertreten sein. Die Arbeitsplätze und Toiletten sind weitestgehend barrierefrei. Das taz-Café ist mit dem #Rollstuhl erreichbar.
Schicke uns Deine #Bewerbung und zeige uns, welche Kenntnisse und Erfahrungen Du gerne bei der taz entfalten möchtest. Es handelt sich um eine volle unbefristete Stelle ab taz-Lohngruppe V. Arbeitsaufnahme ist zum nächstmöglichen Zeitpunkt. Schreibe uns gerne, ab wann Du einsteigen könntest und richte Deine Bewerbung an webjob@taz.de.
#Datenmanagement #Datenanalyse #Datentransformation #Stellenangebot #Stellenangebote #Job #Jobs #Arbeit #Brot
I've been working on this code for storing settings in a JSON file. It's for the mindfulness-at-the-computer project
def settings_file_exists() -> bool:
return os.path.isfile(JSON_SETTINGS_FILE_NAME)
def save_dict_to_json(i_dict_to_save: dict, i_file_path: str):
print("save_data_to_json")
with open(i_file_path, "w") as write_file:
json.dump(i_dict_to_save, write_file, indent=2)
def load_dict_from_json(i_minimum_dict: dict, i_file_path: str) -> dict:
print("load_data_from_json")
ret_dict = i_minimum_dict.copy()
if os.path.isfile(i_file_path):
with open(i_file_path, "r") as read_file:
from_file_dict: dict = json.load(read_file)
diff_key_list: list = []
for min_key in i_minimum_dict.keys():
if min_key not in from_file_dict.keys():
diff_key_list.append(min_key)
print(f"One or more keys needed for the application to work were not "
f"available in {os.path.basename(i_file_path)} so have been added now. "
f"These are the keys: {diff_key_list}")
diff_key_list: list = []
for file_key in from_file_dict.keys():
if file_key not in i_minimum_dict.keys():
diff_key_list.append(file_key)
print(f"One or more keys in {os.path.basename(i_file_path)} are not "
f"used by the application (though may have been used before). "
f"These are the keys: {diff_key_list}")
print(f"Before merge {i_minimum_dict=}")
print(f"Before merge {from_file_dict=}")
ret_dict.update(from_file_dict)
# -if there are different values for the same key, the value
# in from_file_dict takes precendence
print(f"After merge {ret_dict=}")
return ret_dict
SK_SHOW_BREATHING_TEXT = "show breathing text"
SK_REST_ACTIONS = "rest actions"
SK_BREATHING_AUDIO_VOLUME = "breathing audio volume"
SK_BREATHING_BREAK_TIMER_SECS = "breathing break timer secs"
# The values given here are the minimum values needed for the application to work
min_settings_dict = {
SK_SHOW_BREATHING_TEXT: True,
SK_BREATHING_AUDIO_VOLUME: 50,
SK_REST_ACTIONS: {},
SK_BREATHING_BREAK_TIMER_SECS: 3,
}
# Initial setup
if not settings_file_exists():
rest_actions: dict = {
"Making tea": "path/to/image",
"Cleaning workspace": "/home/user/_",
"Walking meditation": "path/to/image",
}
min_settings_dict.get(SK_REST_ACTIONS).update(rest_actions)
db_file_exists_at_application_startup_bl = settings_file_exists()
settings: dict = load_dict_from_json(min_settings_dict, get_json_file_path())
print(f"{settings=}")
#python #programming #coding #json #datapersistence #mindfulness-at-the-computer #matc