621 karma · joined Jan 11, 2018 (8y ago) · 450 submissions
comment 6y ago · link · parent
Here's an example function for quoting from stdin:
function bashquotesingle() {
printf "'";
sed "s/'/'\\\\''/g";
printf "'";
}
Though it does have a bug, at least on macOS, where sed adds a trailing newline. (See https://stackoverflow.com/questions/13325138/why-does-sed-ad...)comment 6y ago · link · parent
In JavaScript or PHP, it’s usually easy to figure out if something is meant to be an int, string, array or object (yes we’ve probably all done “1”+1=>”11” before, but it’s very rare).
But if you are using classes, it’s very useful to distinguish at coding time which exact class an object is. Often you’ll end up with multiple classes with similar sets of properties, and it’s imperative to know which one is being used so you call the right methods.
comment 6y ago · link · parent
Before I had a car, I once bought a dumbbell set. Had to carry it 5 minutes to the bus stop. Box fell apart on the way. Bus driver wasn’t particularly patient with me needing multiple trips to get all pieces into and out of bus either.
Since I own a car and pay insurance, why would I bother with other forms of transit when they are slower and bring their own set of problems?
comment 6y ago · link · parent
graft: noun, a shoot or twig inserted into a slit on the trunk or stem of a living plant, from which it receives sap.
Edit: Ugh nevermind I found more definitions of graft. Google only showed the plant/medical-related ones by default.
comment 6y ago · link · parent
comment 6y ago · link · parent
With respect to exposing implementation details:
If the caller is the one who passed in the connection, then it makes complete sense to throw a SQLException so the caller can deal with it.
If the connection was opened in your method, then yes you probably should wrap it, handle it properly and clean up the connnection, and then throw a different exception.
The only time it's ambiguous is if the connection came from an instance variable. That's often a poor design, but usually means it came indirectly from the caller and so it still makes sense to throw SQLException.
In general, SQLException works fairly well as a checked exception. If some code generates a SQLException, your transaction failed and you should generally abort it (or you can check the specific error code if you are prepared to handle anticipated failures such as a duplicate key error). If it generates any other exception, you can continue working with the database (such as saving the failure status to a table).
comment 6y ago · link · parent
In the app case, you bought an IAP from Apple (I know it’s Facebook’s app, but that doesn’t change the fact that the transaction was executed by Apple) but somehow think it’s ok for there to be a note saying you can pay less if you buy it on your computer instead.
comment 6y ago · link · parent
I believe the (weak) answer to the above is the answer to your question. Features are what matters to the majority of users. The ability to sideload apps itself is not.
comment 6y ago · link · parent
comment 6y ago · link · parent
- legitimate websites using this feature for valid purposes, such as to control devices on your local network
- targeted malware attacks trying to hack devices on your local network
I’m certain we will not start getting popups for this on any mainstream website.
So as long as this permissions thing is more than a simple yes/no dialog, I’m not worried.
comment 6y ago · link · parent
By the way, I think you’d be in even more trouble if you wrote:
cat /dev/zero > acomment 6y ago · link · parent
My response was based on the OP suggesting the account closure was based purely on the App Store policy violation. I’m pretty sure it’s based on more than that, such as the fact that Epic is suing them in bad faith.
There’s probably a million app developers which have violated the policies in some manner at some point and yet very few get blacklisted by Apple.
comment 6y ago · link · parent
comment 6y ago · link · parent
UPDATE inventory
SET quantity = inventory.quantity - daily.amt
FROM
(SELECT sum(quantity) AS amt, itemId FROM sales GROUP BY 2) daily USING( itemId );
Basically just allowing a ON/USING clause after the first FROM entry as if it was joining to the table being updated.Otherwise it's kind of annoying when you end up joining to several tables in the update, but have to use the WHERE clause to join back to the main table.
comment 6y ago · link · parent
Basically the statement you made that employees are paid based on value delivered is not really accurate in most cases.
comment 6y ago · link · parent
1. Find the server via nmap
2. Guess at some URLs until the server finally responded with some hidden data.
While neither of those would require being an expert in the field, this is well beyond the realm of browsing public websites.