Use Gradle sub-projects with Kotlin multiplatform
I'm using Kotlin multi-platform (JVM & JS), which in IDEA creates three projects: demo, demo-js and demo-jvm.I would like to split the common code into more subprojects/submodules. Let's say I add...
View ArticleAnswer by Mark for numpy and Global Interpreter Lock
Quite some numpy routines release GIL, so they can be efficiently parallel in threads (info). Maybe you don't need to do anything special!You can use this question to find whether the routines you need...
View ArticleAnswer by Mark for Is there a performance difference between Numpy and Pandas?
There can be a significant performance difference, of an order of magnitude for multiplications and multiple orders of magnitude for indexing a few random values.I was actually wondering about the same...
View ArticleShare compiled dependencies between dev and release builds
I can compile Rust dependencies in optimized mode, while compiling your own code in debug mode:# Cargo.toml[profile.dev.package."*"]opt-level = 3debug = falseBut this still compiles all my dependencies...
View ArticleAlias for an aggregate column
I would like to get the average of a column using Kotlin Exposed.object MyTable: IntIdTable("MyTable") { val score = integer("score")val result = MyTable.slice(...
View ArticleHover/click area in filled line chart in chart.js
Given a line chart in chart.js with areas under the curve filled. Is there a way to get a useful event when the user hovers over or clicks the filled area?var chart_canvas =...
View ArticleRust expects two levels of boxing for generator while I only specified one
I am encountering a compiler error for something that I feel should work.I tried this code (note generators are nightly-only at the time of writing):#![feature(generators, generator_trait)]use...
View ArticleHow can I only show warnings if there are no errors?
Often during development, I have a bunch of unused imports and variables. I like to fix those after I have correctly working code. The warnings these generate cause me to scroll though the cargo build...
View ArticlePython ical: get events for a day including recurring ones
Is there an easy way to get a day's events from an ical file in Python?For non-recurring, one day events I have used something likefrom icalendar import Calendarfor event in...
View ArticleSin, cos etc for Python 2 Decimal?
In Python 2.6, I found that the Decimal equivalent of sqrt(pi) isDecimal(pi).sqrt()Is there anything like that for sin, cos or other (inverse) trigonometric functions?The docs only mention how to...
View ArticleChange taskbar menu in Tauri
I'm using Tauri and would like to change the menu items shown when clicking my application in the taskbar using the right mouse button (Windows/Linux) or double click (MacOS).For example Firefox shows...
View ArticlePython alternative to Javascript function.bind()? [duplicate]
In Javascript, one might writevar ids = ['item0', 'item1', 'item2', 'item3']; // variable lengthfunction click_callback(number, event){ console.log('this is: ', number);}for (var k = 0; k <...
View ArticleCache Cargo dependencies in a Docker volume
I'm building a Rust program in Docker (rust:1.33.0).Every time code changes, it re-compiles (good), which also re-downloads all dependencies (bad).I thought I could cache dependencies by adding VOLUME...
View ArticleAnswer by Mark for Cache Cargo dependencies in a Docker volume
Here's an overview of the possibilities. (Scroll down for my original answer.)Add Cargo files, create fake main.rs/lib.rs, then compile dependencies. Afterwards remove the fake source and add the real...
View ArticleAnswer by Mark for Else clause on Python while statement
Allow me to give an example on why to use this else-clause. But:my point is now better explained in Leo’s answerI use a for- instead of a while-loop, but else works similar (executes unless break was...
View ArticleAnswer by Mark for How to escape single quotes while setting aliases
The other answers contain better solutions in this (and most) cases, but might you for some reason really want to escape ', you can do '"'"' which actually ends the string, adds a ' escaped by " and...
View ArticleAnswer by Mark for How can I overcome "datetime.datetime not JSON serializable"?
Generally there are several ways to serialize datetimes, like:ISO 8601 string, short and can include timezone info, e.g., jgbarah's answerTimestamp (timezone data is lost), e.g. JayTaylor's...
View ArticleAnswer by Mark for Why does JSON serialization of datetime objects in Python...
If you want to get encoding and decoding of datetimes without having to implement it, you can use json_tricks, which is a wrapper that adds encoding and decoding for various popular types. Just...
View ArticleDefault trait method implementation for all trait objects
I have a trait MyTrait, and I want all trait objects &dyn MyTrait to be comparable to each other and to nothing else. I have that now based on How to test for equality between trait objects?.The...
View ArticleHow can I create hashable trait objects / trait objects with generic method...
I have some structs that implement both Hash and MyTrait. I'm using them as &dyn MyTrait trait objects.Now I want &dyn MyTrait to also implement Hash. I've tried a few things:Naively, trait...
View Article