HNHacker News
TopNewBestAskShowJobs

jventura

1,604 karma · joined February 4, 2016

https://joaoventura.net/
submissionscomments
jventura··on Sieve of Eratosthenes in Python (2015)
There's a small optimization on the original article which I think your implementation doesn't do: "At each stage we know that every composite number up to p^2 has definitely been marked as such"..

Assuming your implementation is working fine (didn't test it), I think the change would be j = i * i on the inline for:

  void sieve()
  {
      for(int i = 2; i < n; i++)
          for (int j = i*i; j < n; j += i) p[j]++;
  }
It's tricky to explain, but take for instance the numbers from 1 to 20. When i=2, it will clear [4, 6, 8, 10, 12, 14, 16, 18, 20] as non-primes. So when i=3, you can skip 6 (which was cleared by i=2) and start directly at 9 (i * i = 3 * 3) to clear [9, 12, 15, 18]. Also, when i=4, you can skip the 8 and 12 (which were cleared by i=2 and i=3) and start on 16 to clear [16, 20]. Finally, when i=5, you can start directly at 25 (out of bounds in this case) because 10, 15 and 20 were already cleared by the previous iterations..

Edit: But as other posters are saying below, the original sieves algorithm shouldn't even have to test i=4 because the numbers it clears (naivelly [4,8,12,16,20]) have already been cleared by the previous iterations of the algorithm.

jventura··on Socratic method to teaching by asking
> When it comes to my docs, my current stance is that it's worse to create something that's too open-ended than too closed

I agree with you as my own approach is also more towards the step-by-step.

And you are right that I also have the luxury of my presence being helpful for when the students get stuck, although I try to make my tutorials so that they do not need much of my help. Also, some students cannot go to my classes as they work, and this approach allows them to do the lab assignments at home without much help from me.

Regarding the broken feedback loop, one possible alternative for web-based instruction is something that requires the user to insert solutions somewhere and have feedback on it. There's a SaaS that allows you to do programming assignments and you must submit it and run it in their servers. Perhaps you could explore something like that, although with JS you could run it in the browser directly?

jventura··on Socratic method to teaching by asking
> One problem with this, though, is that I'm still just telling my readers what to do.

I would advise you to not write tutorials based in questions. But I've read on the diagonal your JS debugging tutorial, and it seems quite "dry" because you are really telling the users to "do this, do that, etc.".

I'm a CS teacher, and my approach for my lab classes is to write what I call "guided tutorials", i.e., I guide my students to the answers (as a sequence of steps) but I do not give them the answers. It is a kind of middle thing between something based on questions and a step-by-step tutorial, and it works very well for me.

I can send you an example that I gave to one of my classes on network sockets, if you want to check it out (in portuguese though). My email is in my profile.

jventura··on Ask HN: What was your first computer?
A ZX Spectrum +3, connected to an audio cassete player. But my first PC was a 386DX 33Mhz with 130 MB of hard disk, msdos 5.0..
jventura··on How I got to 200 productive hours a month
Nope, I'm reading this and thinking how I could do only 1 to 2 hours of deep productive work. I want to simplify my life...
jventura··on Resources to get better at theoretical CS?
Any suggestions on how an arrangement like that could work out for you, like weekly 1-hour online meetings for instance? Just trying to gather some generic opinions, aka "testing the market" :)
jventura··on Resources to get better at theoretical CS?
An alternative to the books and links posted here could be to find someone who can help you with your "basic" CS doubts? Kind of a hire-a-CS-tutor, who could provide you with the necessary information, teach you something and eventually pointing the way forward..

As a CS professor myself I've been entertaining this idea for a part-time thing, but I don't know how many people could be interested on a service like this.

jventura··on Underestimating the power of Jeff Bezos
“There’s the peacetime C.E.O. and the wartime C.E.O. Not to be overly dramatic about it, but this is sort of a war. This is a wartime period. That just means that we need to change a lot of things. We need to just break shit. Sorry to say, we’ve got to break shit and embrace being uncomfortable sometimes. And it’s scary. It’s definitely a scary thing to do. But it’s also fun: you know, lean up against the wall and break it.”

Does these kind of words work with people older than 20? I once had a CTO that also started with these shitty things on the first meeting and he was fired less than 3 months later, as people sabotaged him and his work. Almost nobody gets excited when someone tells you that your professional life is going to change drastically, come on!!

When behaviors are entrenched, you have to be diplomatic, smart and cautious..

jventura··on Linear Algebra for AI
If AI == Neural Networks only, maybe matrix knowledge is enough, but when you start to include NLP, Expert systems, SEarch algorithms such as A*, Minimax, etc. in the AI category, you'll have to know more mathematics..

AI is much more than neural networks!

jventura··on What every software engineer should know about search
Neural networks are all the rage these days. As my knowledge on NNs is quite limited, what I could grasp from the wikipedia article [0] and the original paper [1] is that word2vec uses a vector to represent words in a n-dimensional space.

This seems quite similar to LSA (Latent Semantic Analysis). In LSA, a word is represented by a vector (list / array) of values which represent the number of occurrences of the word in a document. For instance, the list [0, 5, 9, 10] for the word "aeroplane" means than "aeroplane" occurs zero times in D1 (document #1), 5 times in D2, etc. Unlike LSA, word2vec seems to have the vectors values implicit in the neural network weights (?).

The interesting thing on these kind of approaches is that words that share similar contexts, tend to occur in the same documents. In other words, the vectors tend to have approximate values. For instance, it is natural that "aeroplane" tends to occur in the same set of documents as "aeroport".. Tf-Idf [2] does something similar, so these vectors are mostly a data representation of single words.

As for my research, the basis of it was to be able to quantify how "specific" a word or multiword is. The idea is that the more a word/multiword occurs in different contexts (in my case, near different words) the less specific it is. Being able to identify the specificity of words allowed me to know which words/multiwords were probably concepts and which ones weren't. Then, with these concepts I was able to use Tf-Idf to extract document keywords and later I was able to infer broad relationships between concepts (like in if two words tend to co-occur in the same documents and same parts of documents, they are somewhat related).

So, how does word2vec compare to my research?

- I prefer simple statistical approaches like the one I did (which is just counting frequencies and dividing numbers, etc.) than the black-box approach of neural networks. I can tell you why my research provides good results (explained above) but if you read a follow-up paper on word2vec [3] this is what you can find in section 4: "Why does this produce good word representations? Good question. We don’t really know".

- Also, bag-of-box approaches like word2vec and LSA don't tend to represent multiwords (such as "President of the United States of America", which leaves out lots of information on texts.

- Finally, I think there's more possible applications after you know which words/multiwords are informative. With word2vec and LSA you are only representing something similar to frequencies of words in documents, which mostly allows for Information Retrieval-like applications. On the other hand, one of the applications I did with the extracted concepts was to implement a prototype which allowed us to find the definition of a concept on the corpus. The idea was that the definition of a concept was the paragraph where that concept occurred many times but also used other concepts to help the first one to be defined. I don't know how you could do something like that using something like word2vec.

But as I said above, I am not that knowledgeable about word2vec, so I may miss something..

[0] - https://en.wikipedia.org/wiki/Word2vec

[1] - https://arxiv.org/abs/1301.3781

[2] - https://en.wikipedia.org/wiki/Tf%E2%80%93idf

[3] - https://arxiv.org/pdf/1402.3722.pdf

jventura··on What every software engineer should know about search
I used to work on textual Information Retrieval (which is quite related to search). One of the key contributions of my PhD thesis was a statistical method to extract concepts from texts [0].

Surprisingly enough, with those concepts, Tf-Idf [1] was quite good to extract keywords from documents which allowed us to build document descriptor tables which can eventually be used for document search [2]. We also built a small prototype that allowed us to retrieve results of specific areas of documents where the searched concepts were more "valuable" than on other parts of the document [3].

It is a very interesting subarea of AI/NLP which unfortunately doesn't seem to attract much interest.

Since the article also talks a bit about Wikipedia dumps datasets, here's a tool that I've created to build textual corpora: https://github.com/joaoventura/WikiCorpusExtractor

[0] - http://www.sciencedirect.com/science/article/pii/S1877050912...

[1] - https://en.wikipedia.org/wiki/Tf%E2%80%93idf

[2] - https://link.springer.com/chapter/10.1007/978-3-642-40669-0_...

[3] - https://link.springer.com/chapter/10.1007/978-3-642-40669-0_...

jventura··on Facebook, You Needy Sonofabitch
As a small part of a larger change in my personal life, I've also decided to delete my facebook account as well as Linkedin and other social media accounts. Basically I was in the need for a mental break.

Too much mental stimulation, specially from things that don't have much interest, was making my mind very shallow and easily distracted. I still read a lot of HN, but I'm trying to reduce my internet leisure time to 1 hour per day at most.

Since now I easily get bored, I started doing some sudokus (on a paper book) and I am finally starting to feel my mind a little bit sharper. I also feel the need to find more productive things to pass the time. For instance, three days ago I explored, quite in depth, C pointers and pointer arithmetic because of the first comment on this hn thread [0]. Also, yesterday, starting on the hn thread on microkernels [1], I started reading about these "alternative" OSes (Minix, HelenOS, etc), checked the source code of some of them, and eventually played a bit with nasm assembler and made a 32 bit and 64 bit "hello world" app for MacOS. These are things that I wouldn't learn and do if I was being mentally "stimulated" by facebook and that kind of things.

However, one positive thing about facebook is that those friends that used to send emails with funny memes, videos and what else, now use facebook for that. As a result, my email inbox is now much cleaner and calmer.. :)

[0] https://news.ycombinator.com/item?id=15198093

[1] https://news.ycombinator.com/item?id=15216615

jventura··on Facebook, You Needy Sonofabitch
My girlfriend used to grab her phone and start scrolling the fb newsfeed while we were talking. As she knows that I've deleted my fb account, my trick was to gently remind her that we were in the middle of a talk, and although she may be able to do two things at the same time, I don't, and her using the phone is distracting to me and makes me break the flow of the conversation. Like Pavlov's dog, she is now so accustomed to that, that I don't really need to say anything anymore. I just look at her doing that, she understands and turns off the phone (well, most of the time at least).

Even if you aren't both in the middle of a conversation, I suggest to you to slowly start talking to her about all these shaddy things about facebook (important: is not an addiction but a mental conditioning, as "addiction" is a very strong word for some people and "conditioning" is a much fuzzier concept). Then, slowly, start noticing that her "conditioning" on facebook is a turnoff on certain situations. Be honest and frontal about that..

jventura··on Ask HN: What books have made the biggest impact on your mental models?
No More Mr. Nice Guy by Robert Glover. Raised as a peaceful kid whose introversion taught me to try to control my world and keep things to myself, I am now more aware of how much healthier it is to set boundaries and just let the world run its own course. Immensely happier!
jventura··on Good News for Young Strivers: Networking Is Overrated
What's the name of your book?
jventura··on Disconnect. Offline only
And why, would i ask? For instance, I was supposed to be reading an ebook on my iPad, but instead I've been reading this thread for the past half hour...
jventura··on What Happens to Creativity as We Age?
Same for free flying, in my case paragliding. You'll start to better understand the weather, clouds, which side of the mountain is on the sunlight (because of thermals), and every small hill is an opportunity for flying, however short..
jventura··on Annual note to self: most of the world exists outside the tech bubble
I agree with you but I would say that programmers are not the problem but are the "technical" part of it..
jventura··on Ask HN: Projects that don't make you money but you're doing it out of sheer joy?
I built MockREST - http://mockrest.com/ - to create REST APIs from JSON content.

I've only spent 9€ to buy the domain as the application (django application) is on a shared server. I'm making 0 €$ from it, as it was made to solve a problem that I had while teaching mobile development where I teach.

jventura··on Benefits of a Lifestyle Business
I can only think of price-comparison or review-based websites. Is that what you're talking about? How could you monetize something like that without ads, for instance?
jventura··on There Have Always Existed People Who’ve Simply Wanted to Be Alone
As an introvert myself, I do lack the necessary skills to "handle" other people, although I've been slowly working on them. As time goes by, I find it easier to handle other people, although I still prefer to be by myself most of the time.

It just crossed my mind that, as an hypothesis, may it be that introverts prefer to be alone because socializing is hard since we lack the necessary skills?!

jventura··on Ask HN: How to sell your app/side project while working full-time?
Is it as simple as returning the IP address from the incoming TCP/IP message? If so, damn, why don't I have this kind of ideas! :)

Edit: it seems so - https://github.com/rdegges/ipify-api/blob/master/api/get_ip....

jventura··on Emotional Intelligence Needs a Rewrite
> "How do you enable your brain to create a wider variety of emotions and improve your emotional intelligence? One approach is to learn new emotion words. Each new word seeds your brain with the capacity to make new emotion predictions (...)"

This is a very interesting article. However, I wonder if/how the concept (or skill) of emotional granularity can be obtained only from learning new words for emotions. It kind of reminds me of NLP (Neuro-Linguisting programming).

Anyone here has any knowledge on these subjects, or is aware of an accessible research paper where this is explained in a simple way? Also, how is this approach of emotional granularity seen by other researchers?

jventura··on Why Apple and other tech companies are fighting to keep devices hard to repair
HP is also a well-behaved player regarding repairments. For instance, here's the service manual for my HP DV5 laptop: http://h10032.www1.hp.com/ctg/Manual/c02666786.pdf. You can find the replacement procedures for almost all components after page 48..
jventura··on Ask HN: Starting blogging when you're not an expert?
Could you expand on how do you get your students that pay for your lessons? I'm asking this as someone who is a CS teacher in a local university but would like to earn something on the side..
jventura··on Ask HN: Starting blogging when you're not an expert?
Genuine question, you say that "all of a sudden I had some expertise (which) was in demand". Have you been able to monetise on your expertise?
jventura··on Introverts, Emotional Processing, Self-Esteem and Salary Negotiations
I used to the same, but that didn't brought me anything good as I started ignoring my emotional state up to the point that people around me started saying that I was like a robot or something.

Lately, I've started to read some peer-reviewed research and book by researchers on emotions, and I've come to accept that emotions are mostly a biological mechanism which allows for a faster reaction to inputs (from external inputs or internal inputs - thoughts) before your intellect has time to process those inputs.

The book "Emotional Intelligence" by Daniel Goleman has a very interesting chapter (Anatomy of an Emotional Hijackin) that tries to explain biologically what happens with emotions. The idea is that some of the sensory inputs, for instance, visual, are sent to the amygdala as well as to the visual cortex. But since the visual cortex has to do some processing which takes time, the amygdala has a faster but sloppier response. For instance, someone throws a ball into you while you're looking away. You can grasp something by the corner of your eye, and then you raise your arms to defend yourself. Only later you see that it was an inoffensive beach ball. The first reaction was by the amygdala while the identification of the ball was done slowly by the visual cortex..

So now I try to enforce a small amount of time to understand my emotional feedback mechanism before reacting to things. But if it's a shark coming my way, I flee, of course. You learn a lot about your self and your own beliefs by listening to your automatic emotional responses before commiting yourself to any action/reaction. For the case of the coworker, ideally I would say him to slowdown, unless I knew beforehand he was a jerk, and maybe I could be more prepared..

jventura··on Introverts, Emotional Processing, Self-Esteem and Salary Negotiations
Following your suggestion, I would add that people should read "How to win friends & influence people" by Dale Carnegie.

The bottom line of the book is that people that want to get along fine with others should be wary of the other people's emotions. For instance, of the the first "principles" in the book is to not criticise, condemn or complain people openly, because people get defensive (an emotional reactional) when you do that, and you can't get nothing out of them. The rest of the chapters are also related with other people's emotions.

As for "genuinely cares", the book also talks about it in some chapters. What I could get out of it so far is that someone who listens with attention is mostly grasped as someone who genuinely cares about other people..

All in all, the bottom line of the book is all about "managing" the other people's emotional reactions..

jventura··on Introverts, Emotional Processing, Self-Esteem and Salary Negotiations
He says exactly that in the post: "Why couldn’t I think of the snappy response? Because I can’t do verbal processing and emotional processing at the same time!!!"
jventura··on Lindy effect
I'm thinking here if one should generalize that idea to other things we buy, as to make sure that everything we buy has no faulty components. For instance, if we buy a new car, should we stress it to check if something breaks while still within the legal guarantee period, etc.. Of course, one should not stress it too much to the point of wear out prematurely (as in the end of the bathhub curve).

Do you know of any literature, articles, etc., about this? I'm asking more from a consumer's view point..

← PreviousPage 11 of 19Next →