Posts

html - Marking up the "BBC pattern" in HTML5 -

i'm looking @ bbc site, , putting following similar overall pattern, , determining how mark appropriately stumping me somewhat. the bbc consists of several considered sites in own right: http://www.bbc.co.uk http://www.bbc.co.uk/comedy/ http://www.bbc.co.uk/news/ www.bbc.co.uk/[a-lot-more-stuff] (these subdomains instead - indeed, case me - urls not important) each of these self-contained, own content, menu , , feel. of them tied use of (slightly variable mostly) static header bar. contains header "bbc" along links of various sub-sites. so question is, how should marked up. see several different options: the main bbc header site's main <header> , <nav> . sort of correct, because ends de-emphasising importance of sub-site's actual content. when boils down (to use examples above), title "comedy" , associated menu main content of page, not bbc bar. make sub-sites' header , navigation ones marked within <header> ...

Examples of Java frameworks which don't play well with Scala -

has run across java/java ee framework causes problems if used scala? don't know of specific one, pre-java 5 framework uses raw types may cause trouble @ point in scala, if have raw type in hierarchy of class must implement. here few questions related issue: implementing methods having raw types in scala why scala complain illegal inheritance when there raw types in class hierarchy? scala class cant override compare method java interface extends java.util.comparator

ruby on rails - Restricting admin from destroying own account using cancan -

here snippet of code ability class if user.admin? can :manage, :all can :destroy, :all if != current_user i sure can figure out trying here. realize destroy included in manage , repeating myself there. suggestions? edit yjerem's answer correct 1 , changed fit code. looks like. if user.admin? can :manage, :all cannot :destroy, user, :id => user.id as yjerem said, in cancan, ability precedence states ability defined lower down trump ones on them admin can manage except defined under using code above. read ability precedence , there's example there you! basically want cannot method: if user.admin? can :manage, :all cannot :destroy, user, :id => current_user.id because cannot rule below more general one, overrides it.

c# - Is a static variable shared across all instance? -

in public class, have private static dictionary. since dictionary static, mean shared across other instance of same object (see example below). public class tax { private static dictionary<string, double> taxbrakets = new dictionary<string, double>(stringcomparer.ordinalignorecase) { { "individual", 0.18 }, { "business", 0.20 }, { "other", 0.22 }, }; public string type { get; set; } public double computetax(string type, double d) { return d * taxbrakets[this.type]; } } is acceptable use dictionary in way (as static variable)? your static variable taxbrakets not associated instance. this.taxbrakets not compile. occurrences of taxbrakets refer same dictionary. in general, it's totally acceptable use static dictionaries. particular use seems little funny though, i'd need see more code suggest changes.

php - Convert array values to a comma-delimited string, with numbers replaced by '?' -

my array: $numbers = array(1, 3, 5); simply, need change numbers ? question mark , separated , comma. // output (array has 3 items): $string = '?, ?, ?'; you can use combination of str_repeat , count . use rtrim clean trailing comma: $numbers = array(1, 3, 5); $str = str_repeat('?, ', count($numbers)); $str = rtrim($str, ', '); echo $str; // output: ?, ?, ?

Doctrine 2 mysql FIELD function in order by -

i'm trying use mysql field function in order clause in query. i'm assuming doctrine 2 doesn't support field function out of box - true? if so, how can use it? have turn whole query native query? there doctrine 2 extension adds functionality? jeremy hicks, your extension . didn`t know how connect function doctrine, find answer. $doctrineconfig = $this->em->getconfiguration(); $doctrineconfig->addcustomstringfunction('field', 'doctrineextensions\query\mysql\field'); i need field function order entities select in expression. can use function in select, where, between clause, not in order by . solution: $qb ->select("r, field(r.id, " . implode(", ", $ids) . ") hidden field") ->from("entities\round", "r") ->where($qb->expr()->in("r.id", $ids)) ->orderby("field"); to avoid adding field alias re...

c# - Performing Inserts and Updates with Dapper -

i interested in using dapper - can tell supports query , execute. not see dapper includes way of inserting , updating objects. given our project (most projects?) need inserts , updates, best practice doing inserts , updates alongside dapper? preferably not have resort ado.net method of parameter building, etc. the best answer can come @ point use linqtosql inserts , updates. there better answer? we looking @ building few helpers, still deciding on apis , if goes in core or not. see: http://code.google.com/p/dapper-dot-net/issues/detail?id=6 progress. in mean time can following val = "my value"; cnn.execute("insert table(val) values(@val)", new {val}); cnn.execute("update table set val = @val id = @id", new {val, id = 1}); etcetera see blog post: that annoying insert problem update as pointed out in comments, there several extensions available in dapper.contrib project in form of these idbconnection extension methods: ...