Hello all,
In my app, I have three models: Markets, Deals, and Users. Relationships are pretty straightforward:
class Market
has_many :users
has_many :deals
end
class User
belongs_to :market
end
class Deal
belongs_to :market
end
Now, in order to more easily query some of those relationships, the Market model has some metho...
I'm writing a small script to see if certain ports on certain devices are in use or are open. My code is:
for($c=1;$c<=16;$c++){
echo "<tr><td>Pod " . $c . "</td>";
for ($d=5000;$d<=5010;$d++){
$tmp=fsockopen("10.0.0." . $c,$d,$erstr, $errno, 1);
if($tmp){
echo "<td class='o'>OPEN</td>";
fclose($tmp);
}
e...
Hello
Can I use template to create several instantiations of some function, different only in some constant parameter? The number of alternatives for this parameter is fixed.
E.g.
I want not to rewrite (where upper is in 1..32 in powers of two)
funct(param, int upper)
{
some_loops(..)
some_heavy_code_fast_for_const_and_slow_f...
Hi,
I'm trying to write a query to get a courses information and the number of bookings and attendees. Each course can have many bookings and each booking can have many attendees.
We already have a working report, but it uses multiple queries to get the required information. One to get the courses, one to get the bookings, and one to g...
Running my site on IIS7 and looking to improve my Yslow rating. Working with asp.net.
I am able to cache static resources in the web.config but is it possible to the following also:
Set the etag on the resources eg. javascript, images, css files etc
Add expires header to the above static resources
Set gzipping on components
Previously...
If you've implemented the Hungarian Method exactly as given in Figure 11-2 of Combinatorial Optimization: Algorithms and Complexity, did you succeed without altering the pseudo-code in any [significant] way? To be specific, I'm referring to the corrected 1998 Dover edition, which is up-to-date with respect to the errata file dated Octobe...
Hi,
i want to test if current char current is not ',', '-', '.' or ' '
Is there a shorter expression for:
if((current != ' ') || (current != '.') || ...)
any ideas?
EDIT:
I am just allowed to use the methods nextChar and getChar. I have to loop through the chars.
import java.io.FileInputStream;
import java.io.IOException;
import j...
Following code works and deletes all calendar events from iPhone calendar database.
But events are deleting very slow: 2 events per second on iPhone 3GS.
So if you have 3000 events - then it's 25 minutes to erase them...
How would you optimize this code? Maybe I am doing something wrong? Thanks.
- (void)deleteAllCalendarEventsFromIPho...
How to optimize this?
SELECT e.attr_id, e.sku, a.value
FROM product_attr AS e, product_attr_text AS a
WHERE e.attr_id = a.attr_id
AND value
IN (
SELECT value
FROM product_attr_text
WHERE attribute_id = (
SELECT attribute_id
FROM eav_attr
WHERE attribute_code = 'similar_prod_id'
)
AND val...
I Want to optimize the following function using SIMD (SSE2 & such):
int64_t fun(int64_t N, int size, int* p)
{
int64_t sum = 0;
for(int i=1; i<size; i++)
sum += (N/i)*p[i];
return sum;
}
This seems like an eminently vectorizable task, except that the needed instructions just aren't there ...
We can assume that N i...
Looking at improving the performance of my jquery selectors. so any tips or articles as the best per formant jquery selectors? For example selecting the a div's id. Anywhere online I can provide html and compare the different selectors I can use to select the required element.
...
Hi guys, I am attempting to modify the selection algorithm to work with the following situation:
My imput is a list of numbers x1, x2, ... , xn (not necessarily ordered).
Each of these numbers has a weight "w". I call W the sum of all the weights.
If I provide a value X, which is greater than 0 but no larger than W, how can I find a ...
I code the game over at ninjawars.net, and have recently consolidated most of my (ugly) javascript code into a single object that gets re-used for the inner frame and the outer frame.
We were going to consolidate the same instance of jQuery as well (i.e. making it a Global so that it is accessible via $ everywhere, but is only 1 jQuery ...
Im trying to optimize my exercise application in VS2010.
Basically I have several sqrt, pow and memset in the core loop.
More specifically, this is what I do:
// in a cpp file ...
#include <cmath>
#pragma intrinsic(sqrt, pow, memset)
void Simulator::calculate()
{
for( int i=0; i<NUM; i++ )
{
...
float len = std::sqrt(lenSq...
Hi, I have these table structures and while it works, using EXPLAIN on certain SQL queries gives 'Using temporary; Using filesort' on one of the table. This might hamper performance once the table is populated with thousands of data. Below are the table structure and explanations of the system.
CREATE TABLE IF NOT EXISTS `jobapp` (
`i...
It seems like, for many javascript widgets, the authors have made a conscious effort to use tiny variable names. For example:
// Instead of...
this.mousePositions = new Array();
// they use...
this.mp = new Array();
My question is this: how important is this in terms of reducing overall javascript file request size? I'm working on rel...
Hello
When an Apache server supports gzip compression, how can from PHP send a CSS file to the client. Is this using .htaccess or with a library? If is a simple .htaccess line, do provide it!
Thanks a lot
...
I am having problems setting up gzip on an IIS7 server via the web.config. The following is the setup
<httpCompression minFileSizeForComp="0" doDiskSpaceLimiting="false"
staticCompressionDisableCpuUsage="98" staticCompressionEnableCpuUsage="95"
dynamicCompressionEnableCpuUsage="30" dynamicCompressionDisableCpuUsage="...
I have one JS-file that is merged and compressed from several separate files.
So when we start our app, there is only one http request for the JS-file which makes loading it really fast for all pages.
But, a lot of the code is jquery in document.ready(). It binds events and other code to elements on certain pages, but not all code is ne...