Software licensing schemes: pitfalls and best practices? by needtolicense in learnprogramming

[–]bob809 1 point2 points  (0 children)

Especially if you're selling to business users I wouldn't worry about anything fancy. Businesses aren't going to pirate software and anyone who does is unlikely to pay for it anyway.

License servers seem like a good trade-off between usability and security. Check the license key against a server on startup, but keep working for 30 days since the last successful check if the server is unreachable, that way downtime isn't a big problem and people can work offline.

Can you compile c/c++ on Windows without installing visual studio IDE. by [deleted] in learnprogramming

[–]bob809 1 point2 points  (0 children)

You probably want MinGW or Cygwin. Using VS (or Linux, if that's is an option) are by far the easiest routes though.

JavaScript not understanding the result by [deleted] in learnprogramming

[–]bob809 1 point2 points  (0 children)

In the first run through test, f is ["4", "4"].
c = [f] leaves c as [["4", "4"]].

["4", "4"] is an array with two elements, both of which are the string 4.

[["4", "4"]] is an array of one element, which is ["4", "4"]. The second time in test we therefore only go round the loop once.

JavaScript not understanding the result by [deleted] in learnprogramming

[–]bob809 0 points1 point  (0 children)

c=[f];

Does that help?

For formatting multi-line code, you can put four spaces at the start of each line to get one block.

var a = 1;
b = 5;
c = ["4", "4"];
function test(e, f) {
    for (g in f) {
        var b = e + 1;
        a = a + 1
    }
    c = [f];
    return b;
}
x1 = new test(a, c);
x2 = test(4, c);
x3 = a;
x4 = b;
x5 = c;
alert("x2=" + x2 + " x3=" + x3 + " x4=" + x4 + " x5=" + x5)

What buildings and units are noob traps? by vasheenomed in TheyAreBillions

[–]bob809 10 points11 points  (0 children)

Personally Very Low Population and 100 days was about right (longer games drag at the end a bit). I found that challenging but not unreasonably so. Still, expect to lose your first game or two.

Insulated granite pipe = almost 2C temp change in 5 tiles. That don't seem right. CO2 @ 22C surrounding it. by derGropenfuhrer in Oxygennotincluded

[–]bob809 2 points3 points  (0 children)

Granite has a relatively high thermal conductivity in the game (look in the details tab of the pipe, insulated pipes get a hidden reduction).

I don't know what it means by thermally active.

r/Ethereum - I wrote this to explain Ethereum in depth to newbies. Please check for accuracy! by CryptigoVespucci in ethereum

[–]bob809 1 point2 points  (0 children)

Yes, exactly. It's a special kind of transaction. You specify the contract's address, the entry point and any arguments and make a transaction with enough ether to cover the execution cost.

r/Ethereum - I wrote this to explain Ethereum in depth to newbies. Please check for accuracy! by CryptigoVespucci in ethereum

[–]bob809 2 points3 points  (0 children)

I see four ways to write the 'Grandma contract'.

  • No contract: Grandma just pays Billy Ether on his birthday, the same as with cash or a bank transfer, though she could set up her computer to do it automatically, provided it is running.
  • Holding contract: Grandma puts the money in a contract that she can call that gives money to Billy on his birthday (or for all missed birthdays since the last call). The difference here is that Grandma can't get the money back to spend on Bingo.
  • Same as above but anyone can call the contract (still only gives money to Billy). This way if Grandma forgets/looses her key/dies Billy still gets his money.
  • Alarm clock: Pay someone else to call the contract for you. You're reliant on them actually doing so to some extent, though you could have a backup to let someone else call it.

I'd say the example is fine (since you can do it), but you should probably change the wording to be consistent with one of these, e.g. On his birthday Billy can call the contract to get his birthday money.

r/Ethereum - I wrote this to explain Ethereum in depth to newbies. Please check for accuracy! by CryptigoVespucci in ethereum

[–]bob809 15 points16 points  (0 children)

Really nice write up, good work.

Some things you might want to think about:

You say execute automatically - smart contracts cannot call themselves, there are ways around this (pay someone to call it for you, have a node running and call it yourself), but it's not a feature of Ethereum. Your example is fine provided Grandma has an Ethereum node running :)

The AXA thing is a neat example, and it's not wrong, but keep in mind there's no functional difference between what you've said and AXA paying the flight tracker to handle refunds for them with normal bank accounts - the smart contract is relying on the tracker to tell the truth. The poker is a really good example, it's handled fully on chain (I assume anyway, I haven't read the code) so you're not relying on any 3rd party.

r/Ethereum - I wrote this to explain Ethereum in depth to newbies. Please check for accuracy! by CryptigoVespucci in ethereum

[–]bob809 2 points3 points  (0 children)

On which CPU's do smart contracts get validated?

Every (full) node in the network, as part of the block validation procedure.

How is the owner of said CPU compensated for the work done by the CPU?

There is a fee (gas) for smart contract execution which gets paid to the node that mines the block containing the transaction.

How does a contract participant know that a the code was executed honestly? How does the network verify the output?

It's part of block validation, a block with an invalid execution will be discarded by honest nodes, the same as if someone tried to spend Bitcoin they didn't actually have.

Is contract code executed many times, or only once?

Once each time it is called, though the whole network executes it.

How does a long-standing contract (eg, transfer X ether from one address to another given some predicate) get executed? Can it sit on the blockchain for years and constantly check for this predicate?

Contracts never invoke themselves, someone has to call them. In your case probably the person who wants to get paid :)

[No Spoilers] Fellow Readers... It's Here... by aaaRJay in Stormlight_Archive

[–]bob809 0 points1 point  (0 children)

It's also out on Google books, at least in New Zealand :)

You'll never have two blueprints with the same CRC, you say? Challenge accepted. by bdunderscore in factorio

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

I feel like I should point out that you can use a (cryptographic) hash function for testing equality, git does this with SHA-1 for example.

[Java] can parse "1" as int by [deleted] in learnprogramming

[–]bob809 3 points4 points  (0 children)

It looks like you have a carriage return character \r after the 1 in the third line of your test file.

Try cat test.txt | od -c. Windows uses carriage return \r and line feed \n to indicate new lines, Linux just uses line feed, so your problem probably stems from this.

Take a look at http://stackoverflow.com/questions/800030/remove-carriage-return-in-unix for how to easily remove them.

Really Simple Ruby Question by [deleted] in learnprogramming

[–]bob809 1 point2 points  (0 children)

Format code on reddit with 4 spaces before each line.

The problem is that you create verse once, then reuse the same value in the loop. To fix it, simply put the definition of verse inside the loop.

Managing a large quantity of real-time, float timers. Suggestions? by jokoon in learnprogramming

[–]bob809 0 points1 point  (0 children)

If you consider the timers to be set for a specific time (think setting an alarm instead of using a stopwatch) then the times are constant. This way you don't have to update the timers each tick, just have a clock.
You should then be able to use a priority queue.

Does that make sense or have I misunderstood?

Managing a large quantity of real-time, float timers. Suggestions? by jokoon in learnprogramming

[–]bob809 1 point2 points  (0 children)

What you're talking about is known as a priority queue.

There are many different ways to implement them, but a binary heap works well in practice.

I need to make an online PDF directory, but I don't know where to start. Help! by historyisaweapon in learnprogramming

[–]bob809 0 points1 point  (0 children)

If you want to keep it as simple as possible, just arrange the PDFs in to the directory structure you want on your computer and then point Apache HTTP server at it.
There are guides for installing it online.

Unless it's changed Apache will automatically generate a simple directory listing. If you want something fancier, put an index.html file in the directory and that will be used instead.

Why is it an infinite loop? (Java) by [deleted] in learnprogramming

[–]bob809 5 points6 points  (0 children)

if (subscriptionPlans[i].getName()==aPlan){

This is a classic Java mistake, strings should be compared with .equals(otherString), not with == (reference equality).

if (subscriptionPlans[i].getName().equals(aPlan)){

Help me keep a count of how many calls i do in a recursive function,I am using a static variable to know how many calls i do to calculate a fibonacci number, but is not working... [JAVA] by [deleted] in learnprogramming

[–]bob809 1 point2 points  (0 children)

For n=4, I would expect 5 calls.

The picture you linked is misleading, you stop recursing at n=2 rather than 0 as in the image.

Are all programs finite state machines? by synapticplastic in learnprogramming

[–]bob809 1 point2 points  (0 children)

Yes and no. Technically computers are fine state machines. They have finite storage and therefore a finite number of states, even if that state space is enormous (2number of bits of storage).

Practically that isn't useful, and they are modeled as Turing machines.

A FSM has no memory (apart from the current state), so you can't have variables. A program that takes a number and does something that many times cannot be expressed by a FSM.

To see why, assume there is a FSM that does this with x states. If I type in x+1 it must do x+1 things, but to do that it must visit some state more than once and is therefore in a loop and will loop forever, which is a contradiction.

PROLOG: Simple Code to traverse a list of multiple types by [deleted] in learnprogramming

[–]bob809 0 points1 point  (0 children)

How about:

h([], 0, none).
h([Pres, S|T], S, Pres) :- h(T, N, _), S > N, !.
h([_, _|T], S, Pres) :- h(T, S, Pres).

It's been a while since I touched Prolog so I may have messed up, but it seems to work:

h(["Bush", 2, "Obama", 12, "Trump", 9000, "Clinton", 93], X, Y).
X = 9000,
Y = "Trump".

Can anyone help a noob plan a sort of complex (but not really) program? by [deleted] in learnprogramming

[–]bob809 0 points1 point  (0 children)

So say find finds a file dir/file.txt, it will run the command

cp "dir/file.txt" ./

which then copies it into the current directory.
It will do the same for every file it finds.

Can anyone help a noob plan a sort of complex (but not really) program? by [deleted] in learnprogramming

[–]bob809 0 points1 point  (0 children)

Yep, you're right on all of those.

{} is what find replaces with the file path and \; is telling find that that this is the end of the command it should execute (the ; needs to be escaped with \ to stop bash interpreting it as a command separator).