The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
15 views

How should I add user profiles and privacy to devise?

I have a rails 3 devise app has users with a profile and privacy settings. I currently have this working, but am concerned about efficiency and would love the advice of an experienced rails dev. I ...
2
votes
4answers
50 views

How to make this JavaScript code more practical?

I created code as practice.This changes the background color of the browser based on what you type into the text box. I couldn't figure how to do it any other way than using the setInterval() method ...
0
votes
1answer
34 views

How to speed up a function in R

I have the following instructions in R, which I'm using to change the values of variable data$theme according to the text inside data$paragraph, which contains long character strings: lines <- ...
0
votes
0answers
18 views

Efficient Mongodb loop - Ruby

I'm new to Mongo and Ruby and am looking for the most efficient to query the database. I need to grab the top 3 results for each of the 8 users. Currently I am looping through for each user and ...
7
votes
2answers
61 views

Is there a function like “ismember” but more efficient?

For example,A is the number set.b is elements. I want to test whether the number in b is the element of the set A. I know the matlab function "ismember" could do this ,but it's not fast enough when ...
1
vote
5answers
38 views

Is it better to have a smaller amount of code but less clear, or more code and more clear? [on hold]

I've been working on this project for quite some time and it has gotten to be about 2000 lines long. It was done in such a way that it just worked, but would be an absolute nightmare for someone to ...
1
vote
1answer
25 views

Python, SQLAlchemy, how to insert queries in an efficient way with only one commit instruction

I am working with SQLAlchemy and my insert function works correctly. However, i want and i need it to be efficient, therefore since i am inserting inside a "for loop", i would like to commit just once ...
1
vote
1answer
45 views

fortran: I have big local arrays, would it maybe be more efficient to make them global and allocate them beforehand?

I have this question. I noticed my fortran 90 program has many subroutines that allocate big matrices in some subroutine. These matrices are local and therefore only used in that subroutines. However, ...
0
votes
1answer
26 views

Count occurences in PHP Array

I'm playing around with opencart and trying to add a few new features to the filters functionality of the cart. I'm wondering how do I efficiently count the number of occurrences of a given value in ...
-1
votes
1answer
141 views

What's faster? (a+a vs 2*a and more) [closed]

In C/C++, I was wondering which is faster? int a; int b = a + a; // this int b = 2 * a; // or this? Also, is important the datatype? What about long? what about the number of times we add up? ...
-1
votes
2answers
23 views

nav button click change style efficiency [closed]

I'm still pretty new to javascript/jQuery but I dont think this is the best way to do this. Is it? function buttons(){ $('.notclicked').click(function(){ ...
-3
votes
3answers
63 views

Finding efficient Solution in Python

I'm working in a project and I have a function: def myMin(L): current = L[0] for x in L: if x < current: current == x return current It is very readable but not ...
1
vote
1answer
26 views

Ruby Mongo gem bulk insert of enumerable

I am using ruby 1.9.3 with the twitter and mongo gems. I have the following code working: Twitter.user_timeline("GSElevator", :count => 200, :exclude_replies => "true", :include_rts => ...
1
vote
3answers
26 views

Codeigniter tidying up my controllers

I've followed Codeigniter's configuration straight out of the manual - and just wondered if there was a simpler or more efficient way of coding my controllers... eg. class Home extends CI_Controller ...
3
votes
2answers
58 views

Inefficient Expansion Algorithm

So I am trying to write a program which takes a grid and a starting point on the grid, and expands the point outward, labeling each cell with how many expansions it took to reach that location. For ...
0
votes
0answers
50 views

What process in this program could I modularize by making it a function? [migrated]

Here is an exercise I completed today from Bjarne Stroustrup's Programming Principles and Practice in C++ book, any tips about coding style, simplification, or perhaps modularization by means of using ...
2
votes
5answers
56 views

Compact way to generate checkerboard pattern

I need to generate a checkerboard pattern for a game that I am creating. I have come up with the following (pseudo)code, but feel there must be a more compact way to do this. All suggestions welcome! ...
0
votes
0answers
48 views

How can I make my php script more efficient? [closed]

I have a script which gets emails via IMAP, checks for certain subject text, and displays date and subject. It also has an option to download all attachments when the string input matches the subject ...
3
votes
1answer
70 views

std::next_permutation Implementation Explanation seeming little inefficient?

I was curious how std:next_permutation was implemented so I extracted the the gnu libstdc++ 4.7 version and sanitized the identifiers and formatting to produce the following demo... #include ...
0
votes
0answers
24 views

SQL Multi Column Max for one result on a Join (Efficiency Request)

I am trying to connect all products in stock with the latest receipt information for each item. The issue is that I can have the exact same Date/Time on Multiple Receipts so I need the max DocNum as ...
0
votes
1answer
36 views

Openmp-C++ efficiency: an array of structures vs. several arrays

I am using c++ with openmp, and have a concern on the computational efficiency of the following two ways in organizing the data: (1) struct A { int n; double v; double f[3]; .... ...
2
votes
1answer
29 views

Filter Data In a Cleaner/More Efficient Way

I have a set of data with a bunch of columns. Something like the following (in reality my data has about half a million rows): big = [ 1 1 0.93 0.58; 1 2 0.40 0.34; 1 3 0.26 0.31; 1 4 ...
0
votes
1answer
58 views

Showing many images in a WPF view overheads too much memory

I am developing a WPF application and I need to show 7200 images in a window. Each image size is equals to 300x300. My code "*.xaml" is showed below: <ScrollViewer ...
3
votes
4answers
107 views

How to avoid using multiple “if then” for checking parameters?

I have some code that should do a simple thing : if the value of the parameter is -1 then I should change the value. else - do nothing I have a list of 20 parameters, but I wanted to know if there ...
0
votes
1answer
21 views

Efficient ay to process arrays

Let's say I have the following arrays. Array 1: List of cities (might have some entries that are same as array 2) Array 2: List of cities I want to output the following listS: List of cities only ...
2
votes
7answers
120 views

What is the most efficient way of toggling a DOM elements value based on the state of another element?

Imagine we have a text field that executes the code below on each keydown event: if( $('#my_input').val() == '' ) $('#my_span').html('my input is blank'); else $('#my_span').html('My input is not ...
0
votes
3answers
76 views

Is '===' more efficient than '!=='?

Am i correct in saying that this: if (y === x) { //statement a } else { //statement b } is more efficient than this: if (y !== x) { //statement b } else { //statement a } Note: ...
0
votes
1answer
33 views

Improve efficiency of modules

I am running the loop in this method for around 1 million times but it is taking a lot of time maybe due O(n^2) , so is there any way to improve these two modules :- def genIndexList(length,ID): ...
1
vote
1answer
45 views

Python - Many methods with small differences

I have several methods that vary little in construction. They are for setting the (linux-like) permissions on a given item (field_name). The variables oview_perms, gview_perms, aview_perms represent ...
0
votes
0answers
37 views

Can I write this octave code more efficient?

I want to run this code more efficiently. Can I get rid of this for loop? Thanks... N = 2^15; ftx = fft([1:N]); k=[1:N]; rpmt = repmat(ftx,[2,1]); for m = [1:N] retval(m) = ...
2
votes
2answers
225 views

draw over 4K polylines in android google maps

I'm developing right now an application for Android devices. The main functionality is to draw polylines on map to show what is the traffic in the city on each street. Unfortunately when I draw around ...
1
vote
0answers
111 views

Compare-Object Powershell performance and Operation VS Loop

I was looking at this question where the OP wanted to know how to compare items in two arrays without looping through each array. The command given was: $array3 = @(Compare-Object $array1 $array2 | ...
0
votes
0answers
31 views

How exactly does java animation work?

Forgive me for asking a rather amateur question, but through some research I've met a challenging road block in progress. I looked into it on the site but I've been pretty unsuccessful in finding ...
1
vote
5answers
105 views

Counters that flip signs in java

Ok so im trying to make a program and i need to have the counter start at -3 and go down by 2, but every other number has to be a positive: for example: -3, 5, -7, 9, -11, 13, -15, 17, -19,... any ...
1
vote
3answers
81 views

C# with Database code simplication

I am working on a project centered around an Oracle database (though honestly I don't expect that to matter) and I find myself have a fair amount of duplicate code, specifically exceptions. The best ...
-4
votes
1answer
62 views

Need help reducing triple for loop to increase efficiency

for (int i = 0; i < 3; ++i) { for (int k = 0; k < 7; ++k) { for (int h = i; h < 4 + i; ++h) { result = state.getAt(k, h); if (result == 1) { ...
1
vote
1answer
30 views

Looking for more efficient software zoom

I am using a C#, Winforms application with the Aforge library to pull video from a USB camera and manipulate that video. I am doing it by using the new frame event handler and posting that image into ...
0
votes
2answers
121 views

Total number of ways to write a positive integer as the sum of powers of 2 in efficient time

I've been looking at Number of ways to write n as a sum of powers of 2 and it works just fine, but I was wondering how to improve the run time efficiency of that algorithm. It fails to compute ...
0
votes
4answers
83 views

Is it inefficient to reference a hashmap in another class multiple times?

Class A Class A { public HashMap <Integer,Double> myHashMap; public A(){ myHashMap = new HashMap() } } class B Class B { private A anInstanceOfA; public B(A a) { ...
0
votes
3answers
59 views

How to I make this PHP function more efficient?

I want to find out a more efficient way of going about this function: <?php function zipError($title, $desc) { echo '<style type="text/css">'; echo 'body { ...
0
votes
0answers
93 views

GetJSON Javascript Array Efficiency

Probably a simple question, but I'm unsure how to do this. I have a JSON file which looks like this, obviously shortened but you get the idea: { "datapoints": [ { "lat": ...
0
votes
2answers
142 views

C++: most efficient algorithm to find all consecutive subsequences of given length in a sequence

I'm looking for an efficient algorithm to extract all subsequences of a given length from a given sequence over a fixed alphabet (lets say its 0,1,2,3) and also which sub sequences were read and which ...
1
vote
2answers
96 views

Delete Duplicate Records with Same Values

I have a TSQL statement that is taking several hours to run. I'm sure I need to look into the import process to avoid duplicates being inserted but for the time being I'd just like to remove all ...
4
votes
8answers
81 views

Java - looking for more efficient way to code class methods

I am creating a program that automates creation of player characters. Below is my PlayerCharacter class. I have noticed that I repeat many operations on different variables. public class ...
0
votes
0answers
26 views

Best way to loop through only borders of a cube? (marching cubes)

Marching cubes presents us with chunks of 16x16x16 cubes and similar, and it is very useful to be able to loop through just the borders of the chunks to speed up various routines. Take a 4x4x4 cube, ...
-3
votes
1answer
60 views

Improve R script efficency

I am trying to match two very big data (nsar & crsp) sets. My code works quite well but needs a lot of time. My procedure works the following way: Try match via ticker (thereby controlling that ...
-1
votes
3answers
349 views

Optimized Permutation Code in Java

This is a code that I got from internet. import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; ...
3
votes
3answers
100 views

Finding Matching Strings Algorithm

I have very long 5 strings(the number of strings may change).There is no fixed format for these strings. I will provide a number which will indicate the length of the substring. I want to find the ...
0
votes
1answer
72 views

Pulling 50 RSS feeds and checking uniqueness of posts against database [Efficiency Advice]

I want to pull several RSS feeds into a database as efficiently as possible. My site will scrape 50 RSS feeds every 4 hours - I only want to add unique posts to the database. I am a bit stuck on how ...
1
vote
2answers
151 views

Efficiency with nested for each loop through arrayLists of strings

having a problem. Efficiency. I know very little about efficiency in coding, but I'm learning. Searching through these arraylists of strings for item1 and when found adding item2 to a new arrayList. ...

1 2 3 4 5 6