Hi,
I've got two files,file a around 5mb, and file b around 66 mb. I need to find out if there's any occurnaces of the lines in file a, inside file b, and if so write them to file c.
This is the way I'm currently handling it:
ini_set("memory_limit","1000M");
set_time_limit(0);
$small_list=file("a.csv");
$big_list=file_get_contents("b.c...
Let's say we have a value type like this, where the fields are readonly and initialized during construction:
public struct SomeValue
{
private readonly Int32 field1;
private readonly Int32 field2;
...
}
Also, let's say we have a helper class that lets us implement GetHashCode() for composite types in a reusable manner:
p...
I had like to optimize the following Matlab code :
x = linspace(-5,5,100);
y = linspace(-5,5,100);
z = linspace(-5,5,100);
[xp,yp,zp] = meshgrid(x,y,z);
norm = sqrt(xp.^2+yp.^2+zp.^2);
I improved it a little using realsqrt :
norm_0 = sqrt(xp.^2+yp.^2+zp.^2) 10.106 s 37.0%
norm_1 = realsqrt(xp.^2+yp.^2+zp.^2) 1...
Can you think of some way to optimize this piece of code? It's meant to execute in an ARMv7 processor (Iphone 3GS):
4.0% inline float BoxIntegral(IplImage *img, int row, int col, int rows, int cols)
{
0.7% float *data = (float *) img->imageData;
1.4% int step = img->widthStep/sizeof(float);
// The subtraction by o...
The JVM (especially the HotSpot VM) is famous for having a huge number of optimizations it can apply at runtime.
Is there a way to look at a certain piece of code and see what the JVM has actually done to it?
...
I am building an inventory tracking system for internal use at my company. I am working on the database structure and want to get some feedback on which design is better*.
I need a recursive(i might be using this term wrong...) system where a part could be made up of zero or more parts. I though of two ways to do this but am not sure wh...
SELECT
b.categoryid,
SUM(viewcount) AS cnt,
categoryname
FROM
bookvisit AS bv
INNER JOIN book AS b ON b.isbn = bv.isbn
LEFT JOIN category AS c ON b.categoryid = c.categoryid
WHERE
b.categoryid IS NOT NULL AND
b.categoryid <> 0
GROUP BY
b.categoryid
ORDER BY
cnt DESC,
bv.isbn
LIMIT 0, 4
I ha...
I'm developing a screencasting utility in C++.
It basically captures desktop frames and creates an AVI file. The algorithm is as follows:
Create a thread: this->m_hThread=CreateThread(NULL,0,thScreenCapture,this,0,NULL);
Capture desktop in thScreenCapture n times per second (like 5 fps).
obj->Capture();
In Capture(), append the bitm...
What is a good way to split a numpy array randomly into training and testing / validation dataset? Something similar to the cvpartition or crossvalind functions in Matlab.
...
func()
{
fun1();
fun2();
fun3();
fun4();
fun5();
fun6();
..
..
..
..
fun99();
fun100();
}
by using function pointers in C program? I need to call this program repeatedly in my program.
...
Yesterday I read something abouth application optimization and how a programmer should find the most used parts of the program and by profiling and modifying them getting the most benefit (when looking at the time/work invested vs. memory/speed gains). Now, I've run the Eclipse profiler, got VisualVM but I don't how to use this data prop...
Is there a way to detect if a site is on a Content Delivery Network and if yes, can we tell which service are they using?
...
Is there a fast way to multiply values of a float array in C++, to optimize this function (where count is a multiple of 4):
void multiply(float* values, float factor, int count)
{
for(int i=0; i < count; i++)
{
*value *= factor;
value++;
}
}
A solution must work on Mac OS X and Windows, Intel and non-Intel....
Is there a way I can run piece of javascript code ONCE without the use of boolean flag variables to know that it already ran?
Specifically not something like:
var alreadyRan = false;
function runOnce() {
if (alreadyRan) {
return;
}
alreadyRan = true;
/* do stuff here */
}
I'm going to have a lot of these types of funct...
I am a bit new to using blitting for graphics. But I have worked up a few demos myself, and I have been reading a lot of information on the methods used.
One common theme I have been seeing though is that all of them brute force rendering; drawing the farthest back object first and stepping through all other objects. even drawing object...
Hi, all.
I have a web service (JAX-RS/Spring) that generates SQL queries which run against a temp table in Oracle. The data is then archived to another table (through 3 MERGE statements). The execution of each "job" (querying and merging) is done in the background through a JMS broker (ActiveMQ). The sequence of operations of each job i...
I needed to write a weighted version of random.choice (each element in the list has a different probability for being selected). This is what I came up with:
def weightedChoice(choices):
"""Like random.choice, but each element can have a different chance of
being selected.
choices can be any iterable containing iterables w...
I am creating RPG type game. I pull out player's information in every page loaded from two tables with JOIN (it is information about member: age, name, his all game's stats and etc) and sometimes this information is required for me, sometimes not at all. Two tables consists of ~60-70 rows. Here is an example:
$query = mysql_query("SELEC...
What would be the best way to optimize this code below to make it more efficient while applying the 'best practices'. This is just a simple school project and it works, I've tested it. But I just feel like there's a better and more efficient way to write this method. What do you think?
I have an array that
is pre-populated with a bunch...
I have a web service using lighttpd and fastCGI (using TCP) where lighttpd causes a processor bottleneck. How can I optimize the performance of lighttpd and fastCGI?
Best Regards
...