Community Member
Member Avatar
Featured invisal 381 Replied To a Post in Recently Active (Team)
Topic by happygeek in DaniWeb Community Feedback
Would it be clearer to use this SQL instead?



UPDATE members INNER JOIN articles_read
ON members.member_id = articles_read.member_id AND
members.last_visit_timestamp < articles_read.timestamp
SET members.last_visit_timestamp = articles_read.timestamp;

UPDATE members INNER JOIN forums_read
ON members.member_id = forums_read.member_id AND
members.last_visit_timestamp < forums_read.timestamp
SET members.last_visit_timestamp = forums_read.timestamp; Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Seamlessly rerender website as $_GET changes
Topic by Aeonix in Web Development
I think you might interest in [SPFJS](https://github.com/youtube/spfjs), that's used by Youtube. It is still using Javascript. Reply by invisal
Member Avatar
invisal 381 Replied To a Post in The Cyberg Project
Topic by Tomas_3 in Software Development
What a scary project you are aimming? Anyway, if you want to build a toy OS, you can try [Cosmos](https://github.com/CosmosOS/Cosmos). Cosmos is like a OS lego. Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Generating a triangular random
Topic by JamesCherrill in Programming
Let examine how good is square random number as random number. The easiest and simplest way to do so would be using [chi-squared test](https://en.wikipedia.org/wiki/Chi-squared_test). First, to calculate the chi-squared test, we need to know the probability distribution of our algorithm. Let `rand(n)` to be function that random between 0 to … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Generating a triangular random
Topic by JamesCherrill in Programming
There is another way which is even simpler than my last approach. Since random.random() generates number between 0 to 1. If we square it, it will getting smaller. Hence, the lower value will have more chance.

def rand2(n):
r = random.random()
r = r * r
return round(r * n) … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Generating a triangular random
Topic by JamesCherrill in Programming
I believe that computer can quickly calculate square root. Just using Taylor Series or Newton Raphson. These two method is cheap if you don't want too accurate result of the square root. I heard most of GPU has a built-in inverse square root (which can be done in single instruction). Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Generating a triangular random
Topic by JamesCherrill in Programming
Your probability doesn't seem to be correct. Let rework it a bit. We want to random from 0 to n. Let `a` be the value between 0 to n. The probability of `P(a) = 2 * (a + 1) / (n + 1)(n + 2)`. This way, the sum of … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in how do that ?
Topic by hadisur_rahman in Computer Science
177 - 77 = 100 Reply by invisal
Member Avatar
Topic by whaleflipper in Programming
> Suppose a loan has a face value of $1000, the interest rate is 15%, and the duration is 18 months. The interest is computed by multiplying the face value of $1000 by 0.15 yielding $150.0. That figure is then multiplied by the loan period of 1.5 years to yield … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Random Numbers
Topic by Jamie_10 in Software Development
You don't even need condition or mod operator. `odd += number & 1;` even less CO2 emissions. The world is greener. Reply by invisal
Member Avatar
invisal 381 Replied To a Post in logical operators applied to a double
Topic by Centorpe in Mobile Development
I have to agree with rubberman, this is ugly code. Besides, you need to use `==` instead of `=` here. `=` is assignment and `==` is used for comparison.

When work with float-point, we don't usually use `==` as well because float-point cannot represent certain number. Usually, when compare float … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Fastest Way to Find Prime
Topic by JOSheaIV in Software Development
> However, seeing that there is a chance it can fail, I will need to continue to research ways around this.

To be clear, there is no fast way to determine if a very large random number is a prime. Let me quote from reputable source.

* *The wrong way … Reply by invisal
Member Avatar
Topic by Stuugie in Community Center
To make you feel better. You should read [Why Can't Programmers.. Program?](http://blog.codinghorror.com/why-cant-programmers-program/). It shows that a lot of people is worser than you. The most important skill is self-learning. Since, you are here helping and learning, you are better than most people already.

In short, you are not under qualified. … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in AI - Artificial Intelligence
Topic by Stefan_1 in Computer Science
> Thats because we are humans we have a perspective what is good and what is bad for us, how the computer will know what is punishment for him and how much it will care about it

It is simple.

- In my second example about AI for playing Tac … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in AI - Artificial Intelligence
Topic by Stefan_1 in Computer Science
> what programming language they are using

You can use any programming language. AI is no different from other program.

> when learning it self on something new for him and for humans too

AI is trying to replicate how human learn. Human learn based on obversation. Here is how … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in My apologies
Topic by Dani in DaniWeb Community Feedback
> web hosting costs are over $5000/mo

Are you sure you spend $5000 per month for hosting? I am running a website with as much as traffic as Daniweb (if not more) and it costs around $300 per month.

* We are storing our images in DreamObjects. Have over 3 … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Fastest Way to Find Prime
Topic by JOSheaIV in Software Development
You can use *Fermat Test*. It has high probability of getting the right answer. We know that if a^(n-1) mod n != 1, then n must be a composite number.


def ModPowerRecursive(a, p, m):
if p == 0:
return 1
elif p % 2 == 0:
return (ModPowerRecursive(a, p >> … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Fastest Way to Find Prime
Topic by JOSheaIV in Software Development
How large is your prime number? The fastest way (if not the fastest) to determine if *N* is a prime number is to have a pre-calculated of all prime number below *sqrt(N)*. Then, it takes only O(*sqrt(N)/ln(sqrt(N))*) to determine the prime by mod with all prime below *sqrt(N)*.

For example, … Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in My apologies
Topic by Dani in DaniWeb Community Feedback
In my company, we are developing our own lightweight framework. Far lightweight than CodeIgniter but more modern than CodeIgniter (our framework size in total is around 20kb). The framework learning curve is at most 2 hours to 3 hours which is great because the less feature the framework, the less … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in Birthday Paradox
Topic by kayleigh0411 in Software Development
Not entirely suprirsed that you got this result. You skip the loop as soon as found a collision

if(birthdays.contains(randomBirthday))
{
collisionCount++;
break; // break from the test as soon as you found the collision
}

and to be honest, your logic is a mess. Even after you fix this bug, … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in Assigning values to list of strings
Topic by bryann in Software Development
You can use dictionary to simplify your code a bit

dict = {
"t": 1, "f": 1, "c": 1,
"b": 2, "h": 2, "y": 2,
"q": 3, "w": 3, "z": 3
}

value = 0
word1 = input("Please enter a word:")

for letter in word1:
value += dict.get(letter, 0)

print(value) … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in PHP 7 is comming
Topic by vikasmca2k11 in Web Development
php
It is not easy to kill a language with such a big community and large code base such as PHP. Because with large code base, there is large demand for PHP programmer and with large demand, there come the large supply.

PHP is not a bad language. It is easy … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in Sorting 2 dynamic stacks with quicksort
Topic by Ivan_9 in Software Development
> @Ivan_9. Quicksort and bsearch are two parts of the same whole. Quicksort uses bsearch algorithms to determine where to put the next element in the array.

@rubberman
To be clear, QuickSort does not use binary search algorithm to determine where to put the next element in the array. It … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in why linux
Topic by kombi-tamiri in Linux and Unix
I work on both Windows server and Ubuntu server. First of all, both of them are secure and reliable. I ran a website with more than 15 million pageview per month on a single Windows server using IIS 7 and PHP via FastCGI. It is fast and stable. No downtime. … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in Sorting 2 dynamic stacks with quicksort
Topic by Ivan_9 in Software Development
I don't get this question. Do you want to do a QuickSort on Linked List or Stack? Because based on your example, it is a linked list. Although you can use linked list to implement stack, but you must obey the stack properly. In Stack, you can either do pop() … Reply by invisal
Member Avatar
invisal 381 Replied To a Post in Content Delivery Network
Topic by Piers Rollins in Search Engine Strategies
You can use [Cloudflare](https://www.cloudflare.com/). It is free and easy to deploy. Just let it manage your DNS and it will act as a wall between your website server and visitors. Visitors will access to Cloudflare nearest server and Cloudflare will fetch the content of your website and cache (static content). Reply by invisal
Member Avatar
Featured invisal 381 Replied To a Post in Anyone Else Seeing DaniWeb Activity Dropping?
Topic by JOSheaIV in DaniWeb Community Feedback
How come this discuss turn into a flame war. First of all, there is no different between the sub-forum and tag system based. A single tag equals to a sub-forum. Tag system allows a single question to belong to to multiple sub-forum. Therefore, tag system provides more flexiblity. Many energy … Reply by invisal
Member Avatar
Topic by Minimalist in DaniWeb Community Feedback
I agree with this one. It is annoying to scroll down and check the latest reply. Reply by invisal
Member Avatar
Topic by studyemail in Software Development
A year ago, I also wrote an article about [using only bits to representing the TicTacToe](http://programmers.stackexchange.com/questions/263308/determining-the-winning-condition-for-tic-tac-toe/263489#263489). It might be irrelevant to this question, but I think it is nice to share here for those who interests.

**Using Bits for TicTacToe**

Using bits to represent a Tic-Tac-Toe board is perfectly fine … Reply by invisal
Member Avatar
Topic by studyemail in Software Development
Or you can use a single 1d array for TicTacToe.

int rows[] =
{ 0, 0, 0,
0, 0, 0,
0, 0, 0 }

0 means empty. 1 means player 1, and 2 means player 2.

For example, if a player 2 want to make move on row number 2 … Reply by invisal