Search Results

Search found 441 results on 18 pages for 'duplication'.

Page 3/18 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to remove duplication from RSpec

    - by Asa
    context "answer is correct" do before(:each) do @answer = stub_model(Answer, :correct => true).as_new_record assigns[:answer] = @answer render "answers/summarize" end it "should display flashcard context properly" do response.should contain("Quiz") end it "should summarize results" do response.should contain("is correct") end end context "answer is incorrect" do before(:each) do @answer = stub_model(Answer, :correct => false).as_new_record assigns[:answer] = @answer render "answers/summarize" end it "should display flashcard context properly" do response.should contain("Quiz") end it "should summarize results" do response.should contain("is incorrect") end end How do I avoid repeating the following block within both of the above contexts? it "should display flashcard context properly" do response.should contain("Quiz") end

    Read the article

  • Javascript source code analysis ( specifically duplication checking )

    - by David
    Partial duplicate of this Notes: I already use JSLint extensively via a tool I wrote that scans in intervals my current project directory for recently updated/created .js files. It's drastically improved productivity for me and I doubt there is anything as good as JSLint for the price (it's free). That said, is there any analysis tool out there that can find repetitive or near-duplicate code blocks, the goal being to make it easier to find opportunities to consolidate large files or small/medium sized projects?

    Read the article

  • Where should you put 3rd party .NET dlls when using git submodules to avoid duplication

    - by Tim Abell
    I have two .NET library projects in Visual Studio 2008 that both make use of the MySql Connector for .NET (MySql.Data.dll). These libraries are then in turn both used by a .NET command line application which also uses the Connector. The library projects are pulled in to the application's solution as git submodules and referenced by project in Visual Studio. I'm looking for the most effective strategy for storing and referencing the MySql Connector library. I have tried having the MySql.Data.dll checked in to all three projects (in their root folder), this was problematic when one project changed to a newer version of the connector dll. Although each project had its own version of the dll, only one was packaged into the resultant application leading to an API mismatch which was hard to pin down. This has put me off this approach. I have tried having the command line application reference the connector dll that is held in a submodule, however this only removes the possibility of version mismatches when there is only one submodule rather than two as in this case. I am contemplating putting the dll in the global assembly cache (GAC) of all machines that need to build or use the application, but I'm wary of not having all dependencies for an application available in source control.

    Read the article

  • Duplication of menu items with ViewPager and Fragments

    - by Julian
    I'm building an Android Application (minimum SDK Level 10, Gingerbread 2.3.3) with some Fragments in a ViewPager. I'm using ActionBarSherlock to create an ActionBar and android-viewpagertabs to add tabs to the ViewPager just like in the Market client. I have one global menu item that I want to be shown on every tab/fragment. On the first of the three tabs I want to have two additional menu items. But now two strange things happen: First if I start the app, everything seems to be fine, I can see all three menu items on the first page and only one item if i swipe to the second and third tab. But if I swipe back to the second tab from the third one, I can see all three items again which shouldn't happen. If I swipe back to the first and then again to the second tab, everything is fine again. The other strange thing is that every time I rotate the device, the menu items from the fragment are added again, even though they are already in the menu. Code of the FragmentActivity that displays the ViewPager and its tabs: public class MainActivity extends FragmentActivity { public static final String TAG = "MainActivity"; private ActionBar actionBar; private Adapter adapter; private ViewPager viewPager; private ViewPagerTabs tabs; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.volksempfaenger); actionBar = getSupportActionBar(); adapter = new Adapter(getSupportFragmentManager()); adapter.addFragment(getString(R.string.title_tab_subscriptions), SubscriptionGridFragment.class); // adding more fragments here viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(adapter); tabs = (ViewPagerTabs) findViewById(R.id.tabs); tabs.setViewPager(viewPager); } public static class Adapter extends FragmentPagerAdapter implements ViewPagerTabProvider { private FragmentManager fragmentManager; private ArrayList<Class<? extends Fragment>> fragments; private ArrayList<String> titles; public Adapter(FragmentManager fm) { super(fm); fragmentManager = fm; fragments = new ArrayList<Class<? extends Fragment>>(); titles = new ArrayList<String>(); } public void addFragment(String title, Class<? extends Fragment> fragment) { titles.add(title); fragments.add(fragment); } @Override public int getCount() { return fragments.size(); } public String getTitle(int position) { return titles.get(position); } @Override public Fragment getItem(int position) { try { return fragments.get(position).newInstance(); } catch (InstantiationException e) { Log.wtf(TAG, e); } catch (IllegalAccessException e) { Log.wtf(TAG, e); } return null; } @Override public Object instantiateItem(View container, int position) { FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); Fragment f = getItem(position); fragmentTransaction.add(container.getId(), f); fragmentTransaction.commit(); return f; } } @Override public boolean onCreateOptionsMenu(Menu menu) { BaseActivity.addGlobalMenu(this, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { return BaseActivity.handleGlobalMenu(this, item); } } Code of the fragment that shall have its own menu items: public class SubscriptionGridFragment extends Fragment { private GridView subscriptionList; private SubscriptionListAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); } // ... @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.subscription_list, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // ... } }

    Read the article

  • Ado.net ExecuteReader giving duplication while binding with datagrid

    - by Irvin Dua
    I am using below mentioned Ado.net function and resultset bind with grid view, however I am getting the duplicate rows in the resultset. Please help me out. Thanks Private _products As New List(Of Product) Public Property Products As List(Of BusinessObjects.Product) Get Return _products End Get Set(ByVal value As List(Of BusinessObjects.Product)) _products = value End Set End Property Public Function GetProductDetails() As List(Of Product) Dim product As New BusinessObjects.Product Using connection As New SqlConnection connection.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString connection.Open() Using Command As New SqlCommand("select * from T_product", connection) Dim rdr As SqlDataReader rdr = Command.ExecuteReader While rdr.Read() product.ProductID = rdr("ProductID") product.ProductName = rdr("ProductName") Products.Add(product) End While GridView1.DataSource = Products GridView1.DataBind() End Using End Using Return Products End Function

    Read the article

  • Avoiding duplication in JavaDoc comments

    - by TERACytE
    I am writing a class where the same xml is used between some methods. e.g. /** * Sample Response: * <xmp> * <myXML> * <stuff> data </stuff> * </myXML> * </xmp> */ CommonXML Method1(); /** * Sample Submission: * <xmp> * <myXML> * <stuff> data </stuff> * </myXML> * </xmp> */ void Method2(CommonXML xml); I would like to write my documentation so that if the xml changes I have one resource to modify, rather than updating all of the JavaDoc for the affected methods. Does anyone know how to accomplish this?

    Read the article

  • Zend framework - duplication in translated url

    - by tomasr
    I have these URLs cz/kontroler/akce en/controller/action Is used transatable route and works it like charm. But problem is, that when you will write cz/controller/akce it works as well. In generally when you have cz/something-in-czech en/something-in-english which route to someController, will be works still cz/some en/some because it is really name of controller. How solve this duplicity content issue?

    Read the article

  • concatenate multi values in one record without duplication

    - by mikehjun
    I have a dbf table like below which is the result of one to many join from two tables. I want to have unique zone values from one Taxlot id field. table name: input table tid ----- zone 1 ------ A 1 ------ A 1 ------ B 1 ------ C 2 ------ D 2 ------ E 3 ------ C Desirable output table table name: input table tid ----- zone 1 ------ A, B, C 2 ------ D, E 3 ------ C I got some help but couldn't make it to work. inputTbl = r"C:\temp\input.dbf" taxIdZoningDict = {} searchRows = gp.searchcursor(inputTbl) searchRow = searchRows.next() while searchRow: if searchRow.TID in taxIdZoningDict: taxIdZoningDict[searchRow.TID].add(searchRow.ZONE) else: taxIdZoningDict[searchRow.TID] = set() #a set prevents dulpicates! taxIdZoningDict[searchRow.TID].add(searchRow.ZONE) searchRow = searchRows.next() outputTbl = r"C:\temp\output.dbf" gp.CreateTable_management(r"C:\temp", "output.dbf") gp.AddField_management(outputTbl, "TID", "LONG") gp.AddField_management(outputTbl, "ZONES", "TEXT", "", "", "20") tidList = taxIdZoningDict.keys() tidList.sort() #sorts in ascending order insertRows = gp.insertcursor(outputTbl) for tid in tidList: concatString = "" for zone in taxIdZoningDict[tid] concatString = concatString + zone + "," insertRow = insertRows.newrow() insertRow.TID = tid insertRow.ZONES = concatString[:-1] insertRows.insertrow(insertRow) del insertRow del insertRows

    Read the article

  • Avoiding duplication in setting properties on the task in Rake tasks

    - by Stray
    I have a bunch of rake building tasks. They each have unique input / output properties, but the majority of the properties I set on the tasks are the same each time. Currently I'm doing that via simple repetition like this: task :buildThisModule => "bin/modules/thisModule.swf" mxmlc "bin/modules/thisModule.swf" do |t| t.input = "src/project/modules/ThisModule.as" t.prop1 = value1 t.prop2 = value2 ... (And many more property=value sets that are the same in each task) end task :buildThatModule => "bin/modules/thatModule.swf" mxmlc "bin/modules/thatModule.swf" do |t| t.input = "src/project/modules/ThatModule.as" t.prop1 = value1 t.prop2 = value2 ... (And many more property=value sets that are the same in each task) end In my usual programming headspace I'd expect to be able to break out the population of the recurring task properties to a re-usable function. Is there a rake analogy for this? Some way I can have a single function where the shared properties are set on any task? Something equivalent to: task :buildThisModule => "bin/modules/thisModule.swf" mxmlc "bin/modules/thisModule.swf" do |t| addCommonTaskParameters(t) t.input = "src/project/modules/ThisModule.as" end task :buildThatModule => "bin/modules/thatModule.swf" mxmlc "bin/modules/thatModule.swf" do |t| addCommonTaskParameters(t) t.input = "src/project/modules/ThatModule.as" end Thanks.

    Read the article

  • Faster s3 bucket duplication

    - by Sean McCleary
    I have been trying to find a better command line tool for duplicating buckets than s3cmd. s3cmd can duplicate buckets without having to download and upload each file. The command I normally run to duplicate buckets using s3cmd is: s3cmd cp -r --acl-public s3://bucket1 s3://bucket2 This works, but it is very slow as copies each file via the API one at a time. If s3cmd could run in parallel mode, I'd be very happy. Are there other options available as a command line tools or code that people use to duplicate buckets that are faster than s3cmd?

    Read the article

  • MySQL - Exclude rows from Select based on duplication of two columns

    - by Carson C.
    I am attempting to narrow results of an existing complex query based on conditional matches on multiple columns within the returned data set. I'll attempt to simplify the data as much as possible here. Assume that the following table structure represents the data that my existing complex query has already selected (here ordered by date): +----+-----------+------+------------+ | id | remote_id | type | date | +----+-----------+------+------------+ | 1 | 1 | A | 2011-01-01 | | 3 | 1 | A | 2011-01-07 | | 5 | 1 | B | 2011-01-07 | | 4 | 1 | A | 2011-05-01 | +----+-----------+------+------------+ I need to select from that data set based on the following criteria: If the pairing of remote_id and type is unique to the set, return the row always If the pairing of remote_id and type is not unique to the set, take the following action: Of the sets of rows for which the pairing of remote_id and type are not unique, return only the single row for which date is greatest and still less than or equal to now. So, if today is 2010-01-10, I'd like the data set returned to be: +----+-----------+------+------------+ | id | remote_id | type | date | +----+-----------+------+------------+ | 3 | 1 | A | 2011-01-07 | | 5 | 1 | B | 2011-01-07 | +----+-----------+------+------------+ For some reason I'm having no luck wrapping my head around this one. I suspect the answer lies in good application of group_by, but I just can't grasp it. Any help is greatly appreciated!

    Read the article

  • How to parametrize WPF Style?

    - by Konstantin
    Hi! I'm looking for a simplest way to remove duplication in my WPF code. Code below is a simple traffic light with 3 lights - Red, Amber, Green. It is bound to a ViewModel that has one enum property State taking one of those 3 values. Code declaring 3 ellipses is very duplicative. Now I want to add animation so that each light fades in and out - styles will become even bigger and duplication will worsen. Is it possible to parametrize style with State and Color arguments so that I can have a single style in resources describing behavior of a light and then use it 3 times - for 'Red', 'Amber' and 'Green' lights? <UserControl.Resources> <l:TrafficLightViewModel x:Key="ViewModel" /> </UserControl.Resources> <StackPanel Orientation="Vertical" DataContext="{StaticResource ViewModel}"> <StackPanel.Resources> <Style x:Key="singleLightStyle" TargetType="{x:Type Ellipse}"> <Setter Property="StrokeThickness" Value="2" /> <Setter Property="Stroke" Value="Black" /> <Setter Property="Height" Value="{Binding Width, RelativeSource={RelativeSource Self}}" /> <Setter Property="Width" Value="60" /> <Setter Property="Fill" Value="LightGray" /> </Style> </StackPanel.Resources> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Red"> <Setter Property="Fill" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Amber"> <Setter Property="Fill" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Green"> <Setter Property="Fill" Value="Green" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> </StackPanel>

    Read the article

  • Can my tortoise vs. hare race be improved?

    - by FredOverflow
    Here is my code for detecting cycles in a linked list: do { hare = hare.next(); if (hare == back) return; hare = hare.next(); if (hare == back) return; tortoise = tortoise.next(); } while (tortoise != hare); throw new AssertionError("cyclic linkage"); Is there a way to get rid of the code duplication inside the loop? Am I right in assuming that I don't need a check after making the tortoise take a step forward? As I see it, the tortoise can never reach the end of the list before the hare (contrary to the fable). Any other ways to simplify/beautify this code?

    Read the article

  • How do I parse a header with two different version [ID3] avoiding code duplication?

    - by user66141
    I really hope you can give me some interesting viewpoints for my situation, because I am not satisfied with my current approach. I am writing an MP3 parser, starting with an ID3v2 parser. Right now I`m working on the extended header parsing, my issue is that the optional header is defined differently in version 2.3 and 2.4 of the tag. The 2.3 version optional header is defined as follows: struct ID3_3_EXTENDED_HEADER{ DWORD dwExtHeaderSize; //Extended header size (either 6 or 8 bytes , excluded) WORD wExtFlags; //Extended header flags DWORD dwSizeOfPadding; //Size of padding (size of the tag excluding the frames and headers) }; While the 2.4 version is defined : struct ID3_4_EXTENDED_HEADER{ DWORD dwExtHeaderSize; //Extended header size (synchsafe int) BYTE bNumberOfFlagBytes; //Number of flag bytes BYTE bFlags; //Flags }; How could I parse the header while minimizing code duplication? Using two different functions to parse each version sounds less great, using a single function with a different flow for each occasion is similar, any good practices for this kind of issues ? Any tips for avoiding code duplication? Any help would be appreciated.

    Read the article

  • How to prevent duplication of content on a page with too many filters?

    - by Vikas Gulati
    I have a webpage where a user can search for items based on around 6 filters. Currently I have the page implemented with one filter as the base filter (part of the url that would get indexed) and other filters in the form of hash urls (which won't get indexed). This way the duplication is less. Something like this example.com/filter1value-items#by-filter3-filter3value-filter2-filter2value Now as you may see, only one filter is within the reach of the search engine while the rest are hashed. This way I could have 6 pages. Now the problem is I expect users to use two filters as well at times while searching. As per my analysis using the Google Keyword Analyzer there are a fare bit of users that might use two filters in conjunction while searching. So how should I go about it? Having all the filters as part of the url would simply explode the number of pages and sticking to the current way wouldn't let me target those users. I was thinking of going with at max 2 base filters and rest as part of the hash url. But the only thing stopping me is that it would lead to duplication of content as per Google Webmaster Tool's suggestions on Url Structure.

    Read the article

  • Parsing an header with two different version [ID3] avoiding code duplication?

    - by user66141
    I really hope you could give me some interesting viewpoints for my situation, my ways to approach my issue are not to my liking . I am writing an mp3 parser , starting with an ID3v2 parser . Right now I`m working on the extended header parsing , my issue is that the optional header is defined differently in version 2.3 and 2.4 of the tag . The 2.3 version optional header is defined as follows : struct ID3_3_EXTENDED_HEADER{ DWORD dwExtHeaderSize; //Extended header size (either 6 or 8 bytes , excluded) WORD wExtFlags; //Extended header flags DWORD dwSizeOfPadding; //Size of padding (size of the tag excluding the frames and headers) }; While the 2.4 version is defined : struct ID3_4_EXTENDED_HEADER{ DWORD dwExtHeaderSize; //Extended header size (synchsafe int) BYTE bNumberOfFlagBytes; //Number of flag bytes BYTE bFlags; //Flags }; How could I parse the header while minimizing code duplication ? Using two different functions to parse each version sounds less great , using a single function with a different flow for each occasion is similar , any good practices for this kind of issues ? any tips for avoiding code duplication ? anything would be great .

    Read the article

  • DRY and SRP

    - by Timothy Klenke
    Originally posted on: http://geekswithblogs.net/TimothyK/archive/2014/06/11/dry-and-srp.aspxKent Beck’s XP Simplicity Rules (aka Four Rules of Simple Design) are a prioritized list of rules that when applied to your code generally yield a great design.  As you’ll see from the above link the list has slightly evolved over time.  I find today they are usually listed as: All Tests Pass Don’t Repeat Yourself (DRY) Express Intent Minimalistic These are prioritized.  If your code doesn’t work (rule 1) then everything else is forfeit.  Go back to rule one and get the code working before worrying about anything else. Over the years the community have debated whether the priority of rules 2 and 3 should be reversed.  Some say a little duplication in the code is OK as long as it helps express intent.  I’ve debated it myself.  This recent post got me thinking about this again, hence this post.   I don’t think it is fair to compare “Expressing Intent” against “DRY”.  This is a comparison of apples to oranges.  “Expressing Intent” is a principal of code quality.  “Repeating Yourself” is a code smell.  A code smell is merely an indicator that there might be something wrong with the code.  It takes further investigation to determine if a violation of an underlying principal of code quality has actually occurred. For example “using nouns for method names”, “using verbs for property names”, or “using Booleans for parameters” are all code smells that indicate that code probably isn’t doing a good job at expressing intent.  They are usually very good indicators.  But what principle is the code smell of Duplication pointing to and how good of an indicator is it? Duplication in the code base is bad for a couple reasons.  If you need to make a change and that needs to be made in a number of locations it is difficult to know if you have caught all of them.  This can lead to bugs if/when one of those locations is overlooked.  By refactoring the code to remove all duplication there will be left with only one place to change, thereby eliminating this problem. With most projects the code becomes the single source of truth for a project.  If a production code base is inconsistent with a five year old requirements or design document the production code that people are currently living with is usually declared as the current reality (or truth).  Requirement or design documents at this age in a project life cycle are usually of little value. Although comparing production code to external documentation is usually straight forward, duplication within the code base muddles this declaration of truth.  When code is duplicated small discrepancies will creep in between the two copies over time.  The question then becomes which copy is correct?  As different factions debate how the software should work, trust in the software and the team behind it erodes. The code smell of Duplication points to a violation of the “Single Source of Truth” principle.  Let me define that as: A stakeholder’s requirement for a software change should never cause more than one class to change. Violation of the Single Source of Truth principle will always result in duplication in the code.  However, the inverse is not always true.  Duplication in the code does not necessarily indicate that there is a violation of the Single Source of Truth principle. To illustrate this, let’s look at a retail system where the system will (1) send a transaction to a bank and (2) print a receipt for the customer.  Although these are two separate features of the system, they are closely related.  The reason for printing the receipt is usually to provide an audit trail back to the bank transaction.  Both features use the same data:  amount charged, account number, transaction date, customer name, retail store name, and etcetera.  Because both features use much of the same data, there is likely to be a lot of duplication between them.  This duplication can be removed by making both features use the same data access layer. Then start coming the divergent requirements.  The receipt stakeholder wants a change so that the account number has the last few digits masked out to protect the customer’s privacy.  That can be solve with a small IF statement whilst still eliminating all duplication in the system.  Then the bank wants to take a picture of the customer as well as capture their signature and/or PIN number for enhanced security.  Then the receipt owner wants to pull data from a completely different system to report the customer’s loyalty program point total. After a while you realize that the two stakeholders have somewhat similar, but ultimately different responsibilities.  They have their own reasons for pulling the data access layer in different directions.  Then it dawns on you, the Single Responsibility Principle: There should never be more than one reason for a class to change. In this example we have two stakeholders giving two separate reasons for the data access class to change.  It is clear violation of the Single Responsibility Principle.  That’s a problem because it can often lead the project owner pitting the two stakeholders against each other in a vein attempt to get them to work out a mutual single source of truth.  But that doesn’t exist.  There are two completely valid truths that the developers need to support.  How is this to be supported and honour the Single Responsibility Principle?  The solution is to duplicate the data access layer and let each stakeholder control their own copy. The Single Source of Truth and Single Responsibility Principles are very closely related.  SST tells you when to remove duplication; SRP tells you when to introduce it.  They may seem to be fighting each other, but really they are not.  The key is to clearly identify the different responsibilities (or sources of truth) over a system.  Sometimes there is a single person with that responsibility, other times there are many.  This can be especially difficult if the same person has dual responsibilities.  They might not even realize they are wearing multiple hats. In my opinion Single Source of Truth should be listed as the second rule of simple design with Express Intent at number three.  Investigation of the DRY code smell should yield to the proper application SST, without violating SRP.  When necessary leave duplication in the system and let the class names express the different people that are responsible for controlling them.  Knowing all the people with responsibilities over a system is the higher priority because you’ll need to know this before you can express it.  Although it may be a code smell when there is duplication in the code, it does not necessarily mean that the coder has chosen to be expressive over DRY or that the code is bad.

    Read the article

  • How to avoid code duplication for a system which has logic that may change year wise?

    - by aravind
    What would be the way to design a system which has logic that may change year wise? There is an application which conducts online exams. There are five questions for a particular subject. The questions may (or may not) change year wise. As per my current design, the questions in database are stored year wise. There are some year specific code logic as well. In order to enable the application for another year, the year specific database records and code will be copied or duplicated. How to avoid this code duplication?

    Read the article

  • $query returns results but not the ones i want: $query looks good to me :S

    - by Toni Michel Caubet
    I'll start again, Lets say My data is: Table element (id,name,....) 1, name element 1, .... 2, name element 2, .... 3, name element 3, .... Table tags (id,name,id_element, ....) 1, happy , 1 2, result, 1 3, very , 1 4, element, 2 5, another, 3 6, element, 1 7, happy, 2 So if search is 'very, happy,element,result': Results i would like 1) element with id = 2 because it has all tags 2) element with id = 1 because it has the tag 'element' and the tag 'happy' (only 2 less taggs) 3) .... (only 3 less taggs) So if search is 'happy,element': Results i would like 1) element with id = 1 because it has all tags (and no more) 2) element with id = 2 because it has the tag 'element' and the tag 'happy' (and two more tags) 3) .... and 3 more tags This is an echo to my query: (it doesn't fit al requirements i wrote, but its first test to find with matched tags) SELECT element.id as id_deseada,tagg.* FROM element,tagg WHERE tagg.id_element = element.id AND tagg.nombre IN ('happy','tagg','result') GROUP BY tagg.id_element ORDER BY element.votos This returns 10 duplicated elements... :S and doen't even have all taggs (and on database there are taggs with 'happy' results) if it helps, thats how i get the elements of a tag (by name and with only one tagg) $query = "SELECT element.id FROM element,tagg WHERE tagg.nombre = '$nombre_tagg' AND tagg.id_element = element.id AND lan = '$lan' GROUP BY tagg.id_element"; I hope it's a bit easier to understand now, excuse my english.. :) Thanks a lot for you possible aportation!

    Read the article

  • any ideas for avoiding duplicate code in C# and javascript

    - by ooo
    i have an asp.net mvc website where i build up most of the page using C# for example building up html tables given a set of data from my viewmodel i also have a lot of javascript that then dynamcially modifies these tables (add row for example). the javascript code to add a new row looks extremely similar to my "rendering" code i have in C# that is used to build up the html table in the first place. Every time i change the c# code to a add a new field, i have to remember to go back to the javascript code to do the same. is there a better way here?

    Read the article

  • Optimize Duplicate Detection

    - by Dave Jarvis
    Background This is an optimization problem. Oracle Forms XML files have elements such as: <Trigger TriggerName="name" TriggerText="SELECT * FROM DUAL" ... /> Where the TriggerText is arbitrary SQL code. Each SQL statement has been extracted into uniquely named files such as: sql/module=DIAL_ACCESS+trigger=KEY-LISTVAL+filename=d_access.fmb.sql sql/module=REP_PAT_SEEN+trigger=KEY-LISTVAL+filename=rep_pat_seen.fmb.sql I wrote a script to generate a list of exact duplicates using a brute force approach. Problem There are 37,497 files to compare against each other; it takes 8 minutes to compare one file against all the others. Logically, if A = B and A = C, then there is no need to check if B = C. So the problem is: how do you eliminate the redundant comparisons? The script will complete in approximately 208 days. Script Source Code The comparison script is as follows: #!/bin/bash echo Loading directory ... for i in $(find sql/ -type f -name \*.sql); do echo Comparing $i ... for j in $(find sql/ -type f -name \*.sql); do if [ "$i" = "$j" ]; then continue; fi # Case insensitive compare, ignore spaces diff -IEbwBaq $i $j > /dev/null # 0 = no difference (i.e., duplicate code) if [ $? = 0 ]; then echo $i :: $j >> clones.txt fi done done Question How would you optimize the script so that checking for cloned code is a few orders of magnitude faster? System Constraints Using a quad-core CPU with an SSD; trying to avoid using cloud services if possible. The system is a Windows-based machine with Cygwin installed -- algorithms or solutions in other languages are welcome. Thank you!

    Read the article

  • Is 301 redirect sufficient to solve WWW and HTTP/S duplication?

    - by Thomas Ojo
    I was reading about this article - SEO preference for WWW or HTTP:// protocol redirection? Do www websites rank better than NON-www? I have same problem but I needed a help on this further. What about https:// How will this be treated? Is the redirect 301 sufficient to solve the problem? I have a SEO company that says if possible, i should not have redirect but I don't think this is visible? Does permanent redirect in any way have effect on SEO services if properly done?

    Read the article

  • OS Isolation: Virtualization or Dual-Boot Duplication, a General How To?

    - by Mr_CryptoPrime
    I want to isolate my windows 7 operating system and I have looked into virtualization. This should work with Linux, however, I do want to still have a way to run windows 7 securely, but without significant performance loss, thus eliminating virtualization for that. I know that you can dual boot because I currently do so with my XP/Linux system. Is there a way that I can duplicate my windows 7 system so I can select one at bootup? This way I can ensure that each OS is isolated and not worry about performance loss. However, I am having a lot of trouble finding a solid method for OS duplication?! Is this even possible or must I buy two versions of win7 and somehow install them separately? Any information regarding this would be helpful, thanks! Essentially I want, Two instances of win7 (not necessarily simultaneously running) Each are isolated from one another so that a security breach in one doesn't affect the other. There is no performance loss in either from doing so

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >