Comment by Mark on How do I require one field or another or (one of two...
@Tomeamis "not required" means "may or may not be present", while "inclusion forbidden" means "must not be present", that's not the same
View ArticleComment by Mark on How does Go compile so quickly?
"the optimizer works on the assembly code" Assembly code sounds platform dependent, do they really have a separate optimizer for each supported platform?
View ArticleComment by Mark on Django call_command no-initial-data option
@pymen Good to know it's deprecated, thanks. I don't see the danger of using initial_data though if you're flushing the database anyway.
View ArticleComment by Mark on Java Array HashCode implementation
@Torque It only doesn't hurt if equals() is crappy in the same way. Normally a hashCode that is 'basically random' would be a serious problem, because if equals is true then hashCode must be same. A...
View ArticleComment by Mark on How to have one colorbar for all subplots
@gboffi Oh that's good to know, it seems to be experimental for now and didn't exist back in 2016, but seems like a good improvement.
View ArticleComment by Mark on best way to preserve numpy arrays on disk
@argentum2f Fortran unformatted, a binary format used by Fortran with decades of history but I think not a lot of users today. See the repo for more details.
View ArticleComment by Mark on How can I overcome "datetime.datetime not JSON serializable"?
@SmitJohnth I'm glad you ask, because this is why I made json-tricks: github.com/mverleg/pyjson_tricks
View ArticleComment by Mark on Let's Encrypt kubernetes Ingress Controller issuing Fake...
This is useful advice for others, but from the screenshot in the question it doesn't look like the OP has a staging certificate. It'll show organization as (STAGING) Let's Encrypt if it is.
View ArticleComment by Mark on cert-manager: no configured challenge solvers can be used...
* was the problem for me too, according to an article I found, wildcards are only possible with dns challenge instead of http (and only cover one dot-level).
View ArticleComment by Mark on nginx : rewrite rule to remove /index.html from the...
^(.*)/index\.html$ for the (very unlikely) case you have index/html or index2html or something
View ArticleComment by Mark on How can I get the return value of a function passed to...
@EricH. Alternative solutions are valid answer on stackoverflow. The fact that Pool is easier doesn't make it bad, rather it might be considered an advantage to many users.
View ArticleComment by Mark on How do I sort a map by order of insertion?
Extra context: the slower lookups are still O(1) average, but worse memory locality.
View ArticleComment by Mark on systemd apparently not finding .service file
@PierredeLESPINAY As of v248 it's still in the manual, but if you find the cause / workaround please edit it into the answer!
View ArticleGzip output different after Python restart
I'm trying to gzip a numpy array in Python 3.6.8.If I run this snippet twice (different interpreter sessions), I get different output:import gzipimport numpyimport base64data = numpy.array([[1.0, 2.0,...
View ArticleAnswer by Mark for What is the most efficient way to split a list evenly in half
This works and seems like a simple way:def splitList(array): n = len(array) half = int(n/2) # py3 return array[:half], array[n-half:]
View ArticleDelete field from standard Django model
NOTE: this was asked before AbstractUser existed, which is probably what you'd want to use these days.Basically I would like to delete the default email field from the default Django User class...class...
View ArticleAnswer by Mark for Etags used in RESTful APIs are still susceptible to race...
You are right that you can still get race conditions if the 'check last etag' and 'make the change' aren't in one atomic operation.In essence, if your server itself has a race condition, sending etags...
View ArticleAnswer by Mark for Finding unused methods in IntelliJ (excluding tests)
This feature works only for batch inspection and disabled in the editor.¹According to the JetBrains IntelliJ IDEA 2016.3 EAP Makes Unused Code Detection More Flexible blog, it's now possible.You can...
View ArticleUse 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 ArticleWhen using i18n_patterns, how to reverse url without language code
I am using i18n_patterns but I want to use reverse to create a link to the page without language in the url (such that the user will be redirected based on cookies and headers and such).I have tried...
View ArticleIntelliJ IDEA find usages of overriding method without finding sibling methods
I have a parent class P with subclasses A and B.I would like to find all usages of a method f of A.So either p.f() or a.f() but not b.f(), because an instance B b cannot call A.f.I know I can findCalls...
View ArticleAnswer by Mark for Is there a NumPy-like package for Node.js and if not why not?
I've not tried this, but I found node-lapack. Since NumPy gets most of it's speed from using BLAS/LAPACK to do everything, this should help. From the readme it looks like it has an array object too,...
View ArticleHow to turn Koka effect control flow into an external iterator?
Koka has nice ways to model control flow with ctl effects:pub fun main() var n := 20 var sum := 0 (handler { ctl yield(j) { println(j) sum := sum + j n := n - 1 if n > 0 then resume(()) } }){...
View Article