simplify

How best to switch from template mess to clean classes architecture (C++)?

Assuming a largish template library with around 100 files containing around 100 templates with overall more than 200,000 lines of code. Some of the templates use multiple inheritance to make the usage of the library itself rather simple (i.e. inherit from some base templates and only having to implement certain business rules). All that...

How to make a build (java) as "CM-independent" as possible? (CM=Configuration Manager)

I have been thinking of making one of the project builds I handle, as "independent" of me(CM)as I possibly can. By this I dont just mean automation via scripts/tools - although it definitely includes it. This is a project subject to much chaos and so "total" automation would not be realistic. Here is what I'm aiming for: Anybody should...

Simplifying Data with a for loop (Python)

Hi, I was trying to simplify the code: header = [] header.append(header1) header.append(header2) header.append(header3) header.append(header4) header.append(header5) header.append(header6) where: header1 = str(input.head...

insertAt in F# simpler and/or better

I would like to start some questions about simplifying different expressions in F#. Anyone have ideas for better and/or simpler implementation of insertAt (parameters could be reordered, too). Lists or Sequences could be used. Here is some start implementation: let insertAt x xs n = Seq.concat [Seq.take n xs; seq [x]; Seq.skip n xs] ...

All picks of a list in F# - more elegant and simple

Could someone propose better and/or more elegant implementation of this: let each xs = let rec each' acc left right = match right with | [] -> acc | right -> let new_left = left @ [List.hd right] let next = List.tl right let result = (List.hd right), left @ next ...

Stop bing maps simplifying polygons

Bing maps currently simplifies each polygon shape that gets put on the map. While that's good for most things, I need to show the full resolution polygons and I'll sort out the simplification myself. Any ideas on how to do this, I can't seem to find a way to turn it off and finding documentation on Bing/live/VE/MS/whatever maps is a ni...

Simplify jQuery Selector

I have a selector, "td > a.leftmenuitem:last, div > a.leftmenuitem:last", and I'd like to simplify it a little. I've tried "* > a.leftmenuitem:last", "td, div > a.leftmenuitem:last", and "(td, div) > a.leftmenuitem:last", none of which work the way the first selector does. Is this kind of thing just not possible in the selector syntax wi...

Most elegant combinations of elements in F#

One more question about most elegant and simple implementation of element combinations in F#. It should return all combinations of input elements (either List or Sequence). First argument is number of elements in a combination. For example: comb 2 [1;2;2;3];; [[1;2]; [1;2]; [1;3]; [2;2]; [2;3]; [2;3]] ...

Simplifying FOR loops

I have a function that essentially reads values in from a vector of doubles, appends these to a string (while ensuring a space between each and setting their precisions) and returns the end result, minus the final whitespace: std::string MultiplePrintProperties::GetHpitchString() { std::string str; vector< double >::iter...

How can I simplify this PHP?

I have the following model functions with PHP. I know I am repeating myself. Is there anyway I can simplify this code? function getTopMenus(){ $data[0] = 'root'; $this->db->where('parentid',0); $Q = $this->db->get('menus'); if ($Q->num_rows() > 0){ foreach ($Q->result_array() as $row){ $data[$row['i...

html php and select box simplification

Is there a better way to structure this, using html and php? If I had a billion values, this would be a bad way to set them up, not to mention time consuming as well? I am a newb, and I am pretty sure there is a better way, however, my way of doing it seems to be the long way, as in long division, I am pretty sure there are easier meth...

Can this sql query be simplified?

Hi! I have a Sql Query: select * from contactmeta WHERE contactmeta.contact_id in ( select tob.object_id from tagobject tob, tag t, taggroup tg where tob.tag_id = t.tag_id and t.tag_group_id = tg.tag_group_id and tob.object_type_id = 14 and tg.org_id = contactmeta.group_id and (t.name like '%campaign%') ) AND contactmeta.contact_id...

Help me to simplify my jQuery, it's growing huge and redundant!

Hey all, I am no jQuery expert, but I'm learning. I'm using a bit (growing to a LOT) of jQuery to hide some images and show a single image when a thumb is clicked. While this bit of jQuery works, it's horribly inefficient but I am unsure of how to simplify this to something that works on more of a universal level. <script> $(document)...

Simplify WCF configuration

I have a bunch of self-hosted WCF services. Everything's working fine but I'm look for ways to normalize/simplify the resultant config. I've simplified it as much as possible, but I'm still not happy. Currently, my config looks like this: <system.serviceModel> <bindings> <netTcpBinding> <binding name="BindingConf...

Php deliberately awkward?

I'm trying to create a login process (as people who have answered my previous question will know) But it seems impossible to create one process that will work with a desktop app and a standard website. Instead I have the login function in Usermanagement.php (which is a class, icyntk) but then in another php file (api/login.php) I have:...

how to simplify this database update query (php)

How could I simplify this update instruction? Whenever a client buys an item it will update the sales with 1. $this->db->query('SELECT amount FROM shop_items WHERE itemid='.$itemid.''); $new_amount = $item->amount+1; if(!$this->db->query('UPDATE shop_items SET amount='.$new_amount.' WHERE itemid='.$itemid.'')): return false; ...

AS3: How to simplify Action Script 3 Code ?!

Here's a example that I've to use when I want to create a button with mouse-over effect: this.buttonExample.buttonMode = true; this.buttonExample.useHandCursor = true; this.buttonExample.addEventListener(MouseEvent.CLICK,myaction); I'm new to AS3 - is there any way, to simplify this code like this: this.buttonExample....

Can this sql query be simplified?

I have the following tables: Person, {"Id", "Name", "LastName"} Sports, {"Id" "Name", "Type"} SportsPerPerson, {"Id", "PersonId", "SportsId"} For my query I want to get all the Persons that excersise a specific Sport whereas I only have the Sports "Name" attribute at my disposal. To retrieve the correct rows I've figured out the followi...

php help hiding navigation with cookie

I have these tabs on my navigation: <li<?php if ($thisPage=="Customers") echo " class=\"current\""; ?>><a href="/customers/">Customers</a></li> <li<?php if ($thisPage=="Trunks") echo " class=\"current\""; ?>><a href="/trunks/">Trunks</a></li> <li<?php if ($thisPage=="Settings") echo " class=\"current\""; ?>><a href="/settings/">Setti...

How can I simplify this redundant code?

Can someone please help me simpling this redundant piece of code? if (isset($to) === true) { if (is_string($to) === true) { $to = explode(',', $to); } $to = array_filter(filter_var_array(preg_replace('~[<>]|%0[ab]|[[:cntrl:]]~i', '', $to), FILTER_VALIDATE_EMAIL)); } if (isset($cc) === true) { if (is_string(...