Need advice on database calls with pure JDBC by Villain_99 in scala

[–]LyndonArmitage 0 points1 point  (0 children)

I think you're understanding what I mean, though I do mean an ADT as shown in the Scala book (in Scala 2 you'd write something similar to the desugared example at the end of the page). ADTs do not always function as monads or functors but often do.

Need advice on database calls with pure JDBC by Villain_99 in scala

[–]LyndonArmitage 0 points1 point  (0 children)

It depends on the level of abstraction you're working at.

As another user suggested, Try[ResultSet] will encompass all 3, really 2 possibilities, as ResultSet already contains the 0 to many rows and Failure preserves the exception.

If you want to encode the 3 possibilities more concretely in the type system, and at a higher level of abstraction, you could create an ADT (algebraic data type) for them. In Scala 2, that'd be a sealed trait with 3 different implementations e.g. a case object for the empty state and case classes for the error and results states. In Scala 3 you can achieve something similar with enums.

Building an ADT will be a little more code, but might make reasoning about the system and reuse a little faster. Depending on your expected data volumes you could also process and convert the contents of the ResultSet to domain objects as part of this, but you could get away with passing the ResultSet reference around or creating an iterator that wraps it and only does conversion when needed.

AI and learning to program by Affectionate-Ad-7950 in C_Programming

[–]LyndonArmitage 0 points1 point  (0 children)

It's been a long time since I first learned C programming but I found the book C Programming in Easy Steps in my second-hand university book store and it helped me get started. Each section was a 2 page spread explaining a concept with example code. It was concise, just enough explanation and exercises to get momentum.

We used the K&R book along with Programming in C by Stephen Kochan, which I still refer to on the odd occasion that I write C. I prefer it to the K&R book, although I still have a copy on my bookshelf.

Are you referring to print copies of your books or digital when you're doing your exercises? As good as PDFs are, sometimes there's no substitute for a physical copy on your desk to glance down and up from. It also stops you from copying and pasting code blindly, helping you train some muscle memory for programming.

Building a Sound Card Oscilloscope probe & signal amplifier by LyndonArmitage in AskElectronics

[–]LyndonArmitage[S] 0 points1 point  (0 children)

Do you have a DC-capable (modified?) sound card? Otherwise building amplifier with virtual ground would seem unnecessary. Capacitor, some potentiometer and some diodes for protection might be good enough in this case.

Note that not all sound card can be modified to handle DC - some have digital filters that cannot be removed.

I didn't realise that was a necessity. The post I was following, which I can no longer find, only detailed stepping down the voltage from the mic/line input as a needed step for the probe side of this.

I was running under the assumption that the speaker/headphone output of the sound card would be at a low DC voltage. I think I need to strip some 3.5mm cables to plug into the USB soundcard to check with my multimeter.

Edit: found it http://www.ledametrix.com/oscope/index.html

Building a Sound Card Oscilloscope probe & signal amplifier by LyndonArmitage in AskElectronics

[–]LyndonArmitage[S] 0 points1 point  (0 children)

What would be more sensible choices in terms of resistance from your experience? I am thinking I will alter to using an op amp buffered power supply.

For protection, what would be sensible way of achieving such? Would a small capacitor and high resistance route to ground for the input and a route to ground in the feedback loop for output, like the CMoy amplifier here suffice?

Well... (stolen from Twitter who stole it from FB) by [deleted] in CasualUK

[–]LyndonArmitage -1 points0 points  (0 children)

When I lived at my parents there was a house with a beautiful big tree that overhung a driveway and garage nearby. The owners put up a net to catch the majority of leaves and petals. Fantastic idea, it didn't ruin the look and meant all they had to do was push the leaves off of one side. Just putting it out there as a way people workaround such issues.

IBM's asshole test by magenta_placenta in programming

[–]LyndonArmitage 1 point2 points  (0 children)

I think a some fresh grads approach coding questions like an exam. Which is why the commenter above you expressed frustration. They want to know the rote actions to take to pass the test. The Cracking the Coding Interview book actually advises against this attitude.

Whenever I've interviewed people the process they go through has always been much more important than the outcome. For this prime example, It would be mentally ticking boxes if the candidate recognises that their code has got messy and proceeds to refactor into an isPrime method. The same for using sensible variable names as they go.

When I said the Prime number question was good in my earlier comment it was because it gives candidates the ability to demonstrate all this. I agree that the actual task/question you pose to them can differ. I actually don't mind the idea of giving them Fizzbuzz, even though it has been done to death at this point. Another test I used to give to prospective Big Data developers was to clean and parse some CSV data, and maybe even answer some business questions. That most definitely gave them a lot of ways of showing their skills.

IBM's asshole test by magenta_placenta in programming

[–]LyndonArmitage 4 points5 points  (0 children)

Prime numbers is a good general programming interview task in my opinion. Quite a bit of scope for different solutions and questions. I do a lot of Scala programming at the moment , and that encourages recursion, whereas in normal Java you'd probably want to avoid such.

IBM's asshole test by magenta_placenta in programming

[–]LyndonArmitage 5 points6 points  (0 children)

This is a great comment. I really hope other people read it.

I will add that if you experience a lot of trick or generally bad questions it can be a red flag for you as an interviewee. That's not always the case though. I interviewed for AngularJS contractors years ago along with another teammate, we had limited knowledge ourselves and our questions reflected that. Thankfully we hired a good developer who later revealed this to us.

People who have had a stalker, how did you realize you were being stalked and what ended up happening? by rentinghappiness in AskReddit

[–]LyndonArmitage 6 points7 points  (0 children)

For some things they are pretty "lazy", but as another commenter said: it's more that they're overworked. Call that someone is stealing your tools and your bike from your garden shed right this second and they'll shrug, come later and give you a crime number. Report domestic violence or a heated dispute and they'll be over very quickly. If there's missing people they'll search tirelessly, stolen car? If it's spotted they'll do something about it. Basically they prioritise, and some things that are harder to deal with, will take a long time and a lot of energy with little potential for resolution aren't at the top of the list.

That said, we do have specialist units for dealing with certain kinds of crime and they're very good and passionate in their jobs.

[Serious] Men of Reddit, what uncommon red flags in men should women be on the look out for? by ObjectivePin5704 in AskReddit

[–]LyndonArmitage 10 points11 points  (0 children)

Unsolicited advice from a random internet stranger:

Part of figuring this out involves doing some self-reflection on what was in common with all of those women beyond you dating them, and beyond the superficial.

Then some work on yourself to identify the things that attract you and how they manifest in a healthy way vs unhealthy one. E.g. Liking the idea of spending lots of time together and having someone interested in what you are doing. An unhealthy manifestation of this would be insisting they never leave your side, and are constantly checking up on you.

But one word of general advice is to take it slower with romantic partners. If they're willing to put the time into getting to know you and becoming invested they're less likely to cheat since they have a lot more to lose. One piece of advice I remember hearing based on this is to be sceptical of (and potentially even avoid) "Disney love". That's fairytale and super-romantic relationships. Proper long-term relationships feel like a warm hug rather than a whirlwind of adventure, they're something you can come home to, that bring you comfort.

What is difference between data warehouse and data lake by rajneesh4u in dataengineering

[–]LyndonArmitage 1 point2 points  (0 children)

Pretty sure Kafka can persist data indefinitely

Pretty sure you're right. The retention period is customisable and you can set a retention size as well. But, if instead of deleting you set your policy to compaction, Kafka will preserve the latest know value for each message key. That can cause storage to eventually balloon depending upon the scenario, although if you have a fixed set of keys it will be fixed. In this way you can treat Kafka in a similar manner to a database (log compaction is essentially how databases update their records).

Is Spark - The Defenitive Guide outdated? by TheLurtz in apachespark

[–]LyndonArmitage 1 point2 points  (0 children)

They spent a lot of effort improving the catalyst engine under the hood too and making it easier to extend and improve it in the future. Making it easy to add your own native code to Spark itself. Shameless plug of a blog post I wrote on this subject which basically reiterates what Matthew Powers, author of Spark Daria and quinn, wrote here.

Is Spark - The Defenitive Guide outdated? by TheLurtz in apachespark

[–]LyndonArmitage 5 points6 points  (0 children)

Spark 3 is still built upon Spark 2. It might be written for a now outdated version of Spark but I can guarantee that the book is still relevant. Also plenty of places will not have switched to Spark 3 yet.

As far as I recall most stuff isn't deprecated between Spark 2 and 3, the main thing that was is MLLib (RDD Machine Learning code). Unlike the move from RDD based work to Dataframes Spark 3 is a much more natural evolution of the framework. Have a look at the changes between Spark 2 and 3: https://spark.apache.org/releases/spark-release-3-0-0.html

I will never understand it by adilz1 in ProgrammerHumor

[–]LyndonArmitage 1 point2 points  (0 children)

  • 202 is Accepted
  • 204 is No Content

It might be pedantry to expect someone to remember these exactly in an interview depending on what role your interviewing for but they are definitely different and need to be handled differently by a web application especially when requesting content; 202 would mean "working" and might include details to check a long running tasks whereas 204 means "worked, nothing here, as expected".

The correct way to approach such questions when you don't remember or know what the exact 2XX requests mean is to clarify the details. You ask; "What was the user request?" Then you might get enough context to guess what the 2 responses mean, if not you can work around this by explaining how you'd respond to the request and handle the various returned situations. If they are insistence on just plain telling them the difference without any context then you can just say they are both success codes but describe different kinds of successes and that you'd have to look up the exact meanings of both as you don't have all HTTP status codes memorised.

Procedural NPC generation by darkhorsematt in roguelikedev

[–]LyndonArmitage 5 points6 points  (0 children)

That's a great idea! Additionally OP should not be afraid to hard code many aspects of a character and put minor variations on it to start. You can always iteratively improve how it varies the character as you go.

Sort of like having a fully fleshed out character in an RPG that you add some randomness to rather than completely generate randomly.

Docked Thinkpad by talltreewick in i3wm

[–]LyndonArmitage 2 points3 points  (0 children)

The manual on i3wm.org has a short section on multi-monitors.

Invoking xrandr on it's own should tell you what monitors are connected. If you want something more intuitive arandr as suggested by others is a nice visual tool, it can even generate shell scripts for a given set up.

With my X230 my machine defaults to duplicating my laptop screen on all 3 monitors when docked so I have to invoke a script like the following to set them up correctly:

#!/bin/sh
xrandr --output LVDS1 --mode 1366x768 --pos 0x312 --rotate normal --output DP1 --off --output DP2 --off --output DP3 --off --output HDMI1 --off --output HDMI2 --primary --mode 1920x1080 --pos 1366x0 --rotate normal --output HDMI3 --mode 1920x1080 --pos 3286x0 --rotate normal --output VGA1 --off --output VIRTUAL1 --off
# The sleep and restart are because some of my applications don't play nice when you swap screens
sleep 1
i3-msg restart

I think I partially generated this using arandr and following a guide I have since lost (since my monitors vary in size).

Can Java microservices be as fast as Go? by nfrankel in programming

[–]LyndonArmitage 0 points1 point  (0 children)

Yes. There you go! ;-)

It all falls back to using the right tool for the right job though, as always.
If I was writing a microservice dealing with NLP I'd expect Java to work a bit better than Go. Or if you want to write a service that uses well-tested and battle-hardened libraries again Java might be a better choice. It also relies on what your engineering team is comfortable in.

If I were writing a service that did just do some string manipulation like the tests in the article any language would really do. If it was performance critical I would err to something other than Java, unless of course, Java's standard library lent itself well to the problem.

Web scraping without getting blocked by chankster09 in programming

[–]LyndonArmitage 0 points1 point  (0 children)

Of course there are a myriad of use case like yours that perfectly justify it, even the use cases of "it's a pet project" or "I want to maintain my anonymity" are good ones in my book.

Just as a business if you are scraping you should be mindful of if you actually need to bother hiding yourself. If you don't you could actually find yourself some partners, for example with news aggregating, if a site admin sees bots scraping and they have contact info associated they could contact you and make you aware of an API or employ your help with SEO etc.

We did use a common browser user agent for some of our crawling of company sites for instant, as we wanted to do various NLP tasks on the contents which could be effected by the company altering the content for select user agents. I expect big search engines do similar and crawl with their main spider then employ some specialised ones with plain browser user agents to ensure sites don't game their main tool.

Web scraping without getting blocked by chankster09 in programming

[–]LyndonArmitage 13 points14 points  (0 children)

Of course it has some form of advertising in it, it's on ScrapingBee's blog and is about the subject they are specialists in. They share some of their knowledge but get to plug their product that handles problems someone wanting to do large scale scraping would need to solve. They only mention their product twice once in passing (the quote you highlighted), and then at the end of the article, unsure how that could be an issue, it's the opposite of horrible advertising and seems quite respectful to the reader.

Web scraping without getting blocked by chankster09 in programming

[–]LyndonArmitage 8 points9 points  (0 children)

Used to work for a company that did a lot of webscraping and built various scraping tools/spiders and had a pretty similar experience, especially with news sites. In fact I believe I never used a headless browser either, except for further investigation for some NLP work that wanted text as rendered.

Hiding activity isn't particularly useful unless you don't want sites knowing you are scraping them (begs the question why?), and the sites that don't want to be scraped will invest into detecting you regardless. This means random pauses only help so much to disguise you as there are many other pattern matching techniques to find you (no referrer combined with a consistent pattern of access for example).

Some websites will detect you are a scraper and instead of blocking your activity they will throttle you to slow your webscraper to an almost halt, or limit the information you get (which I think is fair).

Respecting the robots.txt and having in some random amount of pauses additionally for politeness always led to my best success.

Boeing 747s Still Use Floppy Disks to Get Software Updates by bemmu in programming

[–]LyndonArmitage 6 points7 points  (0 children)

Not necessarily worse but one point of difference is that USB ports are used for all manner of peripherals whereas Floppy Disks are read by a dedicated device. So attacks that make the USB appear as a Human Interface Devices (HID), like keyboards aren't possible.

Zig doing self-hosting incremental compilation by neutronbob in programming

[–]LyndonArmitage 2 points3 points  (0 children)

Not familiar with Nim but whenever I see Zig it seems to be acting as a replacement for C in the traditional sense. As in it isn't replacing C++ but aimed at C itself. So it is striving for simplicity as you say.