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 6y ago · link · parent

> The bit about how when you strip a bolt it becomes your whole project and how you then need to pause and think through all the options before you before proceeding I am sure saved countless hours and dollars to a lot of people.

The bolt here is just used as an analogy for how to address problems in life, balance importance you give to micro vs macro, the beauty and danger that scales up and down in anything, etc.

Sure, it's a smart one, actually useful if taken literally as well, because the writer is very talented.

> The bit about really understanding how the thing works before attempting to repair it is great.

Again, another analogy. The whole book is teaching you how to think. And then go beyond thinking, as an art of living.

Every page is a personal, human lesson. You can stop at the mechanical aspect of it, but it is missing why this is a fantastic writing. It's giving profound advises using a simple, down to earth, vocabulary.

I could have done so with any other gimmick. Just like star wars could have replaced light sabers with something else. It just became an iconic symbol because it's so obviously recognizable and easy to grab.

But of course, they are also good because they chose such an symbology to make it easy to refer to.

You know where you were in class, and the teachers analyzed a book and you though in your head, BS! ZAMM is an exception to that. It is, really, a conscious and deep work of teaching that goes several levels down.

comment 6y ago · link · parent

See my other comment, this is no different that keeping any other employee around.

comment 6y ago · link · parent

In the same way Star Wars has incredible bits about light saber battling.

comment 6y ago · link · parent

It depends of how the company behaves. It's no different than with any other employees.

Give people the feeling they are part of something, that their day to day actions have a meaning, and enough money for their trouble, and they'll stay.

Say "we are a family" in your speeches and write "values" on the walls while you are just fitting cogs in the machine while optimizing for numbers and they will leave, or do the bare minimum they can if they need the cash.

This is not something you can fake. Not for long at least.

So it's not related to apprentices.

However, apprentices will more likely fit in your culture, accept changes, etc. Because they grow with you.

comment 6y ago · link · parent

The ideal situation is to pair each apprentice with an experienced dev, with a fixed time allocated every day to help them.

Yes, it's costly. Yes, the experienced dev needs to be ok with it.

Then you find small tasks you know people can google their way around and that you know won't lead to a disaster if they are done badly or if something break.

Then you increment.

Apprentices are very slow and very demanding at the beginning. Once they are productive though, they have the best cost/benefit ratio of your company, provided you did the first steps well.

Source: been an apprentice for 5 years, and all my classmates were.

comment 6y ago · link · parent

ZAMM has little to do with fixing motorcycles so I'm not sure it would be that relevant.

comment 6y ago · link · parent

I though you were joking. But no.

A widget doing:

    0 ----------[37]------------------ 100
Is 17kb, __gzipped__. Compressed. Archived.

It's 3ko more than the entire front page of Hacker News, including all the content and assets, after zipping.

comment 6y ago · link · parent

I think it's all those videos/gif in autoplay.

comment 6y ago · link · parent

I don't think it's going to be a fairly high price point. Satellites are becoming commodities, Space X drove the price of launching down, and with the current technologies a small computer can process a lot, especially if you don't have to care about heat dissipation. Quite the contrary, you don't need to construct many towers in cities to get coverage, with all the legal burdens that implies and all the maintenance it requires. You will cover a much broader space, so your potential customer base is bigger for the investment, and you can even cover places that would have not been before. In fact, you can even have better signal for moving people like in trains, cars or... boats and planes !

Of course this is all speculations, but it has a lot of potential.

comment 6y ago · link · parent

And anybody can make an amazon review. Very few people have the skills required to peer review a scientific paper.

comment 6y ago · link · parent

I don't. I have a huge knowledge base I store on my computers with those kind of things. E.G: this snippet is actually almost verbatim a file I have on my laptop I wrote months ago and kept so I don't have to rewrite that again.

comment 6y ago · link · parent

jupyter-notebook is not meant for that. It's meant for code and data exploration. If you dev something using the notebook, you are doing it wrong. That's what IDE are for.

comment 6y ago · link · parent

> If you wouldn't mind going into a little more detail about what you're doing I'd really appreciate it!

What do you want to know ?

comment 6y ago · link · parent

"with" is always a good idea indeed.

But be careful, map() and submit() + as_completed() don't have the same effect.

The first one will give you the result in the insertion order, while the later give you the results in the order they are completed.

comment 6y ago · link · parent

We are getting there. asyncio in 3.7 is now quite ok to use.

Plus, I'm working with andrew sveltov on a new API for aiohttp, so that you can do:

    def main():
        response = await aiohttp.get(url)

    asyncio.run(main())

It should make at least the most common use case of asyncio way more easier.

The biggest problem is that I have yet seen a tutorial that explains properly how to use asyncio.

They all talk about the loop, and future, etc..

First, they all should tell you that asyncio should be used only with Python 3.7+. Don't even bother before. Not that it's not possible, but I've done it, and it's not worth the trouble.

Then, all tutorials should mention wait() or gather(), which are the most important functions of the whole framework. It kills me to never see those explained.

With just that knowledge, you can script happily at least as easily as with the pools I just had show case.

Now, I really hope that we are going to get trio's nurseries imported in the stdlib. yury selivanov is working on it from uvloop, so I got good hopes.

I did a proof of concept as an asyncio lib and it works decently, but having a standard would be much, much better.

comment 6y ago · link · parent

Pocket is not integrated with your bookmarks. For offline consultation, you need a separate app. Of course this app is not available on Linux, where you have to get some community provided tools.

Bookmark integration would mean one software, with the same UI, on every platform, and only one listing for your whole archive system.

comment 6y ago · link · parent

You put the call in a function where you wait for it, and pass it to the thread pool.

Or you use asyncio for network based stuff.

comment 6y ago · link · parent

Besides, you have only access to the text. A website like Amazon has a huge list of additional data points to make guesses.

comment 6y ago · link · parent

Don't follow this blog post advice.

Manually dealing with threads and processes is useful if you want to build a framework or a very complex workflow. But chances are you just want to run stuff concurrently, in the background.

In that case (which is most people case), you really want to use one of the stdlib pools: it takes care of sync, serialization, communication with queues, worker life cycle, task distribution, etc. for you.

Plus in such case, waiting for results is super easy:

    import time
    import random

    from concurrent.futures import ThreadPoolExecutor, as_completed

    # the work to distribute
    def hello():
        seconds = random.randint(0, 5)
        print(f'Hi {seconds}s')
        time.sleep(seconds)
        print(f'Bye {seconds}s')
        return seconds

    # max concurrency is 2
    executor = ThreadPoolExecutor(max_workers=2)
   
    # submit the work
    a = executor.submit(hello)
    b = executor.submit(hello)

    # and here we wait for results
    for future in as_completed((a, b)):
        print(future.result())
Want multiple process instead ? It's the same API:

    import time
    import random

    from concurrent.futures import ProcessPoolExecutor, as_completed

    def hello():
        seconds = random.randint(0, 5)
        print(f'Hi {seconds}s')
        time.sleep(seconds)
        print(f'Bye {seconds}s')
        return seconds

    # Don't forget this for processes, or you'll get in trouble
    if __name__ == "__main__":

        executor = ProcessPoolExecutor(max_workers=2)

        a = executor.submit(hello)
        b = executor.submit(hello)

        for future in as_completed((a, b)):
            print(future.result())
This is Python. Don't make your life harder that it needs to be.

comment 6y ago · link · parent

Auto-play means more views means more ads means more money, yet. But I don't think it's the same for comments.

Comments don't have adds. They are a feature that cost money, but don't bring any.

comment 6y ago · link · parent

I like the idea, but wanted to know how realistic it would be so I made a quick and dirty Python script to download all my bookmarks. If you want to make the same experiment, you can get it from here: https://gist.github.com/ksamuel/fb3af1345626cb66c474f38d8f03...

It requires Python 3.8 (just the stdlib) and wget.

I have 3633 bookmarks, for a total of 1.5 Go unziped, 1.0 Go zipped (and we know we can get more from better algo and using links to files with the same checksum like for JS and css deps).

This seems acceptable IMO, espacially since I used to consider myself a heavy bookmarker and I was stunned by how few I actually had and how little disk they occupied. Here are the types of the files:

   31396 text/plain
   3034 application/octet-stream
   1316 text/x-c++
   1123 text/x-po
    865 text/x-python
    384 text/html
    227 application/gzip
    218 inode/x-empty
    178 text/x-pascal
    113 image/png
     44 application/zlib
     29 text/x-c
     28 text/x-shellscript
     14 application/xml
     13 application/x-dosexec
     12 text/troff
      5 text/x-makefile
      4 text/x-asm
      3 application/zip
      2 image/jpeg
      2 image/gif
      2 application/x-elc
      1 text/x-ruby
      1 text/x-diff
      1 text/rtf
      1 image/x-xcf
      1 image/x-icon
      1 image/svg+xml
      1 application/x-shockwave-flash
      1 application/x-mach-binary
      1 application/x-executable
      1 application/x-dbf
      1 application/pdf
It should probably be opt-in though, like a double click on the "save as bookmark icon" to download the entire file, and the star becomes a different color. Mobile phones, chrome books and raspy may not want to use the spaces, not to mention there are some bookmark content that you don't want your OS to index, and show you preview of in every search.

But it would be fantastic: by doing this experiment I noticed that many bookmarks were 404 now, and I will never get their content back. Beside, searching bookmark, and referencing them is a huge pain.

So definitely something I wish mozilla would consider.

comment 6y ago · link · parent

The author says:

"that formerly beloved browser feature that seems to have lost the battle to 'address bar autocomplete'."

But at least in firefox, if you type "*" then your searched terms in the URL bar, it actually queries your bookmarks !

There are many such operators, you can search in your history ("^"), your tags ("+"), you tabs ("%"): https://support.mozilla.org/en-US/kb/address-bar-keyboard-sh...

My favorite is "?", which is not documented in this link. It forces search instead of resolving a domain name.

E.G: if I type "path.py", looking for the python lib with this name, Firefox will try to go to http://path.py, and will show me an error. I can just add " ?" at the end (with the space) and it will happily search.

It's a fantastic feature I wish more people knew about.

It very well done as well, as you can use it without moving your hands from the keyboard: Ctrl + l gets you to the URL bar, but Ctrl + k gets you to the URL bar, clears it, insert "? ", then let you type :)

It's my latest FF illumination, the previous one was discovering that Ctrl + Shirt + t was reopening the last closed tab.

comment 6y ago · link · parent

> In your opinion, how many of these points are "git gotchas" that the first group need to be trained in, and how many are "subversion gotchas" that only really come up for the second group?

Many years ago, SVN users coming to git were indeed a huge source of head scratching.

Not anymore.

Now we just have a lot of people that just don't think in a way that will lead them to say "So, there's an isomorphism between (1) a commit node; and (2) the chain(s) of commits ending in that node.". In fact, they don't know what isomorphism means, nor that the word exists.

Personally, I like to picture git as applied graph theory. One command = a bunch of operations on the graph.

But there is an old git joke that says:

"Git gets easier once you understand branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space".

It is nonsensical (it's a meta reference to a Monad joke), but I think it gets the point perfectly: we need to bring git to the people that needs it, not to ask the people to come to git. I don't care what level of abstraction they are comfortable with, I want them to feel like they can trust their ability to be productive with the tool and feel their project is safe.

And I find that this way of explaining branches is the most universal way for people from all sorts of background to have a decent model of how git works under the hood. So that when fall in a trap, they can use this model and find a pragmatic way out by themself.

Being right used to be my objective when I was younger. Now I just want to be helpful.

comment 6y ago · link · parent

Was going to say that. reflog should be in every tutorials.

When I started using git, I checked out back in time, then git logged and was baffled to not see my most recent commits in the listing. I panicked, though I lost my work.

Git terrible UI didn't help there: who though it was a good idea to just hide everything with no hint of how to get back at it?

Of course, I could have just git checkout master to get back where at was, I just didn't know it. But that's the point of reflog: if you are not sure what you did or where you are, it's always there for you, it has your back.

comment 6y ago · link · parent

It helps to NOT think of a branch as a commit node, nor a chain of commits ending in that node.

A branch is a separate concept, it's not even stored in the history DB but in a different dir. See it as a label attached to a commit, since a commit can have several branches attached to it, or none. A branch will be moved across the history, while a commit will keep his place in the history.

A branch is designed to be easily created, deleted, and moved around, freely, from anywhere to anywhere.

A commit is designed to feel immutable, and unmovable, and although this is not strictly true, this is how you will mostly use it.

A chain of commits is like a rail track, it goes in one direction, each commit composing it never changing (again, conceptually), and never moving. You stack commits, you grow the track, piece by piece.

The branch is more like a flag you put somewhere on the rail track (most often at the end), to let the workers know where to put the next piece.

Picturing it that way let you best use its properties:

- branches cost nothing. They are very lightweight, unlike in SVN, you should create as many as you want.

- moving to a branch is cheap. Apart from moving the files to the working copy, it's just a matter of changing point of view on the history. Switch to branches often, it's fast.

- you can put a branch anywhere you want. You like an old commit and wanna try something new from it? Plant your flag here and start working.

- deleted a branch by mistake ? No worry, it's just a label. You can recreate it in a blink.

- this branch is so good it should be master? Sure you can. Just swap the labels. But let everyone knows :)

Etc.

comment 6y ago · link · parent

When I was at the university I was enraged by the grades the other students were getting: it was not because it was complicated, it was because the topic was poorly explained.

So I asked the uni to borrow a classroom and hold my own courses, a summary once before every exam. The grades went up and I felt useful for the first time in my life.

I kept explaining things to friends and colleagues after that, while being a full time dev. That's the only thing I was consistently better at than most people. There were better devs, but I could explain python decorators to a junior like if it was the most obvious thing in the world, and I felt proud of it.

I also still was regularly irritated by the terrible state of teaching. Why do people explain react by first installing webpack + babel while you can just drop a script tag and start playing? Why do nobody tells you what a bloody env var is, like you are supposed to be born knowing that? Why no beginner course ever include an intro to a debugger, do you enjoy having your students suffer? Why do they keep using the confusing reverse arrow in git history schemas, as if technically correct where the best kind of correct?

One day, I decided to do charity work in West Africa. I ended up stayed there for 2 years, eventually created my own company. Things where good.

Then the war started. My company went down, my bank account was frozen and I was forced back home, in debt. Fun times.

I looked for missions to quickly make cash, but in France dev doesn't pay that much. So I dug, and noticed that training professionals was incredibly well paid, thousands of dollars for a few days of work, which for the country is insane. It felt like stealing. It still does sometimes.

But I needed the money, and I though I was good at it, so I spammed dozens of entities. After a few courses, in which everybody was surprised there were no slide and the program kept changing, the phone started ringing.

Apparently most professional trainers suck too, and companies were astonished that not only the trainees could enjoy the session, but that they gained productivity afterward. Why did they paid so much money before, then? It's a mystery to me.

But I kept at it every since.

I usually do training once a month: JS, Python, Git, lot of web, a little bit of data analysis, best practice or design patterns.

But I still dev the rest of the time, otherwise I would always go from planes to hotels and that's no life. Besides, a trainer who doesn't code becomes obsolete very quickly.

Yet I try to get remote gigs for American clients: french customers never pay as much and they are very risk adverse so the projects are less interesting. I do have a few, because we know each others very well and working together is a blast: we can have drinks, say offensive jokes and still get the stuff done. Money is not everything.

All in all, I like training people. It's frustrating, infuriating even sometimes. And exhausting. But when I'm fed up with computers, I get to see people. And when I'm fed up with people, I go back to my computer.

comment 6y ago · link · parent

- detached HEAD: "git checkout existing_branch" or "git checkout -b new_branch"

- you don't where somewhere and you moved and you can't go back: "git reflog"

- local repo and remote with a different history (e.g: you rebased on a published branch): the whole team to sync with remote except you, then hold. Export your remaining changes as a patch. Reclone. Apply patch.

- remote has a different history than the rest of the team (e.g: you forced push a different history): Delete remote, recreate, repush from one of the team mate, then apply previous solution.

- your messed up your merge and wish to never have done that: "git reset --merge"

- the last commit is not published and you messed it up: "git commit --amend"

- the last commit is published and you messed it up: "git revert HEAD"

But rather than solve problems, better not get them in the first place. Always "git status" before anything, always get a clean working copy before checkout/pull, create a fat gitignore, etc.

comment 6y ago · link · parent

Well, it is said that a wise man never calls himself a sage. Others do.

comment 6y ago · link · parent

Of course. Someone explained it to me, after all.

In git, a branch is NOT like a wooden branch on the trunk of a tree, although it ends up being at the top of one, which makes the analogy ok.

A git branch is the same thing as a git tag, except it moves automatically when you commit from it.

You can see it as a lightweight label attached to a commit. If your HEAD is itself attached to a branch (HEAD is also a lightweight label, but this one is like a red sticker on a map saying "you are here"), when you do "git commit", the branch label is moved to the newly created commit.

Hence, you can have several branches on a single commit, and you can move branches around: they are just labels. You can also have branches with different names locally and in a remote, or have a branch with the same name, but on different commits locally and in a remote.

A branch is like a reference, it's useful to tell git what place in the history you are talking about, without referring to a commit in particular. It is a moving reference because the place in history you talk about is always changing: it's the top of a chain of commits, the ever changing last thing you worked on for this particular part of the history.

We want branches because they are a convenient way to say "I'm going to do something on the latest commit of this part of the history":

- "git checkout branch_name" => I'm now working on this part of the history, gimme all the latest stuff you got and consider everything I do is now related to it.

- "git checkout branch_name /file/path" => Get the latest version of the file from this part of the history and bring it on my hard drive

Of course, you can put a branch at a commit that is not yet the top of a chain of commits. But soon this commit will become the top of a new chain of commits because when you'll commit from this branch, a new commit will be attached to the previous one, diverging from the original chain, and the branch label will be moved to it. You now have a fork of two chains of commits, both of them having a different branch label at their top:

"git checkout commit_hash && git checkout -b new_branch_name" => I'm going to consider this commit as a new starting point and work from that.

In fact you can move a branch pretty much anywhere, create one or delete one at anytime, including "master", which is not a special case, just one created automatically on the very first commit.

This is also why if you "git checkout commit_hash" instead of "git checkout branch_name", git warns you you are in a "detached HEAD" (the "you are here" label is attached to a commit directly, not a branch label). Indeed, a chain of commits (the stuff that looks like a wooden branch on a trunk in graphics) can exist without a branch label. But it won't be convenient to reference: looking for the hash of the newest, latest commit, every time you want to mention it is tedious. Besides, git will run "git gc" automatically once in a while, deleting diverging parts of the history with no branch or tag, so you may lose this work.

This makes it clear that tags are labels like branches, only they don't move. They serve the purpose of having a static reference to a fixed point in time: both allowing you to easily talk about it, and let git know you want to keep this around.

All that stuff is way clearer with a visual explanation. For my Git training, I bought a fantastic toy for 10yo with magnets that let me build a 3D history tree and use post-its to represent branches and tags. It's instantly obvious. It's really fun, you can move stuff around and show what each command does to the tree. After that, git seems much more accessible, and you just grunt at the terrible UI ergonomics.

comment 6y ago · link · parent

Oh one can identify experts very easily: they are the ones that understand nuances, see and explain things as cost/ratio instead of good/bad and have an up to date view of their ecosystem of choice but are ok with other techs.

The problem is that they are easy to spot only for somebody with experience in the field. This is why companies sometime pay good freelancers to help with hiring: they can assess what the company can't.

And once they do, they realize quickly that:

- there are few experts

- most resumes are bs

- experts are expensive

- they probably don't need them for most tasks and the bs resume dev may be ok, given the price and skill constraints

- they had one expert internally all along, doing half the job of the rest of the entire team and they should make sure this expert stays

1
180181182183184