Better HN
topnewbestaskshowjobs
Log inSign up

BiteCode_dev

24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions

I write to save you time and effort when dealing with Python:

https://www.bitecode.dev/

Email: contact at bitecode.dev

Submissions

comment 5y ago · link · parent

https://docs.python.org/3/library/ast.html

Experience helps with this.

It's a middle path as usual: naive approaches waste as much time as overenginering.

comment 5y ago · link · parent

It's more of a design issue here. You could do away from classes while keeping types by using 2 lines:

    Expr = Callable[[str]], Callable[..., Iterable[str]]] 
    AstNode = Expr | Callable[... ], Callable[..., Iterable[str]]]
You then don't event need to call representation() , as each node is callable. No classes needed.

But my instinct tells me a node will eventually have more attributes and methods. Stuff to get parents, children, siblings, filtering and so on.

So it's probably a good call to use a class for later. Also you want to keep AstNode as a node could be an expression, a statement or a comment.

comment 5y ago · link · parent

I don't think most users expect their chat app to be protected if the police seize their phone.

The main concern is about intercepting messages between 2 parties or mass exploiting the history stored by the provider.

Sure, for some case, it can be important, but that's a much more difficult and rare threat model to address.

comment 5y ago · link · parent

Love this app. Recently, it became less and less usable, with deal breaker bugs like mails not sending reliably or at all.

So I'm going to donate, because this app is fantastic and I really want it to keep existing.

comment 5y ago · link · parent

That's basically what modern JS frontend frameworks do as well. I suppose as soon as something becomes too complex, keeping track of all interactions is just too complicated and rerendering the entire world efficiently looks like an easier problem to deal with.

I like the current trend of going back to renderless components as well. This way you separate the state changes from the way it looks like. Feels like each component is a miniature MVC framework with front and a back.

comment 5y ago · link · parent

Right. It's a good thing for the psf and it doesn't look like there a string attached.

comment 5y ago · link · parent

Google has earned billions thanks to techs like python, and never contributed much to it compared to what it gained.

Then suddenly this.

Now I'm wondering if MS hiring Guido triggered some reaction to not loose control of what is currently one of the most popular language in the world. Or something else I don't know about.

I really want to rejoice. My favorite language gets $ 350k.

Yet I can't help but be suspicious of philanthropy coming from big players. I'm getting cynical and always look for a PR, strategic investments or counter attacks.

comment 5y ago · link · parent

Currently you have 2 options:

- https://beeware.org/

- https://kivy.org/

I doubt Google is going to sponsor any though.

comment 5y ago · link · parent

If the browser supports JS, maybe you can quickly generate uuid based on the same pattern, load the favicon as data url and with onload, check if it's in cache. This would make it significantly faster.

comment 5y ago · link · parent

Some httpie tricks:

Use --offline to see the request but not perform it:

    http --offline get google.com
    GET   / HTTP/1.1
    Accept: application/json, */*;q=0.5
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Content-Length: 5
    Content-Type: application/json
    Host: google.com
    User-Agent: HTTPie/2.4.0
Pipe stuff to httpie to put it in the payload:

    echo "Hello HN" | http --offline get google.com
    GET / HTTP/1.1
    Accept: application/json, */*;q=0.5
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Content-Length: 13
    Content-Type: application/json
    Host: google.com
    User-Agent: HTTPie/2.4.0

    Hello HN
And use http-prompt, because it's awesome: https://github.com/httpie/http-prompt

comment 5y ago · link · parent

Not exactly apples to apples, but I'd like to plug in Vite: https://github.com/vitejs/vite

Not that it makes fast minification (which I don't care that much about, I minify only on deploy, and it's a small % of the time it takes), but it does allow for a very fast workflow in dev mode: auto reload seems almost instant even with heavy transpiling.

I only mention it because I assume people look at this articles and think about their dev process speed as well.

If you haven't, give it a try: it's from the Vue author, so it's really clean, but works with react as well.

comment 5y ago · link · parent

Pyz works with windows but not pex.

Nuitka produces a standalone exe so no need to install python.

comment 5y ago · link · parent

It's really a matter of culture.

Things like httpie, jupyter, etc should be provided as pyz and binaries as well, not just pip installable, but python devs don't do that really often.

It's a shame, because cli tools should be black boxes, people should not have to think about the implementation. I regularly see cli python tools that output stack traces on errors, and it should not happen.

Anyway, if you want those tools to be always around, I really encourage you to grap a usb stick, and put them on there as pyz and binaries. It's always nice to have them at hand.

Here is an example procedure for both (run them in a venv).

For pyz files:

    python -m pip install shiv --user # (Yes, I realize how ironic this is).
Then:

    python -m shiv httpie -o http.pyz -c http
(download httpie, and creates a http.pyz file that will contains httpie and all it's dependancies, plus code to trigger the http command when called)

This will let you do "python http.pyz" anywhere you have a modern python and enjoy httpie without the need to pip install it.

For an exe (this is an example on linux, the commands are a bit different for windows and mac):

    python -m pip install nuitka httpie --user
You need to have a C compiler and python headers around as well (gcc on linux will do, E.G: sudo apt install build-essential python3-dev on ubuntu).

Then:

    python -m nuitka $(which http) --onefile --linux-onefile-icon /usr/share/pixmaps/python3.xpm --follow-imports    --assume-yes-for-downloads

Wait quite a bit.

Now you have a nice stand alone AppImage you can call with ./http.bin to be used on any linux system, and not care if Python is installed to play with httpie.

Here are the resulting files (available for 5 days) so you can see what it looks like:

https://drop.chapril.org/download/a335a8e92f98ee02/#fHC1SvOw...

comment 5y ago · link · parent

I have a lot of respect for the way you react to this comment, and how quickly you fixed the bug.

Thank you for working on such a useful project, and so seriously.

I immediately encountered a second different error, and I'll also take the time to craft a good bug report for it.

comment 5y ago · link · parent

My first attempt, and I get "AttributeError: module 'toml.decoder' has no attribute 'TomlPreserveCommentDecoder'"

So careful, far from stable.

I reported it (https://github.com/frostming/pdm/issues/247) because the project is great and I want it to succeed, but I won't put it in prod any time soon. I prefer my package manager to be stable than fancy.

It's also why I don't use poetry and so on in training. There is always some bug that students will encounter later because there are so many config combinations they can encounter, but recent tools have not been as battle tested as we think: the enterprise world is a wild beast.

comment 5y ago · link · parent

That's literally what the article is about.

comment 5y ago · link · parent

First, so many tutorials give you terrible information. People don't know about "-m", the "py" command, are told to use sudo and not --user.

The current situation is actually not that bad. With my students, the topic is quickly explained and mastered. But it's not a common occurrence.

However, it is true that it's still not as easy as it could be. Some reasons.

- Python is older than java.

- Python is shipped as part of MacOS and Linux, but using the system Python can cause issues, so it's a trap.

- Python deals with a lot of compiled extensions. Scipy embeds C, fortran and assembly. It's a hard problem.

- The Python project has *tremendously* less resources than java.

- Politics. Lots of it.

- Debian et Red Had packagers made a mess by splitting the python setup in many small packages.

- Python 2/3 transition took attention span from the problem during a decade.

- You often install many python versions on the same machine, which makes things harder.

- Python is used by a huge number of non programmers. Much more than java. This shows in the reported difficulties.

- There are way too many ways to install python. So many combinations of failure modes.

- Microsoft screw up with their store not packaging "py" or the core dev by not packaging it on Unix.

- Anaconda brings as many problems as it solves, and is popular because of enterprise limitations.

comment 5y ago · link · parent

I'm being overly critical. Let's say it has problems:

- poetry shell didn't start the same shell that you were in: https://github.com/sarugaku/shellingham/issues/42. Looks like they fixed it 3 days ago though.

- It doesn't set the name of the project in the prompt, so you actually don't know you are in the shell. Very annoying if you have many windows.

comment 5y ago · link · parent

Poetry shell doesn't work on windows, and it doesn't have named venv which matters for some users. Also it's very slow, require to be installed and use proprietary fields in pyproject.toml.

It's a great tool but there are reasons you might want something else.

Alternative like raw pip, pip tools, or dephell all have various pros and cons.

comment 5y ago · link · parent

-m is the replacement for console scripts. Well behaved cli should define a _ _ main _ _. Py

Pytest, pylint, black, pip, poetry, mypy all have one.

Jupyter one is buggy.

comment 5y ago · link · parent

Thanks for making your tool opens ource.

Do you plan to add scripting capabilities to Espanso or do you prefer to focus on the current use case ?

comment 5y ago · link · parent

Bit of a plug, but if you crave for that, and more, you can use AutoKey on Linux (not AutoHotKey which is Windows only): https://github.com/autokey/autokey

It will let you bind custom Python scripts to any mouse/keyboard sequence, including words on the fly. It can trigger word replacements just like Espanso (I use it to fill in emails, dates, addresses, timestamps et phone numbers), and of course, Python being Python, it lets you do a lot more.

The UI is probably not as good as Espanso's, and it may be harder to use (you need to script). On the other hand, it provides an API for prompting you with UI to select dates, files, input, etc., has timers and the whole Python 3 stdlib.

Some nice stuff I do with it:

- typing $email/$ phone present me with a list of email addresses/phone num (I have a lot of them) to insert one. Prevents typo. By pass web form limitations.

- $now and $date does something similar with dates (listing of various formats for the current date and a calendar). Very handy for documents and file name. Most of them don't have automated fields set up.

- $paste paste the clip board content, by passing any UI preventing me to do so, and screen/tmux limitations.

- I'm a heavy dynalist users (dynalist.io/) I love this software, but it lacks a lot of features, which are easy to add with AutoKey: just make a macro that inputs a serie of actions.

comment 5y ago · link · parent

In France at least. Our forests have been growing faster than we cut them for a few decades.

comment 5y ago · link · parent

I took over the maintenance of 0bin.net, and FOSS client encrypted pastebin.

By design it's anonymous, so no account, and no tracking, hence not an obvious money maker.

But I like using it, and I feel no pressure to make it better or fix it, so I can work on it once a year and just be happy.

comment 5y ago · link · parent

If it's just a crud app and not, a spa, even with a bit of ajax, sure I can, and so most devs I know.

Bu5 we are professionals, using frameworks. That changes things.

comment 5y ago · link · parent

Ctrl + L then "*" will search in bookmarks for firefox.

Ctrl + L will focus the url bar, and then you can use several modifiers to search different things. E.G: ? will run a search engine query, even if you type something that looks like a domain name after it, such as a file anme.

comment 5y ago · link · parent

It's a trade off. You don't want to write all your types for quick scripts, data analysis and small web sites.

As a trainer, experience teaches me that it's also much easier for beginners.

Now, types are nice to have for bigger code bases, but that doesn't mean there is no place for a language with optional typing.

comment 5y ago · link · parent

For me, it's like writing 10824 "ten thousand eight hundred and twenty four".

I'd rather read a real regex using the verbose flag to comment groups:

- it shows the real regex for quick scanning and for those familiar with the syntax

- it explains things to the people that are not familiar with it or if the regex is complicated

- it forces the writer to divide the regex into logical groups

- such a system would have comment anyway, to indicate what you are matching such as "product code, date, color" for each part of the matching code.

- if you can't write or read regex and your job is programming, spending an afternoon learning them should be your next step. They are everywhere, no matter the tech stack: unix tools, IDE, 3rd party libs...

- there are plenty of regex tester UI, which let me copy the regex and test various case to see what it does, and tweak it

But I can see the value of such a lib for learning regexes.

comment 5y ago · link · parent

There is a pep for that: https://www.python.org/dev/peps/pep-0582/

comment 5y ago · link · parent

I keep using a lot of text messages: I have many people with different type of chat apps, or no chat apps at all (old gen), so the only way to reach everybody is doing that instead of juggling with different services.

I don't use whatsapp, and don't have an iPhone, so no imessage. Most people don't use Telegram or Signal which I do. Not to mention a lot of geeks have their favorite way of being contacted (slack, wire, etc).

And of course all that will have change in a few years. Before you had to have facebook. When in Asia, it was lime or something else.

As soon as you have a lot diversity in your life, text messages are the only thing that works all the time, plus they are free in my country.

In fact, iMessage is basically sending text messages without the user knowing they do if the other hand is not an Apple device.

In the end, I suspect text messages will still be here in 10 years, and all people around me asking to subscribe to yet another chat service will have change 3 times (and lose their contact list in the process).

1
150151152
184