I need to look up a value in a "table" where a table can be an array or whatever really.
On paper it looks like this (reduced and generalized):
Size 500 750 1000 1250 1500 (speed)
--------------------------------------------
6x5 0.1 0.5 0.55 0.58 0.8
6x4 0.01 0.1 0.4 0.5 0.9
8x5 ...
I am building an application where I am trying to allow users to submit a list of company and date pairs and find out whether or not there was a news event on that date. The news events are stored in a dictionary with a company identifier and a date as a key.
newsDict('identifier','MM/DD/YYYY')=[list of news events for that date]
...
So I was working on a way to lazily generate primes, and I came up with these three definitions, which all work in an equivalent way - just checking whether each new integer
has a factor among all the preceding primes:
primes1 :: [Integer]
primes1 = mkPrimes id [2..]
where mkPrimes f (x:xs) =
if f (const True) x
...
I have a MySQL 5.1 InnoDB table (customers) with the following structure:
int record_id (PRIMARY KEY)
int user_id (ALLOW NULL)
varchar[11] postcode (ALLOW NULL)
varchar[30] region (ALLOW NULL)
..
..
..
There are roughly 7 million rows in the table. Currently, the table is being queried like this:
SELECT * FROM custom...
I have 2063 locations stored in a mysql table. In one of my processes I need to exclude certain results based on how far away they are from a given point of origin. The problem is, I will need to filter a couple of hundred, maybe a couple of thousand results at a time.
So what would be the best way to do the distance math. Should I do i...
The below MSSQL2005 query is very slow. I feel like their ought to be a way to speed it up, but am unsure how. Note that I editted the inner join to use select statements to make it more obvious (to people reading this question) what is going on, though this has no impact on speed (probably the Execution plan is the same either way). ...
I have a script that loops through an array of IP's and checks the clients IP against them.
//filter IP address list
$ip = array();
$ip[] = '10.10.5.*';
$ip[] = '234.119.260.65';
$ip[] = '234.119.254.2';
function testIP($ip){
//testing that correct IP address used
for($i=0, $cnt=count($ip); $i<$cnt; $i++) {
$ipregex = preg_replace...
Hi,
Is there any evidence to suggest that by manually picking which processor to run a thread on you can improve system performance?
For example say you dedicated the thread that does the most work to one core and all other "helper" threads to a second.
...
How would you rate by numbers the efficiency of a certain design?
What will be your variables?
I can think of:
Coupling
Design Patterns use
Language idioms use.
Scalability.
High-viability.
Code Reuse.
Flexibility.
Robustness to errors.
Testability.
Design implications on resource use and memory.
Portability.
Usage of the correct pro...
In tables where you need only 1 column as the key, and values in that column can be integers, when you shouldn't use an identity field?
To the contrary, in the same table and column, when would you generate manually its values and you wouldn't use an autogenerated value for each record?
I guess that it would be the case when there are ...
There are a lot of books out there for new programmers getting into Python. However, are there any books for people who are experienced both in programming and to some degree in Python that introduces advanced topics, subtleties, gotchas, and best practices in Python?
I'm thinking in terms of something like Effective C++ or Effective Ja...
I'm working on a large project, I won't bother to summarize it here, but this section of the project is to take a very large document of text (minimum of around 50,000 words (not unique)), and output each unique word in order of most used to least used (probably top three will be "a" "an" and "the").
My question is of course, what would...
Firstly, please don't move to serverfault. It is indeed a programming question :-)
We are developing occasionally connected applications. These applications reside on laptop and handhelds. In my case, the application runs on a small servlet container (like jetty).
The requirement is that if the system is idle, the application should su...
I'm creating a game in C++ (speaking of which, does the code I use matter?), which coudl be loosely described as a board game, and I'm wondering which of these two "check if character is out of bounds" functions is more efficient:
ONE:
int main()
{
//display board
//get player input
//move player
//if player is out of b...
I am creating a quiz game and I can't figure out the best way to implement UIButtons that disappear one by one at 3 second intervals. I can get the first UIButton to disappear after 3 seconds, but the subsequent UIButtons take considerably longer.
I believe the problem is that my code becomes more inefficient with each UIButton I make ...
This first script gets called several times for each user via an AJAX request. It calls another script on a different server to get the last line of a text file. It works fine, but I think there is a lot of room for improvement but I am not a very good PHP coder, so I am hoping with the help of the community I can optimize this for speed...
I'm building a PHP/MySQL app where users can log in and search for media assets. They can also save searches and create lightboxes (collections of assets). Finally, they can create user groups.
Does it make more sense to query all at once, at log in, for the id's for their saved searches, lightboxes, and groups and save those in sessi...
A few minutes ago, I asked whether it was better to perform many queries at once at log in and save the data in sessions, or to query as needed. I was surprised by the answer, (to query as needed). Are there other good rules of thumb to follow when building PHP/MySQL multi-user apps that speed up performance?
I'm looking for specific w...
How is it possible to implement an efficient large Sqlite db search (more than 90000 entries)?
I'm using Python and SQLObject ORM:
import re
...
def search1():
cr = re.compile(ur'foo')
for item in Item.select():
if cr.search(item.name) or cr.search(item.skim):
print item.name
T...
In trying to resolve Facebook's Puzzle "Hoppity Hop", http://www.facebook.com/careers/puzzles.php?puzzle_id=7, I'm reading one integer only from a file. I'm wondering if this is the most efficient mechanism to do this?
private static int readSoleInteger(String path) throws IOException {
BufferedReader buffer = null;
int integer = 0;
...