Posts

Showing posts from August, 2011

java - Spring Autowired Exception when a remote ejb is down -

hi, have simple question not able solve. i'm using spring 3 lookup remote ejbs , added lazy-init=true bean definition because application must starting if ejb down. unfortunately controller when autowiring of ejb down, "injection of autowired dependencies failed". someone can me! @autowired not lazy? it's possible, using spring, start web application if remote ejb not started?

xml - STS/Eclipse Loading Wrong Spring Beans XSD -

Image
spring tool suite (3.1.0)/eclipse loading wrong version of spring beans xsd, causing xml validation errors. i've got spring-beans 3.2.2.release on classpath maven dependency, , profile attribute of <beans> element should permissable. sadly, flags error. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <beans profile="!cloud"> [...] the following in xml catalog settings, , suggest setting resolution version 3.1.4 of spring beans. i'm not sure how can override dependency maven (that change @ time). if in spring jar see 3.1.4 xsd included in jar. in case suggest adding version number spring-beans.xsd in schemalocation. monkeyed around in xml editor validation, , found helped. with out version nu

w3c validation - document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag -

i getting w3c validation error here mentioned element not allowed appear in context in you've placed it; other mentioned elements ones both allowed there , can contain element mentioned. might mean need containing element, or possibly you've forgotten close previous element. 1 possible cause message have attempted put block-level element (such "<p>" or "<table>") inside inline element (such "<a>", "<span>", or "<font>"). this source code <ul class="link"> <li><a href="" class="selected"><span>1<div class="clr">&nbsp;</div><label>vul postcode in </label></span></a></li> <li><a href=""><span>2<div class="clr">&nbsp;</div><label>restaurants </label></span></a></li> <li><a

javascript - TypeError: Property '$' of object [object Object] is not a function in jQuery 1.7.2 -

i seeing number of these errors in javascript error logs: object expected typeerror: property '$' of object [object object] not function unfortunately, cannot replicate error on of these browsers when try myself. line have highlighted 1 causing error. i have read bit "no conflict" mode , may problem here, can't see issue looking @ code below. i using jquery 1.7.2 , served server, rather cdn: <script type="text/javascript" src="/scripts/jquery/jquery-1.7.2.min.js"></script> my code: $(function() { $('.imgcell').live("mouseenter", function() { if($(this).find('a img').length > 1) { // line throws error $(this).find('a img:eq(0)').hide(); } }); }); it not appear affecting 1 specific browser either, following affected: chrome 26, chromium 25, firefox 10, firefox 14, firefox 16, firefox 20, ie 10, ie 8, ie 9, mobile safari 6

Mysql left join and sum -

i have 3 table , need sum amount separately. use fields on select or clause. select i.*, x.* items left join ( select p.item_id ,sum(p.amount) saleamount ,sum(if(p.type=1,pa.amount,0)) paidamount payments p left join payment_actions pa on pa.payment_id=p.id group p.id ) x on x.item_id=i.id items table; id --- 1 payments table; id | item_id | amount --------------------------- 1 | 1 | 300 payment_actions table; id | payment_id | amount --------------------------- 1 | 1 | 100 1 | 1 | 50 the result should be; saleamount | paidamount -------------------------- 300 | 150 here easy way desired result select i.id, p.amount, pa.amount items left join (select id, item_id, sum(amount) amount payments group item_id) p on p.item_id = i.id left join (select payment_id, sum(amount) a

iphone - Class for iOS like Android.Database.Cursor -

can tell me there class in ios development android.database.cursor in android development. i android app developer , started ios development. have tried googling couldn't decent solution. regards i think can use sqlite3 framework http://www.raywenderlich.com/913/sqlite-101-for-iphone-developers-making-our-app

html - Stop text wrapping -

on following jsfiddle: http://jsfiddle.net/oshirowanen/4fgkj/ here snippet of html have been html post here if posted whole thing: <div id="main"> <div class="inner"> <ul class="column"> <li class="one"> <ul> <li><a href="#" class="link">side menu</a></li> <li><a href="#" class="link">side menu</a></li> <li><a href="#" class="link">side menu</a></li> </ul> </li> <li class="two"> <ul> <li class="main_content"> <p>content goes here</p> </li> </ul> </li>

unit testing - Symfony2 with LiipFunctionalTestBundle error when i load fixture -

i've installed liipfunctionaltestbundle , try use since yesterday i've got error , don't know how solve it. i use basic configuration describe in documentation(config_test) : framework: test: ~ session: storage_id: session.storage.filesystem liip_functional_test: ~ doctrine: dbal: default_connection: default connections: default: driver: pdo_sqlite path: %kernel.cache_dir%/test.sql i create simple test file in bundle, know if db loaded: class adcontrollertest extends webtestcase { public function testindex() { $client = static::createclient(); $this->loadfixtures(array()); $this->asserttrue(true); } } when use $this->loadfixtures(array()); it's works fine, can start off empty database (initialized schema) when replace , try use fixture have error : $this->loadfixtures(array('\blabla\mybunble\datafixtures\orm\loaduserdata')); n

java - open pdf file located in a ressource folder -

i'm trying open pdf located in ressource folder application. work on emulator nothing happens when try on exported application. i'm guessing i'm not using rigth path not see i'm wrong. getressource method works images. here code snippet : public void openpdf(string pdf){ if (desktop.isdesktopsupported()) { try { url monurl = this.getclass().getresource(pdf); file myfile = new file(monurl.touri()); desktop.getdesktop().open(myfile); } catch (ioexception ex) { // no application registered pdfs } catch (urisyntaxexception e) { // todo auto-generated catch block e.printstacktrace(); } } } i'm referring pdf variable way : "name_of_the_file.pdf" edit: i've pasted whole method ok, solved it. file being located in jar, way through inputsteam/outstream , creating temp file. here final code, works great : public void ope

php - MySQL Select box Duplicate - Duplicating one field option but not the other (Queries Identical) -

i creating database upload system - using select box limit number of categories added database. <select name="category"> <?php $conn = mysqli_connect("localhost", "blah", "blah") or die ("no connection"); mysqli_select_db($conn, "upload") or die("db not open"); $query = "select category details group category"; $result = mysqli_query($conn, $query) or die("invalid query"); while($row = mysqli_fetch_array($result)) { echo "<option value=\"" . $row[0] . "\">" . $row[0] . "</option>"; } mysqli_close($conn); ?> </select> <select name="reaction"> <?php $conn = mysqli_connect("localhost", "blah", "blah") or die ("no connection"); mysqli_select_db($co

jquery - IE7 AJAX GET only returning part of response -

i have application can't working in ie 7 (actually, ie 10 running in ie 7 mode). the problem appears when try ajax request using jquery. in newer browsers, response body 30 000 characters of html code, in ie7 response cut short @ 4300 characters. can't find indication ie7's response body has limitation on size. know what's going on? better; know of solution? the server side implementation returns asp.net mvc 4 partial view, if of importance. client side code looks this. $.get(settings.url_root + "?" + params, // typically localhost/getdata?id=1234&id=5678 null, // success function (html) { // html ~4300 chars, should ~30000 }, 'html' ) .fail(function () { // display error message }); try loading relevant parts of document using jquery .load() specifying id of container. refer jquery .load() usage

c# - Know which tab is selected from codebehind -

i have situation: <div id="tabs"> <ul> <li><a href="#tab-1"><span>one</span></a></li> <li><a href="#tab-2"><span>two</span></a></li> <li><a href="#tab-3"><span>three</span></a></li> </ul> </div> and have button <asp:button id="button" runat="server" onclick="button_click" /> my js <script> $(function () { $(".tabs").tabs(); $('.rewrapper').css('width', 'auto'); $('.rewrapper').css('min-width', 'inherit'); }); </script> in codebehind want know tab in , depending on tab save formulary of tab. how know codebehind tab selected? need check first tab selected save 1 information or another, have no idea hot selected tab? thanks i dont

jsp - java String to Date conversion and re-convert date format dd/mm/yy to dd/mm/yyyy -

in application i've set default value in input text box(a jsp file) date.i m fetching oracle database fetches string.so i've convert date.the problem in conversion. picks date '30-apr-2013' .i've convert in date re-convert desire date format 'dd/mm/yyyy'. in webservice write following: @webmethod(operationname = "currenteod") public string currenteod() { string result = null; try{ string sql="select to_char(to_date(max(dat_eod),'dd-mon-yyyy'),'dd/mm/yyyy')"; transactionmanager tm=transactionmanager.getinstance(); try { tm.begin(); result=tm.executescalar(sql).tostring(); system.out.println(result); tm.end(); system.out.println("transaction end..... " ); } catch(exception e) { tm.rollback(); system.out.println("service: " + e);

asp.net mvc - how to pass data from View to as an object Controller using ajax? -

i have search ajax request this: $.ajax({ type: 'post', data: { firstname: firstname, lastname: lastname}, contenttype: "application/json; charset=utf-8", url: 'getpeople', datatype: 'json', } }); in getpeole action can parameter (firstname,lastname) public virtual jsonresult getpeople(string firstname,string lastname) { .... } if change ajax request $.ajax({ type: 'post', data: { firstname: firstname, lastname: lastname,age=age}, contenttype: "application/json; charset=utf-8", url: 'getpeople', datatype: 'json', } }); i must change getpeople public virtual jsonresult getpeople(string firstname,string lastname,int age) { .... } i want searchparameters(firstname,lastname,age) object in getpeople public virtual jsonresult getpeople(searchparam)

javascript - how to calculate the number to increment the variable -

how can calculate missing number, when add variable result equal or greater other variable. promoter: 10 detractor: 2 total: 12 average: 66.67 target: 75 you need ??? promoters reach target. i want find how many promoters need if average less target. how can calculate missing number when add promoter results of average equal or greater target. thank you! function missingnum() { var xpromoter = ''; var x = 10; var y = 2; var target = 75; var z = x + y; var v = ((x - y) / z) * 100; average = math.round(v * 100) / 100; if (average<target) //how increment x average => target document.write("promoter:" + "\n" + x + "<br>"); document.write("detractor:" + "\n" + y + "<br>" ); document.write("total:" + "\n" + z + "<br>" ); document.write("average:" + "\n" + average + &

css - liquid form layout with display:inline-block -

i have got form label container , value container in 1 row , have made fiddle illustrate: http://jsfiddle.net/eeven/3/ the layout fixed , never want value container wrap under label container. since both containers set inline-block can white-space:nowrap list row (see fiddle) , goal partially acomplished. partially, because in value container want text wrap if browser not wide enough hold text in 1 line. thought white-space:normal value container, dosn't work... , reimains in nowrap fashion. what can make work alright? i've solved using css table display (i.e. table-row , table-cell ). solution misbehave in older ie versions . li { display: table-row; } .field_label { display: table-cell; min-width: 140px; background: yellow; } .field_widget { display: table-cell; background: cyan; } solution using css tables http://jsfiddle.net/ecssv/ solution using html tables http://jsfiddle.net/vrhmm/ should work in older ies

CheckedTextView in ListVew - setChecked() does not work for Android 2.3 -

i have listview specifies listselector : <listview android:id="@+id/listview" android:listselector="@drawable/list_selector" android:layout_width="match_parent" android:layout_height="match_parent" /> every list item has checkedtextview : <checkedtextview android:id="@+id/checkedtextview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="checkedtextview" /> i need when clicking on row list, clicked item remain checked, how it: listview.setchoicemode(listview.choice_mode_single); listview.setonitemclicklistener(this); // .... @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { checkedtextview checkedtextview = (checkedtextview) view.findviewbyid(r.id.checkedtextview); checkedtextview.setchecked(true); } it works fine on andr

django - python models.py throwing error -

i updated models.py , getting error.. error thrown: validating models... unhandled exception in thread started <bound method command.inner_run of <django.contrib.staticfiles.management.commands.runserver.command object @ 0x9eb5dec>> traceback (most recent call last): file "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 91, in inner_run self.validate(display_num_errors=true) file "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate num_errors = get_validation_errors(s, app) file "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors (app_name, error) in get_app_errors().items(): file "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors self._populate() file "/usr/local/lib/python2.7/dist-packages/django/db/model

forms - browse file path spring webflow -

i working on spring webflow application. in project there entities point document contains more information entity. document not provided. in case user must able research file himself. i need simple way let user search file , save filepath of selected file database. for of our components use richfaces don't richfaces <fileupload> because it's big , complex. have seen icefaces , tomahawk provide nice solutions our application limited richfaces. thought of using normal: <form:form> <input type="file> </form:form>" but don't know how can information submitted form bean. hoped trigger event once file had been selected , use listener in bean read filename event. cannot find syntax (i don't know if possible). can me? know can richfaces don't think client enormous form select filepath why don't use simple jsp file upload? http://www.tutorialspoint.com/jsp/jsp_file_uploading.htm

Positioning a menu list underneath a textbox with CSS -

i'm struggling css search box , list how want it. want list attached bottom of textbox , have no idea how that. here short of i've got far... <style> ul.drop{display:inline-block;} ul.drop, ul.drop li { list-style: none; margin: 0; padding: 0; background: #ecf1f3; color: #28313f; } ul.drop li.hover, ul.drop li:hover { position: relative; z-index: 599; background: #1e7c9a;} </style> </head> <body> <label for="someinput">search ingredients</label> <input id="someinput"> <ul id="menu" class="drop" style="overflow:auto; max-height:200px;"> <a href="#"><li>ingredient1</li></a> <a href="#"><li>ingredient2</li></a> <a href="#"><li>ingredient3</li></a> <a href="#"><li>ingredient4</li></a> <a href="#"><li>ingredien

javascript - get and append first four images from url -

that's pretty it, how first 4 images whatever url , append them specified element something this: $('document').ready(function(){ var thing = $.get('thing.html'); thing.slice(0,2).appendto(".appending"); }); try this $('document').ready(function () { var thing = $.get('htmlpage.htm', function (markup, b) { var $page = $(markup); $page.each(function (index, item) { if (item.tagname == "img") { $(item).appendto(".appending"); } }); }); });

Enable scaffold in vaadin on grails application -

i creating web-app grails , vaadin, have big problem grails scaffold. after installing vaadin-grails plugin can't access scaffold, try change url mapping without results. someone can me? there no scaffolding vaadin in grails. approach should follow: put domain classes new plugin. create new grails project, reference domain plugin, create controllers scaffolding. create new grails project vaadin , reference domain plugin that means, run 2 grails applications, 1 "administration" scaffolding , second one, "business" people, running vaadin.

xpages - Dojo DataGrid (8.5.3 UP1) Returning Blank Rows - based on Readers field -

trying out dojo datagrid control on alternate xpage (so not impact production) existing view, utilizes readers fields in documents. i've got rest service implemented (xe:viewitemfileservice) , connected dojo datagrid fine (from 8.5.3 up1 controls). i have 2 scenarios of user visibility (via roles in readers field, assigned nab group definition): all documents visible (user a). user can see documents, works fine one. user b can see documents. viewpanel control works fine, once it's in dojo datagrid, has values documents user b should see, remaining x (difference between correctly visible , total document count) rows populated "..." (non-values). inspecting rest service's output via pathinfo yields correct documents user b; take sign , makes me think dojo datagrid what's misbehaving. actual question : how can suppress generation of unnecessary rows? i've tried implement marky roden's approach , got lost on manipulation of how can contro

bash - ssh login verification in perl -

i running following lines of code in perl script find df output of remote machines. works fine , gather info in @df_ret untill until ssh key uptodate. if public corrupted or changed, not showing sign of error in script. if run manually asked password. @df_ret = split /\n/, `ssh -q $server 'df -hp'`; is there way can verify if ssh login successful perl script line should executed else not. been finding many searches on not reach one. help? i have got 1 solution working below; #!/usr/local/bin/perl my $line = `ssh $server -o 'batchmode=yes' -o 'connectionattempts=1' true`; $error = `echo $?`; print "error = $error"; if($error == 0 ) { print "this good"; @df_ret = split /\n/, `ssh -q $server 'df -hp'`; } else { print "this bad"; }

PHP Explode comma separated values with date -

i'm using explode parse string of comma separated values variables. no problem there. issue i'm having 1 of values date in format: may 3, 2013. explode picking on comma in date. have options getting around this? don't have control on source (the original string) i'm trying come way work i've got. $content = 'blue,red,purple,may 2, 2013,orange,green'; list($valuea, $valueb, $valuec, $valued, $valuee, $valuef) = explode(',', $content); thank you! you can use regex split string. based on assumption, there not whitespace between 2 words if used seperator. $content = 'blue,red,purple,may 2, 2013,orange,green'; $result = preg_split('/,(?! )/', $content); your string result correctly in array(6) { [0]=> string(4) "blue" [1]=> string(3) "red" [2]=> string(6) "purple" [3]=> string(11) "may 2, 2013" [4]=> string(6) &q

sql server 2008 - SQL Query randomly stopped working? -

i have sql query provides information ssrs report. report stopped working today , i've checked query , not working either. cant see wrong query wont run. appreciated, need report online today, here error produced: msg 8180, level 16, state 1, line 1 statement(s) not prepared. msg 207, level 16, state 1, line 1 invalid column name 'expr2522'. msg 4104, level 16, state 1, line 1 multi-part identifier "tbl1172.shortdescription" not bound. msg 4104, level 16, state 1, line 1 multi-part identifier "tbl1170.shortdescription" not bound. msg 4104, level 16, state 1, line 1 multi-part identifier "tbl1168.shortdescription" not bound. msg 4104, level 16, state 1, line 1 multi-part identifier "tbl1166.exam" not bound. msg 4104, level 16, state 1, line 1 multi-part identifier "tbl1166.pvhigh" not bound. msg 4104, level 16, state 1, line 1 multi-part identifier "tbl1166.pvach" not bound. msg 4104, level 16, state 1, line 1

c# - Is it possible to copy a 1D array to a 2D array as described and if so, how? -

the example below in c# pulling data texture2d in xna. understanding texture2d.getdata can not used pull data 2d array initially. if 1d array contains values so: 1, 2, 3, 4, 5, 6, 7, 8, 9 is possible copy single dimensional array 2d array 2d array has values so: 1, 2, 3 4, 5, 6 7, 8, 9 my goal copy whole array 1d 2d rather iterating through , calculating indexes. current code this: color[,] texturedatato2darray(texture2d texture) { color[] colors1d = new color[texture.width * texture.height]; texture.getdata(colors1d); color[,] colors2d = new color[texture.width, texture.height]; (int x = 0; x < texture.width; x++) (int y = 0; y < texture.height; y++) colors2d[x, y] = colors1d[x + y * texture.width]; return colors2d; } in copying 1d array 2d array, modular arithmetic friend: color[,] texturedatato2darray(texture2d texture) { color[] colors1d = new color[texture.w

java - How to get custom message from i18n to model -

i set message constraint this import play.i18n.messages; public class user extends model { @constraints.required(message = @messages.get("validation.required")) private string login; but doesn't work. if want specify customized validation message, must create file named messages on conf directory contain customized message first. please check documentation here then, suppose have model following: public class mymodel extends model { @constraints.maxlength(value = 4, message = "validation.limit") @constraints.required @column(name = "column_name") public string columnname; } the messages files contain following: validation.limit=please limit input validation.required=this field required fill notice mark @constraint.maxlength message value "validation.limit" , on messages file specify value of please limit input message. you can find : if input columnname value string length gr

php - SELECT and ORDER BY that column using COUNT from another table -

my scenario this: i have 3 tables structures follows: articles: article_id, more data; tags: tag_id, tag_name, more data; article_tags: article_tag_id, tag_id, article_id each article can have multiple tags. want retrieve tags of article (article_id provided) ordered total number of times tag used. for eg: article1 has tags 'tag4', 'tag3', 'tag2' article2 has tags 'tag4', 'tag3' article3 has tags 'tag4' article4 has tags 'tag4', 'tag3', 'tag2', 'tag1' so when looking tags of article4, should order so: 1. tag4 (4 occurrences) 2. tag3 (3 occurrences) 3. tag2 (2 occurrences) 4. tag1 (1 occurrence) is possible 1 mysql query? retrieving tags of article, array list of tags ordered occurrences, manually sorting former array using later. i think that's select t.tag_name, count(at.*) total tags t join article_tags @ on at.tag_id=t.tag_id t.tag_id in (select tag_id article_tags

javascript - (function(){})() vs. !function(){}() -

this question has answer here: what exclamation mark before function? 7 answers in jquery javascript code see (function(window, undefined) { })(window); and in twitter !function(window, undefined) { }(window); can tell difference between these 2 approaches is? using ! operator before function causes treated expression, can call it: !function() {}() http://jasonlau.biz/home/faq/what-is-the-exclamation-mark-used-for-in-code

r - survival package, right censored data -

i account right censored data in analysis of dataset. using survival package - given cancer treatment tactics , when patient last checked in clients clinic. is there suggested method or manipulation standard survival package account right-censored data? our rows unique individual patients... here our columns filled out: list item our treatment type (constant) days since original diagnosis 'censored' number of patients last heard on day. hence, uncertain if still alive or dead seen stopped attending clinic. should removed probability estimate @ points in future. # of patients died on day (from original diagnosis) so recommend manipulation of standard survival package? or using package? have seen survsnp , survpresmooth , survbivar may perhaps help. want avoid recalculations of individual columns/fields , creating new objects of r algorithm seeing small part of large dataset.

python - Compare two dictionaries with one key in common and form a new dictionary combining the remaining keys associated with this common key -

i have 2 dictionaries, 1 contains name , initial values of registers , other contains name , address values of same registers. i need compare 2 dictionaries on register names [id] , take initial value of register [initvalue] dictionary 1 , address values [addrvalue] dictionary 2 , put them in new dictionary key in new dictionary becomes address rather register name. below doing don't know how merge 2 dictionary keys. regex = "(?p<id>\w+?)_init\s*?=.*?'h(?p<initvalue>[0-9a-fa-f]*)" x in re.findall(regex, lines): init_list = (x.groupdict()["id"], "0x" + x.groupdict()["initvalue"]) regex = "(?p<id>\w+?)_addr\s*?=.*?'h(?p<addrvalue>[0-9a-fa-f]*)" y in re.findall(regex, lines): addr_list = (y.groupdict()["addr_id"], "0x" + y.groupdict()["addrvalue"]) key in set(init_list['init_id'].keys()).union(addr_list['id'].keys()): if init_list[key]

nosql - Can't add index via C# to RavenDB database -

i'm trying create simple index, includes 2 fields document: tracerowid, loaddate. so i've created following class: using model; using raven.abstractions.indexing; using raven.client.indexes; using raven.client.linq; using raven.client.document; using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace indexes { public class idloaddateindex : abstractindexcreationtask<servicetrace> { public idloaddateindex() { map = servicetrace => st in servicetrace select new { id = st.tracerowid, loaddate = st.loaddate }; } } } my model "servicetrace": using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace model { public class servicetrace { public int tracerowid { get; set; } public string statusdescription { get; set;

.htaccess - Yii custom url routing -

i want create friendly urls in yii framework. an example: mysitename.com/country/city/travelling-type or mysitename.com/country/city/travelling-type/price mysitename.com/city/price etc. the problem confuses parameters. tried solve below code, not enough: 'urlmanager' => array( 'urlformat' => 'path', 'appendparams' => true, 'showscriptname' => false, 'usestrictparsing' => false, 'rules' => array( '<country:\w+>/<city:\w+>/<travelling_type:\w+>/<accommodation:\w+>/<caftering:\w+>/<price_from:\d+/<price_to:\d+>' => 'travels/list' ), ), its not easy since yii doesn't know difference between 2 urls: mysitename.com/{city}/{price} mysitename.com/{city}/{accommodation} what can though change route system: '<param1:\w+>/<param2:\w+>/<param3:\w+>

c++ - what is alsa library read value meaning? -

i reading sound values alsa library , return value 40239717. did not understand means. how convert value normal form. my read code this: if ((err = snd_pcm_open (&capture_handle, "default", snd_pcm_stream_capture, 0)) < 0) { qdebug("cannot open audio device default\n"); exit (1); } if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) { qdebug ("cannot allocate hardware parameter structure\n"); exit (1); } if ((err = snd_pcm_hw_params_any (capture_handle, hw_params)) < 0) { qdebug("cannot initialize hardware parameter structure\n"); exit (1); } if ((err = snd_pcm_hw_params_set_access (capture_handle, hw_params, snd_pcm_access_rw_interleaved)) < 0) { qdebug ("cannot set access type \n"); exit (1); } if ((err = snd_pcm_hw_params_set_format (capture_handle, hw_params, snd_pcm_forma

c++ - How do I understand about cpp headfiles -

why headfiles of main.cpp need include .h headfiles contain declaration instead of implementation? can write class in cpp file including both declaration , implementation , include cpp file main.cpp headfile? how can include headfile not in project? technically, header file (or other file decide #include ) can contains absolutely whole makes complete c++ program. what happens when compiler (technically, part of compiler package called "c preprocessor") sees #include "somefile.h" in source-code takes file, , "pastes" main file being compiled. "pretend" preprocessor opening headerfile, marking , pasting main file. the point header files avoid copying , pasting same bit of c++ several source files. example, declaration of class can put header file myclass.h , actual implementation myclass.cpp file, , part of program using myclass need include header. header files not part of project typically surrounded angle brackets, #in

Get words between string of url with php -

i want select specific words of url. let have url localhost/index.php?exam=one&people=two the question, how "one" , "two" php? read preg_match function, still confuse regulation expression pattern. advance $query - parse_url('localhost/index.php?exam=one&people=two', php_url_query); parse_str($query, $keys); print_r(array_values($keys)); // <- want but beware of magic quotes in php < 5.4, parse_str() affected setting

javascript - Replacing images on a page/website that match a pattern -

i need js/jquery (jquery preferred) can replace images on site match specific pattern. on page have images like: img src="http://a248.e.akamai.net/a/262/9086/10h/origin-d9.scene7.com/is/image/default/**a34567_v1**?wid=570&hei=413&fmt=jpeg&qlt=92,0&resmode=sharp2&op_usm=1.1,0.5,1,0" if image src contains "_v1" change character string "_v2". using example above final result be: img src="http://a248.e.akamai.net/a/262/9086/10h/origin-d9.scene7.com/is/image/default/**a34567_v2**?wid=570&hei=413&fmt=jpeg&qlt=92,0&resmode=sharp2&op_usm=1.1,0.5,1,0" this happen multiple times on page. can assist? thanks! since didn't provide multiple examples, cannot tell pattern want use. however, created simplified version regular expressions point in right way: consider html: want change old new. <img src="/old_a.png" /> <img src="/new_b.png" /> <img src="

jquery - onClick Switching Classes issue -

what have <div#graphicsclosebox> nested inside <div#catbox> . it's supposed when click , class changes back. cannot use toggleclass because there form input inside box, clicking form messes things up. $('#catbox').click(function() { $(this).removeclass('cat'); $(this).addclass('cat2'); }); $('#graphicsclosebox').click(function() { $('#catbox').removeclass('cat2'); $('#catbox').addclass('cat'); }); if want example check http://codepen.io/rtro92/pen/mihlu pretty straightforward. know problem in 2nd function, can't target #catbox. thanks! your problem event propagation (a.k.a. "bubbling"), functionality events in 1 dom element "bubbles" parents, unless event told not so. in other words, when clicks <div#graphicsclosebox> , classes correctly added , removed specified. directly after, click event on <div#catbox> triggered, - sin

properties - Silverlight: How do i assign a usercontrol's property value to a textbox? -

i have user control have added outer form in silverlight. user control has textbox called txtroletitle, have declared property in usercontrol's class called lablename , assigned txtroletitle.text labelname shown in code below bellow, in silverlight property panel, under miscellaneous menu, have set labelname "landlord", added 1 of user control outerform , set labelname tenant. not seem work when run silverlight dialogue. value of labelname not appear in textbox during design , run time. here code below. thanks public partial class userroledetails : usercontrol { public string labelname { get; set; } public userroledetails() { initializecomponent(); this.txtroletitle.text = labelname; } } you setting value of txtroletitle.text in constructor, @ point of assignment labelname property not have value. i think need @ making labelname dependency property , binding txtroletitle control in user control's xaml. take @ ex

asp.net - Why would DropDownList.Text is return 0 when it is clearly an empty string? -

i have drop down list binding record sets value=0, text='' the dropdownlist looks fine, not see text in control when try validate in code behind says dropdownlist.text = 0 i not know why control shows no text on form holds value in .text property, doesn't make sense. can help? thanks. i fixed issue having inserting null value along text of '' , dropdownlist.text = '' intead of 0.

c# - why abstract class cannot be instantiated ,what is the use of a class which cannot be instantiated -

i know , read abstract class , interface 1 point never understood that, use of class cannot instantiated. can use normal class , virtual method instead of abstract class? happen when instantiate base class? you typically use abstract class when have set of common functionality shared between derived classes. is, cannot use interface because want provide default functionality. take @ system.io.stream class. class provides common base functionality, requires specific types of streams implement members in order function. these members tagged abstract , indicates compiler , runtime there no suitable base-class implementation. non-abstract class derives abstract class must override inherited abstract members, class implements interface must implement members defined on interface. in stream example, read() method abstract, readbyte() method not -- because readbyte() can implemented in terms of call read() . (although not optimally, why readbyte() virtual, more eff

asp.net mvc - Alternative to using String.Join in Linq query -

i trying use entity framework in asp mvc 3 site bind linq query gridview datasource. since need pull information secondary table 2 of fields getting error linq entities not recognize method 'system.string join(system.string, system.collections.generic.ienumerable'1[system.string])' method, , method cannot translated store expression. i able without creating dedicated view model. there alternative using string.join inside linq query? var grid = new system.web.ui.webcontrols.gridview(); //join in db.banklistagentid on b.id equals a.bankid var banks = b in db.banklistmaster b.status.equals("a") select new { bankname = b.bankname, epurl = b.epurl.trim(), associatedtpmbd = b.associatedtpmbd, fixedstats = string.join("|", in db.banklistagentid a.bankid == b.id && a.fixedorvariable.equals("f")

c# - PowerShell enum value that represents all -

given current enum : add-type -typedefinition @" [system.flags] public enum flagsenum { none = 0, summaryinfo = 1, reportoptions = 2, parameterfields = 4 } "@ is there way create entry sets bits 1? syntax causes errors: add-type -typedefinition @" [system.flags] public enum flagsenum { none = 0, summaryinfo = 1, reportoptions = 2, parameterfields = 4, = (summaryinfo -bor reportoptions -bor parameterfields) } "@ ** edit ** changed declaration: add-type -typedefinition @" [system.flags] public enum flagsenum { none = 0, summaryinfo = 1, reportoptions = 2, parameterfields = 4, = (summaryinfo | reportoptions | parameterfields) } "@ the code: $flags = [flagsenum]::all if ( $flags -band [flagsenum]::summaryinfo ) { write-host "add summaryinfo" } if ( $flags -band [flagsenum]::reportoptions ) { write-host "add rep

Using erb inside erb at Ruby on Rails -

using modified version of http://railscasts.com/episodes/30-pretty-page-title easier page heading , title. every page gets <% title "insert heading here" %> . via helper def title(page_title) content_for(:title) { page_title } end i can use page title , headings of single pages. also want modify view of devise setup, got stuck @ user edit page. standard heading <h2>edit <%= resource_name.to_s.humanize %> </h2> . tried obvious <% title "edit <%= resource_name.to_s.humanize %>" %> but dont work. any idea or suggestions? in advance dennym how <% title "edit #{resource_name.to_s.humanize}" %>? when using double quotes can parse ruby inside #{} blocks inside of string. won't work when using string single quotes (') double (").

python - Importing the `this` module? -

typing following in a python shell not produce error: from import * what this module? this zen of python written tim peters >>> import * zen of python, tim peters beautiful better ugly. explicit better implicit. simple better complex. complex better complicated. flat better nested. sparse better dense. readability counts. ..... >>> d {'a': 'n', 'c': 'p', 'b': 'o', 'e': 'r', 'd': 'q', 'g': 't', 'f': 's', 'i': 'v', 'h': 'u', 'k': 'x', 'j': 'w', 'm': 'z', 'l': 'y', 'o': 'b', 'n': 'a', 'q': 'd', 'p': 'c', 's': 'f', 'r': 'e', 'u': 'h', 't': 'g', 'w': 'j', 'v': 'i', 'y': 'l'

postgresql - SQL window functions: Performance impact of returning the same avg() many times? -

i select bunch of rows table a, along results of aggregate functions avg(a.price) , avg(a.distance). now, select query takes bit of time, don't want run 1 query rows, , other averages. if did that, i'd running query select appropriate rows twice. but looking @ postgresql window function documentation ( http://www.postgresql.org/docs/9.1/static/tutorial-window.html ), seems using window function return results of aggregate functions want use alongside returned rows means every single row returned contain results of aggregate functions. , in case, since aggregation on rows returned main select query , not subset of rows, seems wasteful. what performance implications of returning same avg() many times, given i'm selecting subset of rows in doing aggregate queries across entire subset? in particular, postgres recompute average every time, or cache average somehow? by way of analogy: if @ window function docs , pretend depname 'develop' every row returned se

apache - MOD REWRITE (BASE) on WAMP Server -

i have wamp webserver rewrite module activated. i have projects in: d:/prj/costumer1/www/ (alias: costumer1) d:/prj/costumer2/www/ (alias: costumer2) , on... for costumer1 have .htaccess-file works fine. looking this: rewriteengine on rewritebase /costumer1/ rewriterule ^([^/\.]+)/?$ index.php?a=$1 [qsa] rewriterule ^([^/\.]+)/?/([[a-za-z0-9_-]+)$ index.php?a=$1&b=$2 [qsa] rewriterule ^([^/\.]+)/?/([[a-za-z0-9_-]+)/?/([[a-za-z0-9_-]+)$ index.php?a=$1&b=$2&c=$3 [qsa] now when create src/href-link have use: /costumer1/search/book/novell (aka: costumer1/?a=search&b=book&c=novell) instead of /search/book/novell (aka: costumer1/?a=search&b=book&c=novell) so in short: i don't want write "/costumer1" in front of every link: <a href="/costumer1/search/">search</a> i have done in root .htaccess rewritecond %{http_host} ^customer1$ [nc] rewritecond %{request_uri} !^/customer1 rewriterule ^(.*

windows installer - MSI Validation returns "ICE81 Failure ICE Internal Error 1867. API Returned: 1615." -

all of msi installations display same ice81 "failure" during validation can't figure out causing it. happens no matter msi editor use run validation (ms orca, flexera installshield, instedit.com). installation packages use external cab files located in correct place (same folder msi file) , cab files signed same digital signature msi file signed (and records in media, msidigitalcertificate, msidigitalsignature, , msipatchcertificate tables appear correctly authored). ice81 failure ice internal error 1867. api returned: 1615. msieditor_full_path\darice.cub ice81 failure error 2228: c:\users\my_user_name\appdata\local\temp\random_tmp_filename.tmp, feature_name, select `diskid`, `cabinet` `media` (`diskid` = cab_name.cab) msieditor\darice.cub any ideas? the error error_bad_query_syntax means "the sql query syntax invalid or unsupported." so, internal sql query ice making validate msi failing. looking @ query part can failing query: where