Hacker News new | past | comments | ask | show | jobs | submit | bionoid's comments login

I use Video Background Play Fix [1] (along with uBlock of course). "Firefox for Android can continue playing video even if you switch to another tab or app. However, sites can detect these user actions with the Page Visibility API and the Fullscreen API. This add-on is designed to block events and properties exposed by the APIs."

[1] https://github.com/mozilla/video-bg-play


I'm not sure if I picked it up from a documentary or book, but worth noting that the photographer Frank Hurley dived into the ice water and chopped through a wood wall to rescue the glass plate negatives from the sinking ship. I'm not sure what the best source for this is, but it's at least mentioned in [0]

[0] https://www.pbs.org/wgbh/nova/shackletonexped/images.html


I didn't get past the pricing page to be honest. Podio costs $20/seat for premium, your product costs $48 for pro (with enterprise price not even listed)


Podio is designed for different use-cases than Jet Admin. What have you built in Podio?


Far too expensive IMO.


> 1080p at 240hz with a fancy graphics card

On manufacturer's website [0], both the 15" and 17" Stellaris are listed with WQHD IPS-Panel (2560 x 1440 pixels) - I was looking at them just a few days ago.. The article lists 1080p as option, but it's not possible to order.

[0] https://www.tuxedocomputers.com


Python also has "shorthand ternary" which uses and/or:

    a = bar and foo # "or None" is implied
    b = bar and foo or baz
It does almost the same but not quite. In the latter example, if foo is falsey, it evaluates to "b = baz":

    b = bar ? (foo ? foo : baz) : baz


Woah! I was all ready to disagree with you, saying 'only for Boolean arguments'. In years of writing python I really thought `__and__`/`__or__` returned Boolean. (Of course they can, but for builtins I mean.)

https://docs.python.org/3/reference/datamodel.html#emulating...

It's not made clear here that I can see. Grr, needs type annotations!


That's the wrong part of the doc. You refer to the binary operators || and &&, etc.

This is the correct part: https://docs.python.org/3/reference/expressions.html?highlig...

Edit: you can't override "and" and "or" with dunder methods.


Ahh of course, thanks!


See the language around short-circuiting here

https://docs.python.org/3/library/stdtypes.html#boolean-oper...

The expression is returned based on its truthiness


Is this official, encouraged syntax? It looks like it's just exploiting short-circuit evaluation. `bar && foo || baz` works in Javascript as well for example.


No.

In fact, nearly 20 years ago PEP 308 ("Conditional Expressions") was made so people wouldn't need to resort to this sort of syntax - https://www.python.org/dev/peps/pep-0308/ .

Quoting from the Python FAQ from 2.6 at https://web.archive.org/web/20151030070641if_/https://docs.p... :

> In many cases you can mimic a ? b : c with a and b or c, but there’s a flaw: if b is zero (or empty, or None – anything that tests false) then c will be selected instead. In many cases you can prove by looking at the code that this can’t happen (e.g. because b is a constant or has a type that can never be false), but in general this can be a problem.

> Tim Peters (who wishes it was Steve Majewski) suggested the following solution: (a and [b] or [c])[0].


I have seen it a lot of code over the years, sometimes referred to as "shorthand ternary" or the "and-or-trick". In Python and/or do not return a boolean, but one of its input arguments. So I am going to say it is official syntax, but I don't know to what extent it's encouraged


Not only in python, but in most scripting languages. It’s hard to find one that doesn’t. But it’s neither official, nor ternary syntax anywhere.

  true and false or true
  true ?   false :  true
These are not equivalent. If the second argument is evaluated as false, the “ternary” breaks.

Lua suggests to use this as ternary, but it has only two false values (nil, false), which reduces the number of problematic cases a little.


It saves a character in code golf, but as others have pointed out, it's unsafe.

    a if b else c #+1 byte
    a and b or c  #buggy
    (c,b)[not a]  #ok in general
    a and 1or c   #-1 byte if b is a constant
    (b,c)[a]      #-4 byte if a is boolean


or None is not implied

    >>> repr(False and False)
    'False'
    >>> repr(False and False or None)
    'None'
False is not None

    >>> False == None
    False


As it's error prone, and only saves 1 character, it's not a great shorthand.


EDIT2: What I was replying to is no longer there.

It does short circuit, your logic is just purposely fragile. If you reverse the variables it will print Empty, because the and statement evaluates left to right and stops if one of the arguments is falsey.

  print(len(foo) > 0 and foo[0]  or "Empty")
And since len can't give negative numbers the more Pythonic way to do it would be like this. Even though I generally prefer normal if blocks.

  print(len(foo) and foo[0]  or "Empty")

edit: I do agree that you should probably avoid doing this at all, because it is easy to introduce subtle bugs.


My logic wasn't purposely fragile, I missed that the test goes on the left hand size of the 'and', which makes my case that it's error prone ;)


I cut my teeth on Perl back in the day, and while I have stopped using it completely by now, I am no hater. But this article does not contain the word "bless", and I wonder why it was left out. If I had to guess, it's not as easy to defend as the nice features.


I think Perl not having OO built-in hurt it a lot when the trend towards OO started.

Of course Perl is more functional than OO so maybe it's time for a comeback now the pendulum has swung back...


Actually I think, it was killed by its strange standard library. A good base OO module in the standard, proper datetime modules, a good exception standard, proper iterators and the like, would have gone a long way to avoid the massive fragmentation which is CPAN nowadays.

Then another breaking factor was, I think, actually the long slow Apache 2 and mod_perl 2 migration back then, leaving Perl in one of the areas where it used to dominate in limbo for a long time as other alternatives like standalone appservers and the like simply were not very common initially, so there was no clear migration path. I still think, this was worse than the Perl 6 confusion.

In the end, we're now in some kind of downward spiral, where Python, Ruby, PHP have MASSIVE advantages in regards to the scope of their package repositories, while CPAN support of modern things, especially interfaces to Web APIs, is permanently half assed and unfinished.


The Perl elite spent too many years futzing over whether to include a MOP (meta object protocol) in the stdlib and, if so, which one. Clunky Catalyst, with its weird subroutine signatures, was also no match for Rails, PHP and Django.


You raise a lot of good points. I believe it is a combination of factors.


> But this article does not contain the word "bless", and I wonder why it was left out.

Most people use Moose (or its variants) so they don't have to bless things anymore.


In case anyone is interested, the $N-Protractor algorithm was ported to Python for use in the Kivy framework [0]. Unfortunately it's tied to kivy's clock among other things, but easy to rip it out should you need it in a different context. There is also anexample application that can be used to create gesture templates [1]

[0] https://github.com/kivy/kivy/blob/master/kivy/multistroke.py

[1] https://github.com/kivy/kivy/tree/master/examples/demo/multi...


My interpretation is $1 reads as "unistroke"/"singlestroke" while $N = "multistroke"


The FAQ suggests that NFS is problematic for concurrent access:

> But use caution: this locking mechanism might not work correctly if the database file is kept on an NFS filesystem. This is because fcntl() file locking is broken on many NFS implementations. You should avoid putting SQLite database files on NFS if multiple processes might try to access the file at the same time.

https://www.sqlite.org/faq.html#q5


Oh yeah, I read all that after I started seeing problems, I know I'm in the wrong here. It works just good enough that I haven't addressed it yet (I just kick over the process when things get weird, and the db usually recovers just fine).


The subreddit is /r/Random_Acts_Of_Pizza and still in operation. /r/RandomActsOfPizza was a copycat started with the explicit purpose of bartering nudes for pizza (forbidden in the original). It was later shut down when it turned out it was run by a scammer.


Sounds like OnlyFans with extra steps. You can have a brilliant idea but if you don't have the right PR, the icky factor will turn people off.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: