Posts

Showing posts from July, 2014

java - Store primitive values in an EnumMap -

why can't create enummap this: enummap<funkytrolls, int> amountmap; i want count , save number of trolls of each type. way of doing this? just use integer . generics work on objects, not on primitive types, java has auto-boxing , -unboxing. this should work: map<funkytrolls, integer> amountmap = new enummap<funkytrolls, integer>(); amountmap.put(funkytrolls.very_funky_troll, 100);

forms - Javascript - Get Select(Value) to evaluate -

there 10 different pins need status for. <select> <option value="on" id="p1statuson" name="pin1status">on</option> <option value="off" id="p1statusoff" name="pin1status">off</option> </select> javascript - trying value of pin 1-10 array evaluate later see if enabled or disabled var e = []; (var i=1;i<=10;i++){ e[i] = document.getelementbyid("p" + + "_status"); } then once value, can run validation scripts on other inputs. i have tried ask earlier, quite far off mark trying do. learning javascript , have been trying figure out issue majority of day. thank you! well, getting p1_status when id p1status ... , that's element, seem want selected item? try this: <select id="p1status" name="pin1status"> <option value="on">on</option> <option value="off">off...

c# - Binding recursive treeView -

i'm developping windows form application on visual sudio , first time treeview. project has ado .net entity data model of , sql database, have 3 tables relations: category ( idcategory, namecategory ) subcategory ( idsubcategory, namesubcategorie, idcategory ) articles ( idarticle, namearticle, idsubcategory ) i'm trying create treeview recursion database result below, i'm stuck here can me please? here want show: +category1 +subcategory1-1 article1 article2 article3 +subcategory1-2 article1 article2 article3 +subcategory1-3 article1 article2 article3 +category2 +subcategory2-1 article1 article2 article3 +subcategory2-2 article1 article2 article3 +subcategory2-3 article1 article2 article3 a template code binding recursive treeview database usinf linq or tutorial link shows how helpfull! thanks. i think might you, here popu...

mysql - Multi_query PHP MySQLi -

function search_admin($q) { $db = load_db(); $sql = "select keyword keyword keyword = '%{$q}%'"; $sql .= " select title, status title concat(title, ' ', status) '%{$q}%'"; $sql .= " select first_name, middle_name, last_name, cbemail employees concat(first_name, ' ' , middle_name, ' ' , last_name , ' ' , cbemail) '%{$q}%'"; $sql .= " select username users username = '%{$q}%'"; $result = $db->multi_query($sql); // missing code } i can't seem understand explanation in php manual. hope can englighten me more. search bar, if example search "pending". code search on 3 tables title, employees , users. output results. problem after result query :/

asp.net - Viewstate move session generate an error as 'The state information is invalid for this page and might be corrupted. ' -

i have created web page rad grid. within provide facility filtering ,shorting, grouping , paging . because of performance issue have tried move viewsatate session. there have set enable viewsate false in webpage , added bellow code page. protected override object loadpagestatefrompersistencemedium() { return session["viewstate-" + request.url.absolutepath]; } protected override void savepagestatetopersistencemedium(object state) { session["viewstate-" + request.url.absolutepath] = state; clientscript.registerhiddenfield("__viewstate", ""); } but when thing on rad grid generate bellow error the state information invalid page , might corrupted. if using asp.net 2.0 or higher, microsoft has built-in functionality viewstate in session. should use maximum compatibility. just put in .cs file protected override pagestatepersister pagestatepersister { { ret...

What does module function do in AngularJS? -

in project of vojta testing directives code ? // load tabs code beforeeach(module('tabs')); it says loads tabs code but, why ? isn't tabs module defined next here ? var tabs = angular.module('tabs', []); can 1 give brife explanation of should loaded why , how in angular test ? i tried call function in tests, beforeeach(module('utils')) ; and error : typeerror: property 'module' of object [object object] not function also when try load templates beforeeach(module('templates/loadingbar.html')); i error : error: no module: templates/loadingbar.html i confused whole process. thanks helping ... the code listed var tabs = angular.module('tabs', []); creates tabs module, in order load put ng-app="tabs" on element in dom. instructs angular load tabs module , make definitions available injector app uses resolve dependencies. (see bootstrap guide more information.) in ...

android - Display Contact,Logs and Favourite Contact in Listview in Single Activity -

i want create contact activity contains 3 tabs 1) contact address 2) contact logs (recently used) 3) favourite contact ( used) please tell me how achieve tabs should contain listview display contact thanks in advance for tutorial on creating tabs using fragment, this website can help. for listview , can use this . thing take note of need class extend listfragment instead of fragment . hope helps =)

asp.net - Rearrange child repeaters within a parent repeater -

i have set of nested repeaters structure this: repeater repeater a-1 repeater a-2 repeater a-3 repeater b repeater b-1 repeater b-2 repeater b-3 i want dynamically rearrange child repeaters within parent repeater @ run-time. example, based on user configuration, might want change order of repeater a's children 2,3,1. i'm open either server or client-side solution. i argue client side jquery approach. avoid postbacks, 1990's these days. if able wrap repeater content sort of container element , supply them id attributes write reusable jq function rearranging you. asp.net code: (you have similar) <asp:repeater datasource="<%#source%>" runat="server"> <itemtemplate> <div id="containera"> <asp:repeater datasource="<%#container.dataitem%>" runat="server"> <itemtemplate> <div id="a-<%# bind("c...

c# - How can pass a struct through multiple namespaces without 'using' them? -

this kind of simple problem (or maybe not) i'm caught on. have application testapp uses ui library i'm working on in turn uses graphics library (sharpdx). now sharpdx provides color struct (sharpdx.color). , window class (ui.window) accepts sharpdx.color struct clear rendertarget. however, when using ui library, sharpdx namespace isn't available. causes problem color isn't available. so possible make color available in ui namespace, avoiding need have references sharpdx in project uses ui library. thanks. as far aware, use part of library, need use entire library (unless author has broken down submodules). if using ui library, how can pass sharpdx.color without using sharpdx? if wish use part of library can split off components depend on sharpdx rest. alternatively, can make own color struct, , translate between ui.color , sharpdx.color @ intersection between ui , sharpdx code.

python - django website: As i logged out, but click on the browser backspace arrow, it display the former webpage -

the web backend written in django. logged out, click on browser backspace arrow, display former webpage; code: def safe_exit(request): #print request if 'uname' in request.session , 'uid' in request.session: del request.session['uname'] del request.session['uid'] del request.session['logged_in'] #return render_to_response('reader/login.html',{}) return httpresponseredirect('/') what want : should redirect login page. how achieve this, have tried use ajax user's login status, it's work, because after click on backspace arrow, use firebug listen on network, didn't send http request @ all.

Equivalence Classes in software testing -

i new software testing , studying basic techniques. read following problem: identify equivalence classes following specification: program accepts 5 9 inputs 3 digit integers greater 100. i think doesn't matter how inputs program has, , equivalence class {99,100,101}. right or not? after comments, think classes are: 1.(-00,99) 2.[100] 3.(101,999) 4.(1000,+00) inputs: 0-4 inputs 5-9 inputs more 9 inputs values: 0-100 101-999 greater 999 the program accepts when there between 5 , 9 inputs , each input value 3-digit number between 101 , 999.

css - Draw a crescent moon using SVG in HTML -

Image
is possible draw crescent moon using svg in html? i've been trying things out @ w3 schools don't see example of this. don't need of shading see in typical google images of 'crescent moon', solid border crescent moon. please note solution might not best. not expert when comes vector graphics , should other solution the approach took draw image same background. like: to eliminate border draw circle above it now set 3rd image border white like: if not using borders need use 2 circles you might wanna take @ clipping , masking . might better approach. <!doctype html> <html> <body> <h1>my first svg</h1> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" /> <circle cx="115" cy="50" r="30" stroke="bla...

c++ - Large POD as tuple for sorting -

i have pod 30 members of various types , wanting store thousands of pods in container, , sort container 1 of members. for example: struct person{ int idnumber; ....many other members } thousands of person objects want sort idnumber or other member choose sort by. i've been researching while today , seems efficient, or @ least, simplest, solution not use struct @ all, , rather use tuple can pass index number custom comparison functor use in std::sort . (an example on this page shows 1 way implement type of sort easily, on single member of struct make templating not easy since must refer member name, rather index tuple provides.) my two-part question on approach 1) acceptable tuple large, dozens of members? , 2) there equally elegant solution continuing use struct instead of tuple this? you can make comparator stores pointer member internaly knows member take comparison: struct pod { int i; char c; float f; long l; double ...

.net - sitecore comments list to article -

i need add function of comments blog. have article. , need after article comments section. maybe i'm stupid don't know how solve that... can tell me ideas or send url examples of this? i use sitecore build articles in sections , xslt build view of articles. sample xsl:template article: <xsl:template match="*" mode="main"> <xsl:variable name = "siteroot" select="ancestor-or-self::item[sc:isitemoftype('articlepage',.)]"/> <div> <h2> <sc:html select = "$siteroot" field="article_title"/> </h2> <h6> <sc:html select="$siteroot" field="article_date" /> </h6> <sc:html select = "$siteroot" field="article_content" /> <br /> <div class="commentregion"> comments must here </div> </div> </xsl:template>

java - setting ttf for PDF to Image on PDFbox -

i'm trying set external ttf , able render image out of pdf containing arabic caracters , font need set "arial" , having done console keeps on informing it's using defaultfont instead of arial. org.apache.pdfbox.pdmodel.font.pdsimplefont drawstring attention: changing font on <3> <arial> default font here's code : import java.awt.image.bufferedimage; import java.io.file; import java.io.ioexception; import java.util.iterator; import java.util.list; import java.util.map; import javax.imageio.imageio; import org.apache.pdfbox.pdmodel.pddocument; import org.apache.pdfbox.pdmodel.pdpage; import org.apache.pdfbox.pdmodel.pdresources; import org.apache.pdfbox.pdmodel.edit.pdpagecontentstream; import org.apache.pdfbox.pdmodel.font.pdfont; import org.apache.pdfbox.pdmodel.font.pdtruetypefont; import org.apache.pdfbox.pdmodel.font.pdtype1font; import org.apache.pdfbox.pdmodel.graphics.xobject.pdxobjectimage; public class pdfboxtest { ...

sqlprofiler - Se SQL statetement beeing run within a procedure with SQL Server Profiler -

this not directly programming question ask anyway because it's related debugging . i wonder if it's possible see sql statements being executed within procedure in microsoft sql server profiler? for see procedures being called due complicated procedures causing tricky bug somewhere see sql statement being executed. nice if has tip on this. yes possible. add sp:stmtstarting and/or sp:stmtcompleted events tracing.

php - How to update this query with 2 data arrays for WHERE condition -

hi have 2 data arrays , $lob_array = array(200,201,300); $preference_array = array(500,501,502,503,504,505); i have table rating it has fields rating_id | lob_id | preference_id | average_rating | is_delete i want update is_delete column values according data array . i want compare each lob value $preference_array update rating set is_delete = 1 (lob_id=$lob_array[0] , preference_id in (".implode(',',$preference_array).")) ) or (lob_id=$lob_array[1] , preference_id in (".implode(',',$preference_array).")) ) or (lob_id=$lob_array[0] , preference_id in (".implode(',',$preference_array).")) ) how can , please , because don't know number of elements in $lob_array in advance. would work? update rating set is_delete = 1 (lob_id in (".implode(',',$lob array).") , preference_id in (".implode(',',$preference_array)."));

c# - Adding a button to the last column of a GridView -

this how created grid view in asp.net c# project. grid has 4 columns. want add 5th column , add button on each , every row. how can ? <asp:gridview id="gv" runat="server" cellpadding="1" width="900px"/> set autogeneratecolumns="false" in gridview markup define columns boundfield (or templatefield if wish) add a templatefield button in last column sum up: <asp:gridview runat="server" id="gv" autogeneratecolumns="false" cellpadding="1" width="900px"> <columns> <%-- <asp:boundfield /> definitions here --%> ... <asp:templatefield> <itemtemplate> <asp:button text="click me" runat="server" id="btn" onclick="clicked" /> </itemtemplate> </asp:templatefield> </columns> </asp:...

php - Yii sql generation -

i trying prepare following sql query unfortunately did not work. select course.course_name, enroll.start_date dp_courses course left outer join dp_enroll enroll on course.id = enroll.course_id , enroll.student_id=3 $criteria=new cdbcriteria(array( 'order'=>'update_time desc', 'with'=> array('enroll'), )); $criteria->alias = 'course'; $criteria->together=true; $criteria->join='left outer join dp_enroll on dp_enroll.course_id=course.id , dp_enroll.student_id='. yii::app()->user->id; //$criteria->condition='dp_enroll.student_id='. yii::app()->user->id; relation in course model is: public function relations() { return array( 'enroll'=> array(self::has_many, 'enroll', 'course_id'), 'author' => array(self::belongs_to, 'yumprofile', 'author_id...

Ruby on rails - paperclip not saving to database -

i'm trying make create product page in rails. includes adding multiple images. have 1 model products 1 photos , users. i'm using paperclip gem photo upload. have 2 problems. my file input not allowing me select multiple images when view product no pictures show because pictures are not being saved database p.s. use haml , dont have photo controller. products controller class productscontroller < applicationcontroller before_filter :current_user, only: [:create, :destory] before_filter :correct_user, only: :destory def new @product = product.new @photo = photo.new 5.times { @product.photos.build } end def create @photo = current_user.photos.build(params[:photo]) @product = current_user.products.build(params[:product]) if @product.save render "show", :notice => "sale created!" else render "new", :notice => "somehting went wrong!" end end def show @product =...

c# - MVC-4 FileUpload success message -

i having few problems displaying success message after file has been uploaded. i first tried using viewbag.message , , works , display success message after file has been uploaded, want. cant find way on how , after few seconds change message to: "choose file upload !" , user understand can upload new file. i tried implement javascript feature handle success message instead. problem success message shows before file upload completed, no good, , if small file, message show millisecond. do have suggestion on how can fine tune ? im not sure if should try work further using javascript or viewbag, or different ? what looking success message display around 5 seconds after successful upload, changes "choose file upload message" again. https://github.com/xoxotw/mvc_fileuploader using system; using system.collections.generic; using system.io; using system.linq; using system.threading; using system.web; using system.web.mvc; namespace mvc_fileuploader.con...

installer - Using install shield from CLI ,is it possible? -

i have existing install shield 2009 projects , every time want create newer version of them perform specific tasks want automate script. this operations have perform manually change guid point updated packages build single_exec_image is possible make operations cli on installshield 2009? thank in advance installshield has automation interface (32bit com based). can use api make programmatic changes installer project. installshield supports command line builds using iscmdbld.exe . typically of in realm of build automation using msbuild or nant. both allow write custom tasks in c# can interop com automation interface. for example use tfs uses msbuild (which installshield has native support via .isproj files ) build installer. in scenario can use dynamic properties in msbuild generate guid , can use path variable overrides point source. build target builds installer. a bunch of ways skin cat depending on environment.

java - XStream Element contains TextNode and Element -

i using xstream parse xml , goes while.... there situation xstream seem can't handle it. there's 1 tag named "", in different xml file, can contain text node or other xml tag. it can this: xml file 1: <spec> text node here </spec> xml file 2: <spec id="1"> <tag1>value</tag1> <tag2>value</tag2> </spec> and in spec class, have code... @xstreamalias("spec") @xstreamconverter(value = toattributedvalueconverter.class, strings = { "spec" }) //when text node public class spec { string spec; // text node @xstreamalias("id") @xstreamasattribute string id; @xstreamalias("tag1") string tag1; @xstreamalias("tag2") string tag2; // getter , setter... } in case of xml file 1, works fine, in case of xml file 2, values of fields "tag1" , "tag2" null, , value of field "spec" :...

c# - Can you get Method name that threw Exception? -

is there c# method returns upper-most caller, name of my method threw exception, if actual exception thrown (e.g. database driver errors when method calls it) ? caller -> mymethod -> dbdriver(error) i want "mymethod", not "dbdriver" i'd rather not re-throw exceptions way chain. my current kludge, iterate through stacktrace frames, , parse out method using methodbase.getcurrentmethod().declaringtype . is there built-in method information or more elegant solution? thanks! use exception.targetsite property method name gets method throws current exception.

javascript - Update a Gridview from a JQuery Slider -

i trying use jquery ui slider update gridview in visual studio. can tell me how use postback or other function achieve this. time. jquery ui slider <script> $(function () { $("#sliderrange1").slider({ range: true, min: 0, max: 2500, step: 100, values: [0, 2500], slide: function (event, ui) { $("#amount").val("mw " + ui.values[0] + " - mw " + ui.values[1]); $("#minval").val(ui.values[0]); $("#maxval").val(ui.values[1]); }, stop: function (event, ui) { } }); $("#amount").val("mw " + $("#sliderrange1").slider("...

java - PrintServiceLookup.lookupPrintService solution in JBoss AS 7 -

i trying print pdf document jsf web application. when call method findprinter() main method, printservices found, when call method web page printservice not found. code mentioned below.. public static void main(final string[] args) throws exception { printtest printtest = new printtest(); printtest.findprinter(); } public void findprinter() { printservice[] printservices = printerjob.lookupprintservices(); system.out.println("print services length :: " + printservices.length); (printservice printservice : printservices) { system.out.println("printservice :: " + printservice); } <h:form> <p:commandbutton value="print" action="#{printtest.findprinter()}"/> </h:form> any suggestions... add tag in modules/sun/jdk/main/module.xml of jbossas mentioned: path name="sun/print" open resources.jar jre, , extract meta-inf/services/javax.print.printservicelook...

php - Codeigniter get all rows from db -

i'm working on task manager have 2 types of user: administrators(all privileges), , users(limited privileges). here's task function in controller function task($id) { $data = array( 'query' => $this->main_model->get_task($id), 'task_id' => $id, ); $data2['comments'] = $this->main_model->get_comments($id); $this->load->library('form_validation'); $this->load->helper('security'); $this->form_validation->set_rules('comment_text', 'comment_text', 'trim|required|strip_tags|xss_clean'); if ($this->form_validation->run() === false) { if($this->main_model->get_task($id)) { foreach ($this->main_model->get_task($id) $tas) { $data = array( 'title' => $tas->task_name, 'desc' => $tas->task_d...

How to returns the array of DOM nodes in google map V3 api? -

how returns array of dom nodes hold content of tabs of info window in google map v3 api? i migrating google map version v2 v3 . in v2 using these type of codes array of dom nodes hold content of tabs of info window. below code google map v2 code. if (!div) return; var link = div.down('a.jsdetailslink'); if (!link) return; link.href = '/ajax/?action=profileinfofull&id=' + location.id; new facebox(link); how use in v3, [object htmldivelement]? please help.!!

Google Like Pagination using Jquery -

here have <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> <li>10</li> <li>11</li> <li>12</li> <li>13</li> <li>14</li> <li>15</li> <li>16</li> <li>17</li> <li>18</li> <li>19</li> <li>20</li> </ul> initally showing 10 li's, when user comes 10th page need hide visible 10 li's , show next 10 li's , should work in vice versa using jquery ... pagination in google .. i have tried below code : var currentindex = $("div#pagination ul").children('li:visible').eq(-2).index(); var nextindex = currentindex + 10; $("div#pagination ul li:not(':first'):not(':last')").hide(); $('div#pagination ul li:lt(...

Numpy savetxt loop -

using numpy, going split array of dimension (557124,2) , dtype = "s10" , in 6 subarrays using: sub_arr = np.split(arr, 6) now use for loop on savetxt , save 6 subarrays 6 .txt files. i tried: for in sub_array: np.savetxt(("subarray", i, ".txt"), sub_array[i], fmt='%s') there 2 problems: it's incorrect in sub_array . should use range(5) want make adaptable number of sub arrays. i thought use sort of "paste" in r when did ("subarray", i, ".txt") . there alike in numpy? any idea? from i've understood sub_arr = np.split(arr, 6) returns list of 6 numpy arrays. can use enumerate each array , index fname_template = "subarray.{i}.txt" i, sarr in enumerate(sub_arr): np.savetxt(fname_template.format(i=i), sarr, fmt='%s') to create file name i've used new string formatting . otherwise can concatenate strings + "subarray."+str(i)+".txt...

How to convert RGB from YUV420p for ffmpeg encoder? -

i want make .avi video file bitmap images using c++ code. wrote following code: //get rgb array data bmp file uint8_t* rgb24data = new uint8_t[3*imgwidth*imgheight]; hbitmap = (hbitmap) loadimage( null, _t("myfile.bmp"), image_bitmap, 0, 0, lr_loadfromfile); getdibits(hdc, hbitmap, 0, imgheight, rgb24data , (bitmapinfo*)&bmi, dib_rgb_colors); /* allocate encoded raw picture. */ avpicture dst_picture; avpicture_alloc(&dst_picture, av_pix_fmt_yuv420p, imgwidth, imgheight); /* convert rgb24data yuv420p , stored array dst_picture.data */ rgb24toyuv420p(imgwidth, imgheight, rgb24data, dst_picture.data); //how implement function? //code encode frame dst_picture here my problem how implement rgb24toyuv420p() function, function convert rgb24 data array rgb24data yuv420p , store array dst_picture.data ffmpeg encoder? you can use swscale something this: #include <libswscale/swscale.h> swscontext * ctx = sws_getcontext(imgwidth, imgheight, ...

Using javascript and node.js how to post the content to the text file through ajax -

using javascript , node.js how post content text file through ajax. <html> <body> <input type="button" value="click me" onclick="postcontent()"> <script> function postcontent(){ var req=new xmlhttprequest(); req.open('post','addcontent.js',true);//in sample.txt file want insert content req.send(); } </script> </body> </html> addcontent.js var fs = require('fs'); fs.writefile("/tmp/sample.txt", "hey there!", function(err) { if(err) { console.log(err); } else { console.log("the file saved!"); } }); you can have server-side script writes content text file , call server-side script using ajax. req.open('post', 'fileposter', true); req.send(datatowrite); edited new question: req.open('post','addcontent.js',true); addcontent.js should http s...

jquery - load google charts through an ajax call -

i'm trying call google chart after clicking on link. function looks like: function getgraphdata(id) { var ajax_url = '<?=url?>ajaxlibrary/get-graph-data'; $.ajax({ type: 'post', url: ajax_url, datatype: 'html', data: ({ id : id }), cache: false, success: function(data) { $('a').removeclass("selected"); $('#link_'+id).addclass("selected"); alert(data); }, }); } so i'm trying achieve here load different graph different like, lets have politics charts, sports charts etc. don't know put google api code though, because seems it's not working... edit: edited function this: $.ajax({ type: "post", datatype: "html", data: {id: id}, url: '<?=url?>' + 'ajaxlibrary/get-charts', success: function...

c# - kentico API - Grouping Roles using membership -

within kentico administration area, there facility group 'roles' using 'membership' feature. have built 'custom role provider' allows me access kentico database through api, working , correct. the api allows me access roles of user fine, ideally access 'memberships' instead , 'roles' associated through api. when authenticating users access page/link etc have call group name , search through mappings find associated 'role', grant or deny access. is there way in api this, need create custom sql string , execute against database extract data need? there no out-of-box functionality that. have utilize offered info objects , providers. have created short sample code understand concept. // user name userinfo user = userinfoprovider.getuserinfo("testuser"); // user-role bindings user's identifier infodataset<userroleinfo> userroles = userroleinfoprovider.getuserroles("userid=" + us...

c# 4.0 - Textbox focus does not work when focus by mouseclick wpf -

when click on text box mouse focus not display. , when goes textbox keyboard focus displayed. trying below code. please can 1 suggest me how solve issue. <style x:key="textboxfocusvisualstyle" > <setter property="control.template"> <setter.value> <controltemplate> <image source="/mit;component/resources/txtfocus.png" stretch="fill" margin="-8,-6,-8,-6"/> </controltemplate> </setter.value> </setter> </style> <textbox grid.column="2" height="44" margin="20,48,0,0" name="txtemailid" verticalalignment="top" keyboardnavigation.tabindex="2" maxwidth="400" horizontalalignment="left" width="350" text="" focusvisualstyle="{dynamicresource textboxfocusvisualstyle}" verticalcontentalignme...

android - Set contentDescription for ActionBar's up button -

i'm trying customize "navigate up" default contentdescription associated button of actionbar (i'm using actionbarsherlock). from actionbarview 's source: public void sethomebuttonenabled(boolean enable) { mhomelayout.setenabled(enable); mhomelayout.setfocusable(enable); // make sure home button has accurate content description accessibility. if (!enable) { mhomelayout.setcontentdescription(null); } else if ((mdisplayoptions & actionbar.display_home_as_up) != 0) { mhomelayout.setcontentdescription(mcontext.getresources().gettext( r.string.abs__action_bar_up_description)); } else { mhomelayout.setcontentdescription(mcontext.getresources().gettext( r.string.abs__action_bar_home_description)); } } so key how reference mhomelayout . getwindow().getdecorview().findviewbyid(android.r.id.home) not working, it's returning imageview. how do? thanks ;) here h...

c# - Can we change the masterpage dynamically based on condition -

this question has answer here: can change nested master page's master dynamically? 4 answers i have 2 master pages in project. based on role want use 1 of master page. the master page changed in preint event protected void page_preinit(object sender, eventargs e) { try { if (conduction1) this.page.masterpagefile = "~/masterpage.master"; else this.page.masterpagefile = "~/master.master"; } catch (exception ex) { } }

mysql - Select row where SUM becomes greater than X -

i have table ---------------- id | duration ---------------- 1 10 2 10 3 10 i want select id sum(duration) becomes greater 15. in other words... ------------------------- id | duration | sum ------------------------- 1 10 10 2 10 20 3 10 30 sum becomes grater @ row id 2. have select row. of course can't use sum() stored procedure sure have use join , having instead of where. problem wrong result. to this, need cumulative sum, mysql not offer directly. can subquery. select right row. select id, duration, cumdur (select id, duration, (select sum(duration) t t2 t2.duration < t.duration or (t2.duration = t.duration , t2.id <= t.id) ) cumdur t ) t 15 between (cumdur - duration + 1) , cumdur note orders id when multiple rows have same duration.

c - comparison of signed and unsigned numbers -

this question has answer here: comparison operation on unsigned , signed integers 5 answers here question shown below , answers comes true.i know there promotion happen when compare signed , unsigned.can please tell me how signed value gets promoted? main() { signed int = -5; unsigned int b = 2147483648; if(a > b) printf("true\n"); else printf("false\n"); } advanced maddy try printing out converted value , see goes on: int main(int argc, char **argv) { signed int = -5; unsigned int ua = a; unsigned int b = 2147483648; printf("a=%d ua=%u b=%u\n", a, ua, b); if(a > b) printf("true\n"); else printf("false\n"); } prints a=-5 ua=4294967291 b=2147483648 true share , enjoy.

Java Reflection in android -

this typeface class public class typeface { public static final typeface rupee(context ctx){ typeface typeface = typeface.createfromasset(ctx.getassets(), "rupee_foradian.ttf"); return typeface; } public static final typeface arialrounded(context ctx){ typeface typeface = typeface.createfromasset(ctx.getassets(), "rupee_foradian.ttf"); return typeface; } } and try access methods class using reflection following way method method; typeface typeface; try{ method = typeface.getclass().getmethod("rupee",context.class); }catch(exception e){ system.out.println("method : "+e); } but throws nullpointerexception . 05-21 17:12:07.026: i/system.out(14917): method : java.lang.nullpointerexception i dont know wrong way. sombody can me please. thanks in advance. typeface null , because it's not initialized change typeface typeface = new typeface();

android - How to retrieve data from sqlite file -

i doing search operation.i created dbadapter. able manually insert values , perform search. want insert data sqlite file.how proceed? should place sqlite file in assets folder? please tell me how proceed. want search data sqlite file. here main activity code: public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); searchview = (searchview) findviewbyid(r.id.search); searchview.seticonifiedbydefault(false); searchview.setonquerytextlistener(this); searchview.setoncloselistener(this); mlistview = (listview) findviewbyid(r.id.list); assetmanager manager = this.getassets(); mdbhelper = new customersdbadapter(this); mdbhelper.open(); mdbhelper.deleteallcustomers(); //add customer data sample mdbhelper.createcustomer("pizza1", "piz", "1107 west ada", "", "los angeles"); mdbhelper.createcustomer("pizza2", ...

What is the meaning of this C++ macro? -

i can't figure out macro means: #define declare_handle(n) typedef struct n##__{int i;}*n declare_handle(hwnd); i have learned c program that: "##" means connect parameter. so macro equals: typedef struct hwnd__{int i;}*hwnd is right? if right, meaning of sentence? ================== code game bombermaaan (for windows , linux), link http://sourceforge.net/p/bombermaaan/code/head/tree/trunk/src/bombermaaan/winreplace.h , line no 90. the main purpose of construct prevent misuse of handles. if handles void * or int or long long or other basic type, there nothing prevent using 1 instead of another. pointer struct hwnd__ , pointer struct hbitmap__ isn't same thing, if have following code: hwnd hwnd; hbitmap hbmp; hbmp = getbitmap(...); hwnd = hbmp; // gives compiler error. it's classic technique ensure unique types api supplier don't want provide true declaration for. although i'm not entirely sure why need ...

matlab - Using struct arrays in parfor -

i having trouble using struct arrays in matlab's parfor loop. following code has 2 problems not understand: s=struct('a',{},'b',{}); if matlabpool('size')==0 matlabpool open local 2 end j = 1:2 parfor k=1:4 fprintf('[%d,%d]\n',k,j) s(j,k).a = k; s(j,k).b = j; end end matlabpool close it fails error error using parallel_function (line 589) insufficient number of outputs right hand side of equal sign satisfy assignment. on output, variable s vector, not array (as should be, if code breaks before finishing). edit problem solved if initialize struct arrays correct size, by: s=struct('a',cell(2,4),'b',cell(2,4)); however, still happy insights problem (e.g rally bug, suggested oleg komarov) it working fine me don't know happens. in general need careful parfor loops , there ample documentation on how align everything. 2 different words of advice. first , more importantly, parfor loop ...

jquery - Get index of changed element -

i have custom list in html wich add rows dynamically when click in button, row has 2 column second column filled depending of selection of first column on same row. i allow user choose value of new row list of possible values, after user select value fill second column on same row possible values depending of previous selection, problem when load jquery values of second column show if have more 1 row, values added first 1 row. so if have more 1 row , user change first column 3st row jquery change value of second column on 1st row... all custom rows of list has same id , names... there copy of first 1 when add new one. is there way detect on onchange index of element called event? i hope explained well. thanks much.

java - PreparedStatement Close Issue for MySQLNonTransientConnectionException: -

i unable locate following exception occurs. have closed preparedstatement after loop finishes, still gives me error while calling sendbill method: exception text: com.mysql.jdbc.exceptions.jdbc4.mysqlnontransientconnectionexception: no operations allowed after statement closed. @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) @ java.lang.reflect.constructor.newinstance(constructor.java:513) @ com.mysql.jdbc.util.handlenewinstance(util.java:411) @ com.mysql.jdbc.util.getinstance(util.java:386) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:1015) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:989) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:975) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:920) @...

php - StofDoctrineExtensionsBundle softdelete - How do I use it? -

my boss installed bundle softdelete filter, documentation beyond sparse. how use in delete queries? enable in config: stof_doctrine_extensions: orm: default: ... softdeleteable: true doctrine: ... orm: filters: softdeleteable: class: gedmo\softdeleteable\filter\softdeleteablefilter enabled: true then in entity: <?php namespace foo\barbundle\entity; use doctrine\orm\mapping orm; use gedmo\mapping\annotation gedmo; /** * ... * @gedmo\softdeleteable(fieldname="deletedat") * @orm\entity */ class foo { /** * @var \datetime $deletedat * * @orm\column(name="deleted_at", type="datetime", nullable=true) */ private $deletedat; then delete entities (the extension takes care of rest): $em = $this->getdoctrine()->getmanager(); $em->remove($entity); $em->flush();

android - Progress Dialog should spin till loading of gridview completed -

i working on 1 android app in want display progress dialog till loading of gridview completed. problem progress dialog spin intial time. stops spinning. here code. public class allsites extends activity { private final string url_select = "http://api.stackexchange.com/2.1/sites?filter=!rgb_y51.*-(yx"; private gridview gview; private listviewcustomadapter adapter; private arraylist<object> itemlist = new arraylist<object>(); private itembean bean; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.allsites); //gridview gridview = (gridview) findviewbyid(r.id.gvallsites); gview = (gridview) findviewbyid(r.id.gvallsites); new task().execute(); } private class task extends asynctask<void, void, gzipinputstream> { private progressdialog progress; ...

mongodb - Mongo Db design (embed vs references) in Trello -

when open https://trello.com/board/board_name/board_id.json , can see within board there nested documents of card, list, actions etc. want know whether 3 main collections trello team talk card, board, member referenced or embedded (nested) within board? they're referenced. responses assembled api don't precisely reflect structure of db. otherwise, board documents grow without bound, wouldn't work out long-lived boards. also, if included member documents in board, we'd have update every single board document member on when updated member's name.

How to do query on multiple nested data fields in MongoDB -

so, i'm trying query documents have city of 'paris' and state of 'france'. need kind of join, haven't been able figure out how construct it. i'm using c# driver, i'll gladly accept using method. { "_id" : objectid("519b407f3c22a73a7c29269f"), "documentid" : "1", "meta" : [{ "name" : "city", "value" : "paris", }, { "name" : "state", "value" : "france", } }] } { "_id" : objectid("519b407f3c22a73a7c29269g"), "documentid" : "2", "meta" : [{ "name" : "city", "value" : "paris", }, { "name" : "state", "value" : "texas", } }] } the $elemmatch operator used indicate conditions ...

c# convert a part of a json string to objects -

ive got problem decoding json output api.openkvk.nl. want rows converted objects, whats best way convert json rows list? a json example is: [{"result":{"types":["bigint","varchar","int","int","varchar","varchar","varchar","varchar","varchar","varchar","bigint","varchar","double","double","date"],"header":["kvk","bedrijfsnaam","kvks","sub","adres","postcode","plaats","type","status","website","vestiging","rechtsvorm","lat_rad","lon_rad","anbi"]," rows ":[["170401310000","kuijpers installaties helmond b.v.","17040131",null,"panovenweg 18","5708hr","helmond","hoofdvestiging",...

mysql - How to speed up my sql queries? -

i have huge database (mysql) 7 tables (1000000 record each) use simple queries call information : select * matches match_date='$date' select * countries country_id in (select country_id tournaments id='$id') select * tournaments id='$id' i use indexing columns in clause query being faster bit. does have helping ideas improve speed exponentially? the worst request seems one: select * countries country_id in ( select country_id tournaments id='$id') try use this: select countries.* countries inner join tournaments on countries.country_id=tournaments.country_id , tournaments.id=$id index these columns: countries.country_id tournaments.country_id tournaments.id and better use columns names instead of *.

python - django - how to do this with kwargs -

i wondering when touch db when doing queries. more precisely, when query performed: i have kwargs dic: kwargs = {'name__startswith':'somename','color__iexact':'somecolor'} but name__startswith query, need distinct() . , not color__iexact . i thought, set name__startswith distinct() in loop this: for q in kwargs: if q == 'name__startswith': thing.objects.filter(name__startswith=somename).distinct('id') and query dynamically: allthings = thing.objects.filter(**kwargs) but somehow wrong, seem doing 2 different things here.. how can these 2 queries dynamically? django querysets lazy , actual queries aren't evaluated until use data. allthings = thing.objects.filter(**kwargs) if 'name__startswith' in kwargs: allthings = allthings.distinct('id') no queries should preformed above unitl use data. great filtering queries wish do from docs : querysets lazy – act of creating...

What is the IntelliJ shortcut key to create a javadoc comment? -

in eclipse, can press alt + shift + j , javadoc comment automatically generated fields, returns, or whatever applicable specific javadoc comment. i'm assuming intellij idea has feature. can tell me if there keyboard shortcut this? typing /** + pressing enter above method signature create javadoc stubs you.

ibm midrange - Create SQL view against AS/400 data -

how create view against table? want select according todays date. field in as400 defined numeric 8 0. what don't understand is, have recreate table in iseries navigator, order header , detail. exists on as/400 never used in iseries navigator. once view created, should able access via crystal reports. use create view sql statement create view , convert numeric date sql date. note if there invalid dates in table cause error when try select data. may have include validation logic in conversion. for example: create view myview select date(substr(digits(yyyymmdd),1,4) ||'-'|| substr(digits(yyyymmdd),4,2) ||'-'|| substr(digits(yyyymmdd),6,2)) mydate mytable