News for hackers. Stuff that matters.

quinnftw

Re:static-server: an HTTP server in Go for static content on Saturday September 16, 2023 @06:57PM (#37539651)
Looking at the code this appears [1] to be a very thin wrapper around go's built in file server from the http package.

[1]: https://github.com/eliben/static-server/blob/main/internal/s...

Re:Customize Python dependency resolution with machine learning on Thursday November 25, 2021 @05:12PM (#29345448)
It could: What if a machine learning algorithm picked each of your dependency versions for you ~magically~
Re:Retro Review: 2009 Mac Pro in 2018 on Sunday March 25, 2018 @05:41PM (#16674773)
I run a 2010 MacBook pro which I have upgraded the RAM and swapped out the disk for an SSD (luckily 2010 was pre motherboard soldering nonsense). It still runs like a champ 8 years later.
I wonder if one could introduce a secondary classifier which is immune (or more resistant) to this kind of attack as a fail safe. One idea that comes to mind is to back the neural net with a random forest, which I imagine would be very hard to trick with this kind of attack as a collection of independent (key) weak learners are trained on the data. To trick a random forest, you would have to trick the majority of the trees within it.
Re:Write Fast Apps Using Async Python 3.6 and Redis on Thursday April 27, 2017 @04:06PM (#14214262)
You can use caching to mimic this behaviour in Flask, I.e.

http://flask.pocoo.org/docs/0.12/patterns/caching/

I'm not sure how this works with multiple threads though, I imagine you would have to synchronize it yourself.

Re:An Introduction to Reflection in C++ on Saturday April 15, 2017 @12:55PM (#14121563)
Cruising along with frequent pit stops for garbage collection.

All jokes aside I agree with you to some extent: C++ can be frustrating to work with, and there are a lot of quirks that make it really easy to blow your foot off.

These quirks are not without benefit though. Being able to control how memory is allocated is hugely important in performance sensitive applications where pointer chasing is not tolerable. The same can be said about r values/move semantics.

Re:Mapping Strings in C++ on Wednesday April 12, 2017 @05:25PM (#14101908)
I thought this aswell, but you have it backwards. The point is to convert a string to it's corresponding enum, not the other way around.
Re:Data Structures and Algorithms Problems on Wednesday April 05, 2017 @03:30PM (#14044823)
Genuine curiosity because I don't have a whole lot of experience with embedded systems: Why not just use C then?

Either way I would argue that using sizeof in that way is a sketchy practise.

Re:Data Structures and Algorithms Problems on Wednesday April 05, 2017 @02:11PM (#14044232)
One nitpick (and this applies to almost every site of this genre, i.e. geeksforgeeks, hackerrank, etc.):

The code listed as "C++" is essentially C with ostreams. If I were interviewing someone and they claimed to know C++, and then used "sizeof(A) / sizeof(A[0])" to get the size of an array, I'd question how much C++ they actually knew. I understand that the focus here is mainly on problem solving and not language specific patterns, but when you advertise the site as a coding interview helper I think that the solution code should reflect that which should be written in an actual interview.

Re:On mutex performance and WTF::Lock on Sunday April 02, 2017 @11:42AM (#14017540)
I'd be interested in seeing the rational behind the fairshare policy. I suppose theoretically the firstfit policy could result in starvation via one thread constantly preempting another during the lock contention, but I don't imagine that would happen very often in practise.
Re:What's new in C++17, with lots of examples on Monday March 06, 2017 @04:44PM (#13806326)
This is true, though generally anytime one uses `auto` it should be `const auto&` to avoid swallowing the quantifiers and potentially costly copies anyways.
Re:Mysterious Gmail account lockouts prompt hack fears on Sunday February 26, 2017 @03:33PM (#13739671)
Call me naive, but I REALLY think people are overreacting on this. Yes, the timing does seem quite coincidental given the Cloudflare bug, but Google has a pretty good record of being transparent with these things.

On top of this, Google does not use Cloudflare and as far as I know there have been no reports of accounts actually being comprised, only logged out. I would wager whatever maintenance routine they were carrying out accidentally invalided some user sessions.

Re:Common Multithreading Mistakes in C# – Unsafe Assumptions on Wednesday February 22, 2017 @02:47PM (#13708587)
Potentially, yes. Assuming that you are correctly synchronizing the actions inside each Task as to avoid race conditions (a big assumption), there is no control on the number of threads here. What if your program is already using a bunch of threads for something else, and then you go ahead and spawn off 10 more? You will oversaturate the CPU and end up with virtual threads, thus incurring scheduling overhead. In my opinion when you are doing this type of thing you should almost always use a thread pool to ensure that you aren't creating an unreasonable number of threads.
Re:The most cited deep learning papers on Thursday February 16, 2017 @10:01AM (#13660322)
I think what you are describing here is simply "average number of citations per year", no?
Re:Mkfile(8) is severely syscall limited on OS X on Sunday February 12, 2017 @08:15AM (#13628181)
Yes but mkfile uses syscalls to create and write to the file. With a smaller buffer more write syscalls are required to populate the file.
Re:Ask HN: What C++ parallelization framework do you use? on Thursday February 09, 2017 @09:22AM (#13607061)
I've found that most of my multithreading needs can be serviced by a simple thread pool that I rolled using the constructs that c++ provides (std::queue, std::thread, and std::future mainly). Obviously it's not heavily optimized, but for CPU bound tasks it gets the job done and doesn't require any heavy lifting installing libraries and what not.
Re:14 Character Random Number Generator in C on Wednesday February 08, 2017 @04:31PM (#13602334)
This particular one isn't large, but in general a pseudo-prime will produce similar effects.
Re:14 Character Random Number Generator in C on Wednesday February 08, 2017 @09:17AM (#13598327)
I noticed that too, I think he may be referring to the fact that generating super large actual prime numbers is hard, so people use probabilistic algorithms to generate probably almost primes
Re:The multiprocessing module in Python on Friday February 03, 2017 @04:00PM (#13563267)
Not quite. You can submit as many jobs as you'd like to the pool and it will delegate them to 16 threads. The pool maintains a queue of work to be done and the fixed number of threads consume from the queue.
Re:How Do I Declare a Function Pointer in C? on Thursday January 19, 2017 @04:52PM (#13439794)
You could also do

    void foo(std::function<void(int)> callback);
A few issues with this implementation:

Is it really nessecary to allocate all of the hash buckets up front? Why not initialize them to null and then allocate them as you need?

Why not use some kind of managed container like std vector to store the hash buckets? This removes the need to do explicit memory management.

Why not use std forward_list instead of rolling your own linked list? Again, this will reduce the amount of code and save you from having to do manual memory management

Re:A recruiter sent me a message in code. I fixed it on Friday December 30, 2016 @01:09PM (#13285937)
OH! Haha my mistake, that wording is naturally ambiguous.
Re:A recruiter sent me a message in code. I fixed it on Friday December 30, 2016 @01:05PM (#13285916)
You would think someone that works at LinkedIn, a company that likely employees hundreds (thousand(s)?), of engineers would have this proof read before sending it off to potential applicants. This is a real turn off.
Re:C++17 – better than you might think on Friday December 30, 2016 @09:46AM (#13284579)
I develop solely in UNIX environments so I can't comment on its performance on windows, but it's fantastic on UNIX and very easy to write / configure.
Re:C++17 – better than you might think on Thursday December 29, 2016 @08:00AM (#13277019)
To piggy back on this comment: what build system are you using? I've found that bazel has greatly reduced compile times, even when using boost and opencv.
Re:Skip Lists Done Right on Monday December 19, 2016 @07:32AM (#13210984)
Something to note: you state that BST's have logarithmic time in order successor, but many implementations use threaded binary trees which provide an amortized constant successor operation. Great article though.
Re:Tiny-dnn – A C++11 implementation of deep learning on Wednesday November 30, 2016 @06:40PM (#13075727)
Is this not a binary perceptron? How do you plan to classify all 10 digits with this?
Re:The Case Against Artificial Intelligence on Wednesday September 28, 2016 @11:03PM (#12603042)
I'm not sure I would classify printing hand written strings as having a bot "write" the article.
Personally I would use a macro such as:

    #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
    TypeName(TypeName&) = delete;              \
    void operator=(TypeName) = delete;
Introducing a virtual base class for disabling copying introduces a vtable and un-needed inheritance.

Older »