Posts

Showing posts from July, 2013

Correct practice using 'using' in C++ templates -

i have small class uses several stl lists internally template<class t> class mc_base { using obj_list = std::list<t>; using obj_val = typename obj_list::value_type; using obj_itr = typename obj_list::iterator; using obj_citr = typename obj_list::const_iterator; obj_list a,b,c; ... }; with using statements, if write iterator inside class definition, looks nice , clean: obj_itr begin() { return a.begin(); }; obj_itr end() { return a.end(); }; obj_citr begin() const { return a.begin(); }; obj_citr end() const { return a.end(); }; writing new functions, again inside class definition, easy since can use names obj_xxxx names when needed. furthermore, if decide change container type (to std::vector ) @ point later, have change 1 line , long new container supports same actions should seamless. this problematic when want define new class function outside of class definition template<class t> obj_itr mc_base<t>::foo(obj_itr x)

java - scalable loadbalancer for jetty server -

i creating application , want create applications fast scale. use java jetty servers, cassandra database , solr search engine. should use loadbalancer infront of jetty servers whole setup can scale. i've read mod_jk , apache i've read doesn't scale many machines due beeing programmed in c. should use? should try , program myself in java? want use non sticky sessions. so apache work fine reverse proxy, more or team familiar with. without sticky sessions pretty easy things work. nginx or haproxy looking though if need bigger. scale horizontally more trick of not having sticky sessions (which have covered) fronting dns round robining work. really not sure mean programming being in c doesn't have scaling things horizontally or vertically. thats more of architecture thing language used implement it.

javascript - Strange characters in Htmt view -

i have javascript following <script type="text/javascript"> var login = "<sec:authentication property="principal.username"/>"; </script> when see value of login is abc&#64;gmail&#46;com. what want must abc@gmail.com. is there way can correct lo-gin , not weird symbols. know why such weird symbols occurring instead of proper symbols. &#64; , &#46; html codes @ , . respectively. as far know there isin't native function decode such string in javascript. can use parsing ability of dom elements. var login = (login = document.createelement('span'), login.innerhtml = 'abc&#64;gmail&#46;com', login.textcontent); you can wrap functionality in function reuse: function decodehtml(text) { var el = document.createelement('span'); return el.innerhtml = text, el.textcontent; } decodehtml('abc&#64;gmail&#46;com');

jquery - How do I change left with element label? -

my code this: <label><li><input name="skills[]" class="skills" value="1" type="checkbox" /></li>a</label> <label><li><input name="skills[]" class="skills" value="2" type="checkbox" /></li>b</label> for change (left element) of checked checkbox, use code: $('input.skills').on('change', function() { if($(this).is(':checked')) { $(this).parents('li').append('<span class="text">add</span>'); } else { $(this).parents('li').find('.text').remove(); } $(this).animate({left:'500'},1000); }); however don't change label location, change checked check box location. you can move entire li. http://jsfiddle.net/pyuau/ html <ul class="skill-holder"> <li><input name="skills[]" class="skills&qu

java - How do we get to know whether a macro is present or not in a word document? -

using java how find whether macro present or not in microsoft word document. tried using switch command winword.exe there no switch can find it. use library can parse word documents. apache poi choice long documents aren't big. the library allows load document. afterwards, can examine various parts. bug 52949 has attachment sample code how extract macro code. should started. you you're using new xml format .docx / ooxml, word file in fact zip archive can unpack using standard java library. inside, find lot of xml files. macros should there well.

Communication errors with Amazon SWF - Ruby Flow -

we having issue new ruby-flow wrapper amazon swf. the issue workflow , activity workers (several times hour) unable correctly communicate swf server. manifests in various ways: workflows or activities fail register when workers new versions started workflow or activity workers crash activity workers finish task , error when reporting done, entire execution fails. for worker crashes (either kind), see following: andy@andy-mbp:crucible $rails_env=development rake crucible:swf:ingress_wf_start rake aborted! execution expired /users/andy/.rvm/gems/ruby-1.9.3-p448@rails3/gems/aws-sdk-1.11.1/lib/aws/core/http/connection_pool.rb:301:in `start_session' /users/andy/.rvm/gems/ruby-1.9.3-p448@rails3/gems/aws-sdk-1.11.1/lib/aws/core/http/connection_pool.rb:125:in `session_for' /users/andy/.rvm/gems/ruby-1.9.3-p448@rails3/gems/aws-sdk-1.11.1/lib/aws/core/http/net_http_handler.rb:52:in `handle' /users/andy/.rvm/gems/ruby-1.9.3-p448@rails3/gems/aws-sdk-1.11.1/lib/aws/core/

sql - Optimal way of determining number of table entries that are duplicate on particular columns -

i need determine whether particular table rows unique on particular columns. i'm doing using subquery so: select t1.id, (select count(*) mytable t2 (t2.firstname = t1.firstname) , (t2.surname = t1.surname) ) cnt mytable t1 t1.id in (100, 101, 102); which works fine. however, i'd know if knows of more efficient way of achieving same result using subquery. i'm doing on azure sql server, way. you use group this: select t1.firstname, t1.surname, count(t1.id) cnt mytable t1 t1.id in (100, 101, 102) group t1.firstname, t1.surname order cnt desc you can add having cnt > 1 after group clause if want filter dupplicates. however, depends if need id column well, if do, might have use subquery. here can find more information on subject: http://technet.microsoft.com/en-us/library/ms177673.aspx

sql - View Clustered Index Seek over 0.5 million rows takes 7 minutes -

take @ execution plan: http://sdrv.ms/1aglg7k it’s not estimated, it’s actual. actual execution took 30 minutes . select second statement (takes 47.8% of total execution time – 15 minutes). @ top operation in statement – view clustered index seek on _security_tuple4. operation costs 51.2% of statement – 7 minutes. the view contains 0.5m rows (for reference, log2(0.5m) ~= 19 – mere 19 steps given index tree node size two, in reality higher). result of operator 0 rows (doesn’t match estimate, never mind now). actual executions – zero. so question is : how bleep take 7 minutes?! (and of course, how fix it?) edit : some clarification on i'm asking here . not interested in general performance-related advice, such "look @ indexes", "look @ sizes", "parameter sniffing", "different execution plans different data", etc. know already, can kind of analysis myself. what need know what cause 1 particular clustered index seek slow

ios - Autorelease objects in ARC -

suppose in database manager singleton. + (swdatabasemanager *)retrievemanager { @synchronized(self) { if (!sharedsingleton) { sharedsingleton = [[swdatabasemanager alloc] init]; } return sharedsingleton; } } - (nsarray *)getproductdetails:(nsstring *)somestring { nsarray *temp = [self getrowsforquery:somestring]; return temp; } - (nsarray *)getrowsforquery:(nsstring *)sql { sqlite3_stmt *statement=nil; nsmutablearray *arrayresults = [nsmutablearray arraywithcapacity:1]; // //fetching data database , adds them in arrayresults // return arrayresults; } now view controller calling function of database manager this.... [self getproductservicedidgetdetail:[[swdatabasemanager retrievemanager] getproductdetail: @"somequery"] - (void)getproductservicedidgetdetail:(nsarray *)detailarray { [self setdatasource:[nsarray arraywitharray:detailarray]]; [self.tableview reloaddata]; } q

Yii Ajax request CSRF can not be verified -

i use few different ajax calls in 1 of pages through couple of different methods. chtml::link() chtml::ajax() within cgridview since enabling csrf i'm having difficulty verifying token. correct way? i've read few posts, struggling implement. instance in chtml::link() i've tried: 'data' => "yii::app()->request->csrftokenname = yii::app()->request->csrftoken", and within cgridview : data: { yii::app()->request->csrftokenname => yii::app()->request->csrftoken }, 1- fot ajax have ajax , ajaxlink , ajaxbutton not link. 2- csrf token works when use post request 3- add csrf token this: 'data' =>array('yii_csrf_token' => yii::app()->request->csrftoken)`

Magento - plugin overwrite local.xml block -

i have local.xml file has following: <default> <cms_index_index translate="label"> <reference name="masthead"> <block type="page/html" template="cms/masthead/homepage.phtml" as="banners" /> </reference> </cms_index_index translate="label"> </default> i have plugin has it's own config.xml - wish override above block template located in: /app/code/local/mageworx/geoip/cms/homepage.phtml. the config.xml file different , looks like: <config> <modules> <mageworx_geoip> <version>1.0.7</version> </mageworx_geoip> </modules> <frontend> <translate> <modules> <mageworx_geoip> <files> <default>mageworx_geoip.csv</default> </files> </mageworx_geoip>

vb.net - ArrayList in VB 2010 - What's wrong with my code? -

i wondering if point out going wrong code. working arraylist called nouns , have code adds word that's picked arraylist arraylist called newarray() . the trouble is, when sub called label_click event, doesn't keep words stored in newarray code newarray.add(wordchosen) is. found debugging it, using breakpoints , stepping. the code part here: sub getnoun() dim nouns arraylist = new arraylist(16) nouns.add("france") nouns.add("bird") nouns.add("doctor") nouns.add("city") ... dim lblarray label() = {lblone, lbltwo, lblthree, lblfour} start: dim wordchosen string wordchosen = nouns(random.next(16)) if newarray.contains(wordchosen) goto start else dim labelchosen label labelchosen = lblarray(random.next(4)) labelchosen.text = wordchosen nouns.remove(wordchosen) newarray.add(wordchosen) end if end sub what keep words within dynamic

node.js - Mongoose and findAndModify -

i use node.js mongoose plugin. need try select single document query like: { _id: '52261c53daa9d6b74e00000c', someadditionalflag: 156 } and if , if succeeds change flag value. moreover, find , modify operation needs atomic . please, how achieve using mongoose? you don't need use findandmodify don't need original document. can use update this: mymodel.update({ _id: '52261c53daa9d6b74e00000c', someadditionalflag: 156 }, { $set: {someadditionalflag: newvalue } }, function(err, numaffected) { ... }); in callback, numaffected 1 if change made, otherwise 0.

r - `geom_line()` connects points mapped to different groups -

Image
i'd group data based on interaction of 2 variables, map aesthetic 1 of variables. (the other variable represents replicates should, in theory, equivalent each other). can find inelegant ways this, seems there ought more elegant way it. for example # data frame 2 continuous variables , 2 factors set.seed(0) x <- rep(1:10, 4) y <- c(rep(1:10, 2)+rnorm(20)/5, rep(6:15, 2) + rnorm(20)/5) treatment <- gl(2, 20, 40, labels=letters[1:2]) replicate <- gl(2, 10, 40) d <- data.frame(x=x, y=y, treatment=treatment, replicate=replicate) ggplot(d, aes(x=x, y=y, colour=treatment, shape=replicate)) + geom_point() + geom_line() this gets right, except don't want represent points different shapes. seems group=interaction(treatment, replicate) (e.g based on this question , geom_line() still connects points in different groups: ggplot(d, aes(x=x, y=y, colour=treatment, group=interaction("treatment", "replicate"))) + geom_point() + geom_li

linux - extract file content from match pattern to another match pattern -

how extract file content match pattern match pattern. not split. for example: 1.txt myname myage myeducation myaddress > myoccupation mydesignation mysalary myofficename > mygrosssalary mypermanentaddress myfathersname in above file want extract content file , remove content starting pattern > myoccupation to > mygrosssalary to file. with awk: awk '/> myoccupation/,/> mygrosssalary/' file with sed: sed -n '/> myoccupation/,/> mygrosssalary/p' file and can use output redirection create file, with comand ... > newfile

ios - Is it necessary to declare a property for a private variable? -

i wanted know if necessary declare property every private variable create in xcode projects. if is, can explain me reason? =) properties useful if want add custom get-and-set logic variables. typically used more public variables. there cases when may want use them private variables, not "necessary".

GWT Cell Tree Right Click Selection -

so have created celltree , want select cell receives right click when open context menu things, know cell working with. maybe going wrong way, can override onbrowserevent method , detect when right clicks on tree can't figure out cell being clicked can manually select it. has found solution problem? the solution consists of 2 steps: 1) add treeviewmodel constructor of celltree . model can set names of elements in tree. here simple implementation api : private static class customtreemodel implements treeviewmodel { /** * {@link nodeinfo} provides children of specified * value. */ public <t> nodeinfo<?> getnodeinfo(t value) { /* * create data in data provider. use parent value prefix * next level. */ listdataprovider<string> dataprovider = new listdataprovider<string>(); (int = 0; < 2; i++) { dataprovider.getlist().add(value + "." + string.valueof(i)); }

java - Do Guice singletons honor thread-confinement? -

i have concern regarding guice , whether or not singletons obey thread confinement may try set up: public class cachemodule extends abstractmodule { @override protected void configure() { // widgetcache.class located inside 3rd party jar // don't have ability modify. widgetcache widgetcache = new widgetcache(...lots of params); // guice reuse same widgetcache instance on , on across // multiple calls injector#getinstance(widgetcache.class); bind(widgetcache.class).toinstance(widgetcache); } } // cacheadaptor "root" of dependency tree. other objects // created it. public class cacheadaptor { private cachemodule bootstrapper = new cachemodule(); private widgetcache widgetcache; public cacheadaptor() { super(); injector injector = guice.createinjector(bootstrapper); setwidgetcache(injector.getinstance(widgetcache.class)); } // ...etc. } so can see, time crea

Static tableview tap to top on iOS only works on some controllers? -

i have designed app (not yet released) in 2 tableview controllers have static cells. when tap status bar, should zoom top. however, 1 of them this. cause interference on 1 not working? i found since had hooked up, had manually detect when user tapped clock , scroll programmatically top [[nsnotificationcenter defaultcenter] addobserverforname:@"_uiapplicationsystemgesturestatechangednotification" object:nil queue:nil usingblock:^(nsnotification *note) { nslog(@"status bar pressed!"); //[self.tableview scrolltorowatindexpath:[nsindexpath indexpathforitem:0 insection:0] atscrollposition:uitableviewscrollpositiontop animated:yes]; [self.ta

ios - How to create an NSMutableArray and assign a specific object to it? -

i getting obj c, , looking create array of mkannotations. i have created mkannotation class called trucklocation contains name, description, latitude, , longitude. here have far array: nsmutablearray* trucksarray =[nsmutablearray arraywithobjects: @[<#objects, ...#>] nil]; yore trying combine 2 different syntaxes similar different things. don't seem have instances of annotations. create instances trucklocation *a1 = ...; trucklocation *a2 = ...; then can add them nsmutablearray *trucksarray = [nsmutablearray arraywithobjects:a1, a2, nil]; or nsmutablearray *trucksarray = [@[a1, a2] mutablecopy] this shorter , more modern form need make mutable create immutable instance.

linux - How do I mix ip and name based virtualhosts on the same server? -

i have production site on server , i'm looking add development site. production site using ip address have single domain ssl certificate. there way can add development site without purchasing ip. don't need ssl development site. perhaps mix of ip , name based virtualhosts? current setup follows: # production namevirtualhost 123.45.678.910:80 <virtualhost 123.45.678.910:80> documentroot /var/www/html/production servername www.example.com </virtualhost> namevirtualhost 123.45.678.910:443 <virtualhost 123.45.678.910:443> documentroot /var/www/html/production servername www.example.com </virtualhost> thanks paul edit would work? # production namevirtualhost 123.45.678.910:80 <virtualhost 123.45.678.910:80> documentroot /var/www/html/production servername www.example.com </virtualhost> namevirtualhost 123.45.678.910:443 <virtualhost 123.45.678.910:443> documentroot /var/www/html/production servername www.e

c++ - Why does the root pointer get initialized to null always? -

i'm confused following code: class tree { protected: struct node { node* leftsibling; node* rightsibling; int value; }; private: node* root; int value; ..... public: void addelement(int number) { if (root == null) { printf("this value of pointer %lld\n",(long long)root); printf("this value of int %d\n",value); ... return; } printf("not null\n"); } }; int main() { tree curtree; srand(time(0)); for(int = 0;i < 40; ++i) { curtree.addelement(rand() % 1000); } } the curtree variable local main function expected not have members initialized 0, both initialized. no, has unspecified contents . contents might random memory garbage, or happen 0, depending on whatever data left in memory location beforehand. it might happen due way code compiled, particular stack location containing root has 0

php - Xpath query not working -

here html: <div class="blogentry expecting featured featured-post-today%e2%80%99s-top-story first"> <h2><a href="/2013/09/03/rachel-zoe-pregnant-expecting-second-child/" rel="bookmark" title="permanent link rachel zoe expecting second&nbsp;child">rachel zoe expecting second&nbsp;child</a></h2> </div> <div class="blogentry expecting featured featured-post-today%e2%80%99s-top-story first"> <h2><a href="someurl" rel="bookmark" title="permanent link rachel zoe expecting second&nbsp;child">sometitle</a></h2> </div> i'm trying anchor value. here xpath: $finder->query('//div[@class="blogentry"]//h2//a'); it's returning no value. idea why? you need use function contains() here: $xml = <<<eof <div class="blogentry expecting featured featured-post-today%e2%80%99s-to

jquery - Cloudflare content in <head>..</head> element -

can explain me hows , whys content cloudflare seems inject documents create, being served through domain running via cloudflare? i know how html looks like, have built after all. if check via ftp looks same, if load in browser , inspect code there additional code present. why there for? all can see somehow breaks jquery , page not working should. i use cloudflare high-traffic site , it's helped immensely. cloudflare intercepts request , caches it, adds of own code other purposes - including caching , tracking (i believe). i haven't looked in cloudflare cp quite time, think there's option revome (or all) of additional code. if remember correctly have section on site explains additional code.

php - Xpath getting multiple p tags in one nodeValue -

i'd retrieve of p tags within div class="post" in 1 nodevalue. here html: <div class="blogentry expecting featured featured-post-today%e2%80%99s-top-story first"> <h2><a href="/2013/09/03/rachel-zoe-pregnant-expecting-second-child/" rel="bookmark" title="permanent link rachel zoe expecting second&nbsp;child">rachel zoe expecting second&nbsp;child</a></h2> <div class="post"> <p>sometext</p> <p>someothertext</p> </div> <div class="blogentry expecting featured featured-post-today%e2%80%99s-top-story first"> <h2><a href="someurl" rel="bookmark" title="permanent link rachel zoe expecting second&nbsp;child">sometitle</a></h2> <div class="post"> <p>sometext</p> <p>someothertext</p> </div> </div> here xpath:

javascript - detect textbox change when the jquery UI slider moves -

i have fiddle http://jsfiddle.net/48hpa/ , calculates sum automatically when enter keyword myself, when change slider, textbox value changes, don't see sum. why this? how can make work? thank much. $(document).ready(function(){ $(function() { $( "#slider1" ).slider({ range: "min", value: 36, min: 1, max: 36, slide: function( event, ui ) { $( ".amount1" ).val( ui.value); } }); $( ".amount1" ).val($( "#slider1" ).slider( "value" )); }); $(function() { $( "#slider2" ).slider({ range: "min", value: 50000, min: 1, max: 50000, slide: function( event, ui ) { $( ".amount2" ).val( ui.value ); } }); $( ".amount2" ).val( $( "#slider2" ).slider( "value" )); }

Selecting model based off of route in Rails -

i have polymorphic model discussion . can applied specialty model , program model. routes set as: resources :programs, :only => :show resources :discussions, :only => [:show, :create, :destroy, :new] end resources :specialties resources :discussions, :only => [:show, :create, :destroy, :new] end so, new discussions made either like: /specialties/yyyyy/discussions/new /programs/yyyyyy/discussions/new the problem in discussions_controller.rb file. have function: def new @object = xxxxx.find(params[:id]) end how choose appropriate model form (eg. replace 'xxxxx') , determining discussionable_type. assume parse url, doesn't seem clean. ideas? given routes, should either have params[:program_id] or params[:specialty_id] (or alike). this tell use.

angularjs - How come Ace editor won't work correctly in my Meteor/Angular application? -

i've created example meteor application integrates angularjs , embeds ace editor via ui.ace angular directive. however, although editor shows up, doesn't accept input. in chromium/chrome it's after open or close developer tools editor reacts , becomes responsive input (the editor must react change in browser's state afaict). basically, how fix app ace component works , accepts input? full source code app available @ github . code html angular.html <div class="content pure-g-r" data-ng-controller="meteorctrl"> <header> <nav id="menu" class="pure-menu pure-menu-open pure-menu-fixed pure-menu-horizontal"> <div class="pure-u-1-5"> <div class="pure-menu-heading">meteor-ace</div> </div> <ul class="pure-u-4-5"> <li data-ng-repeat="menuitem in menuitems&quo

php - send form data to two pages via ajax -

im having little problem here, have form, 2 fields, need form redirect me specifil location, example 1.php, , need values form sent 2.php @ once, php couldnt it, im guessing ajax can done, ideas? <form action="1.php"> <input type="text" name="value1"> <input type="text" name="value2"> </form> why im doing this? search form, have jquery pagination on form action, pagination gets data 2.php, need data sent also, need in 1.php , 2.php ideas? you can same sending data asynchronously other page html5 formdata. here's code : <form action="1.php" onsubmit="senddata()" id="myform"> <input type="text" name="value1"> <input type="text" name="value2"> </form> <script> function senddata() { var formdata = new formdata(document.getelementbyid('myform')); $.ajax({ url: '2.php',

Is it compulsory to use the abstract class as the root class in Java? -

is compulsory use abstract class root class in java? in other words, can extends normal class create derived abstract class? yes second question. try , see. code compile. think way: every class extends concrete class object , yet can still make own classes abstract.

c# - Copy Enhanced Metafile from clipboard and save it as an image -

i using follwing c# code copy image clipboard. if (clipboard.containsdata(system.windows.dataformats.enhancedmetafile)) { /* taken http://social.msdn.microsoft.com/forums/windowsdesktop/en-us/a5cebe0d-eee4-4a91-88e4-88eca9974a5c/excel-copypicture-and-asve-to-enhanced-metafile*/ var img = (system.windows.interop.interopbitmap)clipboard.getimage(); var bit = clipboard.getimage(); var enc = new system.windows.media.imaging.jpegbitmapencoder(); var stream = new filestream(filename + ".bmp", filemode.create); enc.frames.add(bitmapframe.create(bit)); enc.save(stream); } i took snippet here . control go in if condition. clipboard.getimage() returns null. can please suggest going wrong in here? i have tried following snippet metafile metafile = clipboard.getdata(system.windows.dataformats.enhancedmetafile) metafile; control control = new control(); graphics grfx = control.creategraphics(); memorystream ms = new memorystream(); intptr iphdc

javascript - Simplify functions so the code does not get too big -

i have code each element make scroll effect when done: keep repeating function each element, problem 30 elements different classes add, code large. jquery: $(window).scroll(function () { $('.regalos').each(function () { var imagepos = $(this).offset().top; var topofwindow = $(window).scrolltop(); if (imagepos < topofwindow + 400) { $(this).addclass("stretchleft"); } }); $('.sprite-layer-2').each(function () { var imagepos = $(this).offset().top; var topofwindow = $(window).scrolltop(); if (imagepos < topofwindow + 400) { $(this).addclass("slideleft"); } }); // ... must 28 }); i use: $(window).scroll(function () { var topofwindow = $(window).scrolltop(); function _checkoffset(classname) { return function () { var $this = $(th

Request: Efficient procedure to manually loop between two lists in python -

i feel silly asking have been struggling couple of days on how improve code , cannot discern obvious way improve actual design rather inefficient , ugly despite supposed simplicity... i need move across couple of lists using key events. for simplicity's sake let's first list “shops” , second 1 “products” shops = [shopa,shopb,shopc,shopcd,shope] products = [oranges, milk, water, chocolate, rice] let's keyboards keys “1” , “2” want move forward , backward respectively along “shops” list. on other hand, want use keys “3” , “4” move forward , backward respectively on “products” list. now, method have consists in couple of counters: “shopcounter” , “productscounter”. incidentally, each time move along “shops” list set “productscounter” 0 can start @ checking @ first item (in example oranges :) my problem lies in location/design of counters. have 4 sections in code: 1 each key instruction want , input (next/previous shop; next/previous product). since pyth

How to get Volume Serial Number using Visual Basic 2010? -

i'm trying volume serial number using visual basic 2010, is there whole code example shows me how this? thanks i guess simplest answer question given by: hans passant: link, i copied , pasted function , works microsoft visual basic 2010 express, without modifications public function getdriveserialnumber() string dim driveserial long dim fso object, drv object 'create filesystemobject object fso = createobject("scripting.filesystemobject") drv = fso.getdrive(fso.getdrivename(appdomain.currentdomain.basedirectory)) drv if .isready driveserial = .serialnumber else '"drive not ready!" driveserial = -1 end if end 'clean drv = nothing fso = nothing getdriveserialnumber = hex(driveserial) end function i thank help, and apologize repeating question, did google search , stackflow search, search was" "get hard drive serial number

what are the benefits of using base Interface in c# -

i m working application in base inteface has been created below public interface ibaserepository : idisposable { bool isunitofwork { get; set; } void savechanges(); } then other interfaces extend interface as public interface icourserepository : ibaserepository { course getcoursebyid(int id); list<course> getcourses(); coursemodule getcoursemodulebyid(int id); } just wondering advantage of approach the base repository allows specify behavior want repository contracts have without repeating in every imyentityrepository create. even more fun though implementing base repository , specifying generic code generic operations: public abstract class baserepository<tentity> : irepository<tentity> tentity : class { private dbcontext _context; public repository(dbcontext context) { if (context == null) { throw new argumentnullexception("context"); } _context = context; }

cannot change width attribute in iframe -

i working iframes. have found place in codebase iframe name found. despite changing attributes there, nothing happens. empty browser cache, still nothing happens. cannot find value that's stuck in codebase '460px !important' anywhere in codebase, , yet persists. advice appreciated. thank you! it's been days. you can use in size in percent or pixel instead. hope clear: <html> <head></head> <body> <iframe src="http://google" style="border: 0; position:fixed; top:0; left:0; right:0; bottom:0; width:100%; height:100%"> </body> </html>

How to free downloaded image from memory in android? -

in android app, download images , set them imageviews. assuming have reference imageview, can image , free memory manually using code? can show me how this? thanks. bitmap=null; you can bitmap bu using bitmapfactory.decoderesource(resources res, int id) have @ abdroid developer blog tutorials on handling loading of images. it's great resource loading large bitmaps

Magento language changes when changing theme -

when install new theme language changes. theme controlling language in magento? when change default theme language correct , can install theme works themes don't correct language. can tell me how can correct this? in admin menu go the system > configuration, the first tab shown should general , includes locale section . that set store's language. can choose store applies scope selection in top left of page. also can see here graphical notation hope sure you

PHP/MYSQL - Error Array ( ) string(47) "Column count doesn't match value count at row 1" -

if (!$errors) { $salt = time(); $pwd = sha1($password . $salt); $mysqli = new mysqli('localhost','user','password','database'); if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); } $stmt = $mysqli->prepare("insert users values (?,?,?,?,?,?)"); $stmt->bind_param('ssssss',$username,$pwd,$lastloggedin,$role,$paswordchangedate,$salt); this code snippet, have counted, countless times (on fingers too..)- connection works, did var_dump($mysqli->error) error. when logging mysql , describing table 7 rows field type null key default id int(11) no pri null auto_increment username varchar(50) yes uni null password varchar(50) yes null lastloggedin datetime yes null role varchar(20) yes null paswwordchangedate datetime yes null salt

jquery - Image grows with browser width? -

heee, had question; know how can let background image grow browser in terms of width , perhaps height well. mean? have 2 great examples here; 1 http://www.google.com/nexus/7/ 2 http://getbootstrap.com/examples/carousel/ that kinda i'm looking for... image stays centered.. *i don't use bootstrap made own responsive design in css. #heat{ background: url(../img/full.jpg) 50% 0 no-repeat; position: absolute; height: 100%; width: 100%; margin: 0 auto; padding: 0; } just use this..? img { width:100%; height:auto; } jsfiddle example ..

Android dialog box width gets really small when I set a background image for an activity? -

in android project, added background image activity xml file. set style not show title bar on top. activity has button when pressed show dialog box. recently added image , made not show title bar, when went test out, , clicked button, dialog box width 100px. before added background image, dialog box width fine, fills parent. this xml file used dialog box: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/activity_vertical_margin" android:orientation="vertical" > <textview android:id="@+id/textview_email&

java - How to overcome the restriction on the number of input entries allowed by Google? -

i need build java based code can act provider of web scraper automatically extract product review data google play store . output of data extraction should include: product name, maker, description, , every piece of review given product . review should include reviewing author, reviewing date, rating, , review text . trying use following link: https://code.google.com/p/android-market-api/ i have committed them svn , imported project in eclipse java environment. have filled myquery column apps , comments . it restricting amount of information able extract - number of entries coming 50. , if try run again, giving same results again - same apps. therefore, have changed existing modifying setentriescount 10 30, start index 2 2+i , kept in loop, can extract info in loops. there restriction on number of inputs google allows, necessary me create multiple ids, wondering how use them api. ideas? sorry if have missed out info. please let me know if more details needed. please

Switching letters in a string and recieving an index out of range error in Java -

i'm trying write program input sentence, , 2 letters, , switch instances of letters , print out switched sentence. instance, input i eat bananas and “e” , “a,” , program print i lika aet benenes here code, @ end prints out string index out of line. ideas how fix this? system.out.println("write awesome."); string input1 = keyboard.readstring(); system.out.println("pick letter awesome sentence."); char letter1 = keyboard.readchar(); system.out.println("pick letter awesome sentence."); char letter2 = keyboard.readchar(); double let1 = (input1.length()); int let1next = (int) let1; double let2 = (input1.length()); int let2next = (int) let2; string newuserimput = input1.replace(input1.charat(let1next), input1.charat(let2next)); system.out.println(newuserimput); without stack trace, have guess exception on line. string newuserimput = input1.replace(input1.charat(let1next), input1.charat(let2next)); what input1.ch

api - Rounding to decimal point in jQuery -

i pulling 2 objects json response bing maps api , how can trim loc[0] , loc[1] 4 decimal places using jquery ? var loc = result.resourcesets[0].resources[0].point.coordinates; $("#resultscoords").html(loc[0] + ',' + loc[1]); the tofixed function round number digits specify, whether there more or less. example n = 1.0; n.tofixed(2); // returns 1.00 y = 1.1432176452; y.tofixed(2); // returns 1.14 in case, applied following way: var loc = result.resourcesets[0].resources[0].point.coordinates; $("#resultscoords").html(loc[0].tofixed(4) + ',' + loc[1].tofixed(4)); this return 2 results, rounded 4 decimal places.

MS Visual Web Developer Double click VB.NET -

ms visual web developer 2010-vb.net when button double clicked ,i want show controls.how add codes in double click event. thanks based on fact you're using visual studio web developer, i'll assume you're doing browser. if you're not, comment on answer , i'll delete it. asp.net doesn't distinguish between single , double clicks. you'll have use javascript this. you're trying accomplish, you'll have make client-side button ondblclick event calls .click() function of server-side button's rendered <input> element. here's mean: <asp:button id="button" onclick="some_method()" /> <!-- renders this: --> <input type="submit" onclick="..." name="button" id="button" /> knowing (you can check in rendered document), can this: <input type="button" ondblclick="document.getelementbyid('button').click()" ... /> of

c++ - Can I print STL map with cout instead of iterator loop -

#include <string> #include <iostream> #include <map> #include <utility> using namespace std; int main() { map<int, string> employees; // 1) assignment using array index notation employees[5234] = "mike c."; employees[3374] = "charlie m."; employees[1923] = "david d."; employees[7582] = "john a."; employees[5328] = "peter q."; cout << employees; cout << "employees[3374]=" << employees[3374] << endl << endl; cout << "map size: " << employees.size() << endl; /*for( map<int,string>::iterator ii=employees.begin(); ii!=employees.end(); ++ii) { cout << (*ii).first << ": " << (*ii).second << endl; }*/ system("pause"); } i know add in order me print cout << employees; instead of using iterator.because did see code can directly prin

c# - asp.net MVC 4How to capture json data from action and update dropdonwlist -

Image
background: have asp.net mvc4 web application. in page, got drop down list filled file inforamation. try letting user click button, , fire popup window in which, user can enter name , select file upload. similar how upload picture in stackoverflow. once file uploaded completed. in action, return json data include filename , uploaded time. return json(new { error = false, uploadedfilename = filename, uploadedtime = datetimeoffset.now } question: unfortunately, action returns print json data on page. could me 1. how can view capture json data , update dropdown list instead of showing them on page? 2. should use ajax (jquery ajax or ajax.beginform) handle this? thanks regards you can achieve follows: in controller pass json data: return json(new[] { new { id = "value1", name = "name1" }, new { id = "value2", name = "name2" } }, jsonrequestbehavior.allowget); then make , ajax call recive json response , can

c# - How to get the Filename(s) Uploaded using the Ajax Uploader -

i uploading multiple files db using ajax file uploder, need names of files without extension in normal file control.does 1 knows there way filenames uploaded using ajax uploader. had searched in google , seen many sites haven't found helpful links. knows helpful links or code kindly suggest me. you can use request.files files submitted page. e.g. if (request.files.count > 0) { httppostedfile objfile = request.files[0]; string filename = strtick + system.io.path.getfilenamewithoutextension(objfile.filename); string originalname = objfile.filename; }

In WPF, in MenuItem's template, if set Background in IsHighlighted trigger, then Background IsPressed trigger is invalid -

i want menuitem have ismouseover , ispressed status different background, after try times, still failed. submarinex.. menu consists of lots of sub controls.. if want set background colors of menuitems.. need define styles out menu items inner menu items... <grid> <menu ismainmenu="true"> <menu.resources> <!-- outermenu items--> <style targettype="{x:type menuitem}"> <style.triggers> <trigger property="ismouseover" value="true"> <setter property="background" value="red" /> </trigger> <trigger property="ispressed" value="true"> <setter property="background" value="green" /> </trigger> </style.triggers>

html - Image not taking up full width set on parent div -

Image
see fiddle as can see in fiddle there empty space on left side of image. have set image 100% width not taking space. can check hover on it. html <ul class="ulteamlist"> <li class="teamlist"> <img src="http://s21.postimg.org/jpw2o7ofr/image.png"> <div class="overlay"></div> <p>vikas ghodke</p> <p class="tposition">lead developer</p> </li> </ul> css ul.ulteamlist { margin: 0; list-style: none; } li.teamlist { background: #fff; box-shadow: 0px 1px 1px -1px #ccc; float: left; padding:0; display: block; width:40%; margin-bottom: 3%; margin-right: 3%; transition: 0.5s; position: relative; } li.teamlist:hover { background:#0dbca1; } li.teamlist:hover p { color:#fff; } .overlay { width: 100%; height: 210px; background: #fff; position: absolute;

database - SQL QUERY Error :subquery returns more than one row -

i newbie sql , database learning , trying solve following database problem: we have table 2 column name , marks. write query based on table returns grades if marks if greater 700, 'a' if less 700 , greater 500, 'b' or 'c'. main point table has 2 column. here's query: create table class (name varchar(20),marks int); insert class values ("anu",1000),("abhi",100),("mittal",800),("chanchal",1200),("gurpreet",750),("somesh",1000),("sonia",600),("khushbu",450),("rashi",1100),("jyoti",550); select * class; it shows following table: | name | marks | | anu | 1000 | | abhi | 100 | | mittal | 800 | | chanchal | 1200 | | gurpreet | 750 | | somesh | 1000 | | sonia | 600 | | khushbu | 450 | | rashi | 1100 | | jyoti | 550 | select * class grade =(select case when marks >700 "a&quo

Optimize SQL Server Aggregation Query -

i'm looking ideas on how optimize query. i've evaluated execution plan not offer ideas missing index curious if writing query better (different tactics) result in faster/lighter query. select [place], count([place]) ( select scoresid, replace(replace(eventplace1,'t', ''),'*','') [place] [ms.prod]..mso_scores union select scoresid, replace(replace(eventplace2,'t', ''),'*','') [mso.prod]..mso_scores union select scoresid, replace(replace(eventplace3,'t', ''),'*','') [mso.prod]..mso_scores union select scoresid, replace(replace(eventplace4,'t', ''),'*','') [mso.prod]..mso_scores union select scoresid, replace(replace(eventplace5,'t', ''),'*','') [mso.prod]..mso_scores union select scoresid, replace(replace(eventplace6,'t', ''),'

iphone - Stop setKeepAliveTimeout handler from being called after application came foreground? -

for voip application sending ping packet server every 10 minutes using setkeepalivetimeout, works fine, i'm not sure how stop handler being called once application came foreground. eg: here how set timeout [[uiapplication sharedapplication] setkeepalivetimeout:600 handler:^{ [self backgroundhandler]; }]; background handler: - (void)backgroundhandler { printf("10 minute time elapsed\n"); // action... } above function being called after application came foreground, have read in apple documentation set handler nil stop it. have tried below in applicationwillenterforeground [uiapplication sharedapplication] setkeepalivetimeout:600 handler:nil]; still i'm getting call every 10 mins. how handle this, need use flag only. any appreciated. you have invoke clearkeepalivetimeout stop timer. setkeepalivetimeout: designed keep voip connection on , that's why it's periodically called.