Posts

Showing posts from June, 2015

Need tips to optimize SQL Server stored procedure -

this stored procedure, it's taking time execute though running local database. please suggest changes in order improve performance begin try declare @country_cd int set @country_cd =(select country_cd country country_desc = ltrim(rtrim(@country_desc))) declare @companny_cd int set @companny_cd =(select company_cd company company_desc = ltrim(rtrim(@company_desc))) begin transaction delete pack country_cd = @country_cd , company_cd = @companny_cd , pack_desc = ltrim(rtrim(@pack_desc)) commit transaction end try begin catch if(@@trancount > 0) rollback transaction declare @errmsg nvarchar(4000), @errseverity int select @errmsg = error_message(),@errseverity = error_severity() raiserror(@errmsg, @errseverity, 1) end catch hard without knowing more database schema. few initial ideas might cleanup *_desc variables right away rather doin

performance - PL/SQL : Should i use a collection or do multiple querys? -

Image
i'm working on project need create big html table each table row 15 minute interval , every table column day. goal show users want reserve rooms when room available , not. webpages pl/sql packages print out proper html. example of table room : (don't mind different colors) all room definitions stored oracle database containing start date, end date, starting hour, ending hour , days of week. example definition be: (07-31-2013 - 07-31-2014, 00:00 - 23:59, mondays,tuesdays , fridays) my concern build every square of html table, need make query check if specific period defined. (for example if user wants see full week 10:00 14:00 room, 112 querys made build table 15 minute intervals) not mention user can see 4 weeks , time interval (could 00:00 23:59). problem need make check room definitions have make check many times see if interval taken reservation... make 224 querys see week. my solution room definitions , reservations affect period user wants see , put them in

php - Imagick - Make black background white -

i using following code mask 1 image on image.on output gives me image black backgroung. but need white background or transparent background. following code using mask 1 image on another. <?php $destination_path = getcwd().directory_separator; $im1="image1.png"; $im2="image2.png"; $i1="$destination_path$im1"; $i2="$destination_path$im2"; $base = new imagick($i1); $mask = new imagick($i2); // setting same size images $base->resizeimage(274, 275, imagick::filter_lanczos, 1); // copy opacity mask $base->compositeimage($mask, imagick::composite_dstin, 0, 0, imagick::channel_alpha); $base->writeimage('output.png'); header("content-type: image/png"); echo $base; ?> the trick using: $im = $im->flattenimages(); : <?php $im = new imagick($filename); $im->setimagebackgroundcolor('#ffffff'); $im = $im->flattenimages(); $im->setimageformat("jpeg"); $im->setimagec

android - Why is it not sleeping for 3 seconds before it starts listening? -

i'm trying do: perform texttospeech speechrecognizer starts listening user repeats texttospeech'd word/phrases but problem that, example, if "example" via texttospeech, when speechrecognizer starts listening, takes in "example" previous , adds onto 1 user says. @ end, ended "example example", didn't want. code: public void onitemclick(adapterview<?> parent, view view, int position, long id) { // todo auto-generated method stub item = (string) parent.getitematposition(position); tts.speak(item, texttospeech.queue_flush, null); thread thread = new thread() { public void run() { try { sleep(3000); } catch (interruptedexception e) { e.printstacktrace(); } } }; thread.start(); sr.startlistening(srintent); } you doing 2 process in 2 thread. creating thread 1 , make sleep 3 seconds , sr.startlistening(s

3d - Different Axes Positions in MATLAB -

Image
i'm trying shift axes positions in matlab figure. i'd achieve similar (which done in gnuplot): i don't have idea whether possible @ all, or might find answer, appreciated. hmm.... so let's plot: x = zeros(1,21); y = -10:10; z = y/2; figure; plot3(x,y,z); % line (0,-10,-5) (0,10,5) similar example well, 1 problem matlab doesn't automatically plot coordinate axis you've shown there. discussed here: how show x , y axes in matlab graph? to plot (in 3d), cheap solution is: locs = axis; % current axis boundaries hold on; plot3([locs(1) locs(2)], [0 0], [0 0]); %plot xaxis, line between(-x,0,0) , (x,0,0); plot3([0 0], [locs(3) locs(4)], [0 0]); %plot y axis, line (0,-y,0) , (0,y,0); plot3([0 0], [0 0], [locs(5) locs(6)]); % plot z axis hold off just gnu plot, 3d matlab plot "in box." unlike gnu plot, matlab box isn't outlined. if want outline you'll have draw lines too...ugh. % lets plot 12 lines make box in black

Excel: Data validation of specific numbers with special cell formatting -

i'm learning data validation of cell values in excel , have discovered problem solve. have cell want allow specific number values. no problem since can use data validation specific cell. can't use "numbers" criteria have numbers 10; 20; 30 example because can specify number ranges (larger than, less than, between etc). instead of using number range use "list" function , write 10; 20; 30 , works. the problem occurs when add special formatting cell. let's want format 1 isn't pre-existing in excel, enter value "10" should display "10 moneys" or grammatically correct. if use custom formatting can add " moneys" after "standard" displayed in cell format menu (ctrl + 1). if either 1 works, if add both list 10; 20; 30, , formatting of standard" moneys" doesn't work when use drop down menu. reason because drop down menu tries add value "10 moneys" , list doesn't recognise because expe

Can we use GoogleAds/AdMob/AdWhirl in cocos2d-android? -

i want add admob / adwhirl gamelayer scene. i search on everywhere couldn't find way work. don't want switch library. , should do? if have worked on , give way . as there not layout xml file cocos2d android can add progammatically. crate linear layout in onstart method itself. like this linearlayout.layoutparams adparams = new linearlayout.layoutparams( getwindowmanager().getdefaultdisplay().getwidth(), getwindowmanager().getdefaultdisplay().getheight()+getwindowmanager().getdefaultdisplay().getheight()-50); adview = new adview(simplegame.this, adsize.banner, "your ad id"); adview.setadlistener(simplegame.this); adrequest request = new adrequest(); request.addtestdevice(adrequest.test_emulator); adview.loadad(request); ccdirector.shareddirector().getactivity().addcontentview(adview,adparams); this should i

apache commons beanutils - How to copy objects managed by Hibernate? -

i want copy object (its properties). object managed hibernate , has lazy collections. propertyutils.copyproperties() throws lazy exception. is there way? ps: not want unproxy object since don't own (its in jar) you can call hibernate.initialize() on every lazy collectio of original object before copying. obviously, not work outside of transaction, if yor object detached hibernate session. so, have initialize lazy collections enough.

c# - DynamicMethod and type checks -

can explain or point explanation why runtime types check not occurs in sample below - string property can set type value ... stuck in unexpected place , surprised using system; using system.reflection; using system.reflection.emit; namespace dynamics { internal class program { private static void main(string[] args) { var = new a(); a.name = "name"; console.writeline(a.name.gettype().name); propertyinfo pi = a.gettype().getproperty("name"); dynamicmethod method = new dynamicmethod( "dynamicsetvalue", // name null, // return type new type[] { typeof(object), // 0, objsource typeof(object), // 1, value }, // parameter types typeof(program), // owner true); // skip visibility ilgene

java - How to change ActionBar Tab bottom border and selected tab background? -

Image
i have created clean app fixed tabs , imported appcompat, how change active tab bottom border color , change clicked tab background? this want: have @ action bar style generator http://jgilfelt.github.io/android-actionbarstylegenerator/

php - "accessRules()" in YII -

i use yii framework , limiting access pages accessrules , filter. there information of how limit access without db or how getting access variable, how can getting role database , access filters in controller. public function filters() { return array( 'accesscontrol', // perform access control crud operations 'postonly + delete', // allow deletion via post request ); } public function accessrules() { return array( array('allow', // allow authenticated user perform 'create' , 'update' actions 'actions'=>array('create','update', 'view', 'index'), 'users'=>array('@'), ), array('allow', // allow admin user perform 'admin' , 'delete' actions 'actions'=>array('admin','delete', 'view', 'index'), 'users'=>array(

performance - Randomize timestamp column in large MySQL table -

i have test database table ~100m rows generated cloning original 3k rows multiple times. let's table describes events have timestamps. due cloning have ~10m events per day far real cases. i'd randomize date column , scatter records several days. here procedure i've come with: drop procedure if exists `randomizedates`; delimiter // create procedure `randomizedates`(in `daterange` int) begin declare id int unsigned; declare buf timestamp; declare done int default false; declare cur1 cursor select event_id events; declare continue handler not found set done = true; open cur1; the_loop: loop fetch cur1 id; if done leave the_loop; end if; set buf = (select now() - interval floor(rand() * daterange) day); update events set starttime = buf event_id = id; end loop the_loop; close cur1; end // delimiter ; on 3k table executes ~6 seconds assuming linear сomplexity take ~50 hours applied on 100m table. there way speed up? or maybe p

Django South migrations fails with column does not exist, for a column that hasn't been introduced yet -

on app running multiple migrations 0023-0027 in 1 go. first of migration complaining missing column not introduced until later. running migrations blogs: - migrating forwards 0027_auto > blogs:0023_auto error in migration: blogs:0023_auto the error reads: django.db.utils.databaseerror: column blogs_blog.author_bio not exist line 1: ...log"."author_name", "blogs_bl... so idea why migration 0023 fail missing column not introduced until migration 0027? the problem auto-generated 0023 migration in forwards function had following in it: in blog.objects.all(): a.uuid = u'' + str(uuid.uuid1().hex) a.save() that calls model based on latest content, author_bio in it. fix call model "orm" so: in orm.blog.objects.all(): a.uuid = u'' + str(uuid.uuid1().hex) a.save()

java - Empty JTextField User Input Error -

i'm trying create program takes user input through jtextfield , converts integer me calculate with. want prevent breaking program typing nothing jtextfield. how can detect when jtextfield empty? daniel this spot use regular expression. here basic information on how use them.

asp.net mvc 4 - Using UrlHelper inside a controller breaks test -

i'm new mvc , tdd please go easy on me! i have action needs redirect action. i'm constructing base uri follows: urlhelper u = new urlhelper(this.controllercontext.requestcontext); string baseuri = u.action("paypalauth", "order"); i've adapted paypal's sample code (string baseuri = request.url.scheme + "://" + request.url.authority + "/order/paypalauth?";) maybe i've not used best method come baseuri target action? main problem is, when call action mstest unit test null exception on controllercontext. what's easiest way solve problem? have found similar questions on can't follow them. guess may need use mocking framework don't know start! what's easiest way solve problem? by mocking controllercontext . here's example of how achieved: https://stackoverflow.com/a/32672/29407

dojo - dijit/form/form issues POST issues in firefox -

i trying post form using dojo.xhrpost . below code works fine in chrome not work @ in firefox. when doesn't work see page reloads again , nothing happens. tried use dojo.stopevent(event); doesn't seem work in firefox. can please suggest me mistake. feel issue more form xhrpost. html looks below: <div data-dojo-type="dijit/form/form" data-dojo-id="myform" id="loginform" enctype="multipart/form-data" action="" method="post"> <script type="dojo/method" data-dojo-event="onsubmit"> if(this.validate()){ senddata(); //calling javascript function }else{ alert('form contains invalid data. please correct first'); return false; } return true; </script> <table cellspacing="10"> <tr> <td><label for="name">username:</label></td> <td><input type="text"

html - Please help me with this navigation bar -

this code vertical navigation bar have created, there 1 more thing need add here , flyout menu on mouse over. have tried many things did not work. here's css code .navbar{ list-style-type: none; margin: 0; padding: 10px; width: 280px; /* width of menu */ } .navbar li{ border-bottom: 1px solid white; /* white border beneath each menu item */ } .navbar li a{ background: #333 url(media/sexypanelright.gif) no-repeat right top; /*color of menu default*/ font: bold 13px "lucida grande", "trebuchet ms", verdana; display: block; color: white; width: auto; padding: 5px 0; /* vertical (top/bottom) padding each menu link */ text-indent: 8px; text-decoration: none; border-bottom: 1px solid black; /*bottom border of menu link. should equal or darker link's bgcolor*/ } .navbar li a:visited, .navbar li a:active{ color: white; } .navbar li a:hover{ background-color: black; /*color of menu onmouseover*/ color: white; border-bottom: 1px solid black; /*bottom border

How to display an ArrayList in a JPanel -

how can jlist show in jpenel. example i'd have following groups of items displayed in jpanel, each group showing on it's own column, new group being dropped new line, how google lists search results. for example: import java.util.arraylist; import java.util.list; import javax.swing.jpanel; public class readerimpl { jpanel paneto = new jpanel(); list<string> text() { list<string> lovely = new arraylist<string>(4); lovely.add("tall, short, average"); // line 1 lovely.add("mangoes, apples, bananas"); // line 2 lovely.add("12, 33"); return lovely; } // how add lovely arraylist paneto } a jlist renderer can draw checkbox, jlist does not support cell editor. instead, consider one-column jtable. check out link here. hope helps.

php - Sorting distinct results into different tables -

i have table contains information on classes cpr, first aid, etc...i sort , display information table each class type. of cpr classes in table new table first aid classes, etc... the code below puts each class it's own table...i need group them classname if possible. thanks in advance help. scott <?php $result = mysql_query("select * providerclasses clientid = '$clientid' order classname"); $i = 0; // start count bg color while($row = mysql_fetch_array($result)) { echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" class=\"gridtable\" width=\"975\" style=\"margin-bottom:100px;\">"; echo "<tr class=\"gridheader\">"; echo "<td width=\"88\" class=\"grid-header-cell\">date</td>"; echo "<td width=\"161\" class=\"grid-header-cell\">time</td>"; echo "&

css - Auto width when add list -

i have simple menu (centered margin:0 auto ) list items. now, i'm trying keep menu on same centered position when add additional list items. here fiddle play it ul{ list-style-type: none; background: red; margin:0 auto; width: 56%; max-width:600px } ul li{ display: inline-block; width: 100px; background-color: #000; color: #fff; } i want additional li 's ul wrap , still centered. i don't want use flexbox because ie doesn't support :d the problem solved. giving ul {display:table} thank all,especially coop ! not sure if you're after i've had issues centering nav menus , came solution: ul{ display: table; margin: 0 auto; list-style-type: none; background: red; } ul li { float: left; color: #fff; background-color: #000; } note li's floated need clear them on ul. i'd suggest clearfix solution that. example full code be: ul { display: table; margin: 0 auto; list-style-type: none; background: r

dymola - Debug Modelica code -

i wonder if there way "debug" modelica code, mean debugging code line line , can see how variables change, things that? i know modelica code translated c, want know if there's possibility somehow, if there is, believe it's gonna great improvement of simulation environments. thanks. hy this question , comes lot. first, let's step second. the idea of debugging "line line" comes imperative programming languages. "imperative" mean program sequence of instructions carried out in specified order. when debugs java or python, "line line" approach makes sense because statements fundamental way behavior represented. "line line" approach extended modeling formalisms block diagrams (e.g. simulink) because, while graphical, imperative (i.e. constitute steps carried out in specified order). but modelica not imperative language. there no notion of steps, statements or instructions. instead, have omnipresent equ

url - Android -Convert large paragraph links to spanURL -

tried online search already. here example of trying do: text within textview is: "hey how doing check link: http://www.google.com , if dont link try link http://yahoo.com or try http://tinyurl.com/wp-tinyurl " i make these links clickable in listview. not want use android:autolink="web" on textview object list item clickable , these can consume click event or cause confusion. im looking way scan through text , collect links , change them spanurl way text becomes clickable not textview. if makes difference here textview within row layout of listview have now: <textview android:id="@+id/tv_user_response" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="25dp" android:autolink="web" android:descendantfocusability="blocksdescendants" android:textcolor="@color/grey_font"

android - Do I need to target devices for my application? -

Image
i finished application, it's working expected on mobile phone, however, running on different avd it's disaster. i have read article: http://developer.android.com/guide/practices/screens_support.html , articles too: http://developer.android.com/guide/topics/resources/index.html , don't know should do. the min sdk 4.0 (api 14), , i'm targeting android 4.0.3 (api 15). want application run on mobile phones. know can set in androidmanifest.xml do need create 7 individual layouts compatible different devices in portrait mode? my problem views width, height , margins in dp. on different devices looks different. better understand i've attached image: as can see, marked green portions spaces are. what should have same design on different devices? do need recreate design using relativelayout , reference views between them? you shouldn't write whole new code other screens unless should differently in terms of positioning of elements. should de

rest - Drupal 7 Services 3.4 with session authentication and jQuery -

i'm having trouble connecting drupal 7 , jquery using services 3.4 , jquery cookie plugin. understand, need following: - post service endpoint /user/login - session name , session id , add them http cookie - session token id - add token id http header: x-csrf-token: sometoken i try method using jquery , receive 'access denied user anonymous' error. i'm using services 3.4 cors module across 2 subdomains. endpoint appears set correctly , login function returns user , session data, , token. i have tested accessing service php script based on this example . modified example create nodes well. works expected, respecting drupal's permissions. i have made following change header in custom module after receiving errors token being in header. function custom_services_init() { drupal_add_http_header('access-control-allow-headers', 'x-csrf-token'); } here jquery code: $('#menu-connect').click(function() { var url = 'http

javascript - Why are my hidden divs auto appearing? -

i have 2 hidden divs named hidden_div , hidden_divx. objective make each 1 appear when respective checkbox clicked. have 2 separate functions. both pretty identical. first hidden div works fine. second 1 auto appears. thoughts or suggestions? js: function doinput(obj){ var checkboxs = $("input[type=checkbox]:checked"); var =0, box; $('#hidden_div').fadeout('fast'); while(box = checkboxs[i++]){ if(!box.checked)continue; $('#hidden_div').fadein('fast'); break; } } function doinputs(obj){ var checkboxs = $("input[type=checkbox]:checked"); var =0, box; $('#hidden_divx').fadeout('fast'); while(box = checkboxs[i++]){ if(!box.checked)continue; $('#hidden_divx').fadein('fast'); break; } } and here current html: <div id="ticket_hidden" style="text-align: center; clear:both;">

javascript - Multiple d3 charts on one page -

i have cubism d3 chart on page. want add more charts page. possible add more d3 charts in same page or have use other libraries? i asking because every visualization in d3 uses .axis , if give style cubism graph affect other graphs well. i recommend wrapping entire generating code in function specifies dom element want put chart in parameter. leverage javascript closure , should work out.

iOS: Adding observer to a UIView's frame.origin.y? -

i'm trying monitor , react changing value of origin of uiview's frame. code: [cell.bottomview addobserver:self forkeypath:@"frame.origin" options:nskeyvalueobservingoptionnew context:null]; -(void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context { nslog(@"%@ changed", keypath); } i'm getting following error message don't understand: an instance 0x7587d10 of class nsconcretevalue deallocated while key value observers still registered it. observation info leaked, , may become mistakenly attached other object. set breakpoint on nskvodeallocatebreak stop here in debugger. here's current observation info: <nskeyvalueobservationinfo 0x7587fd0> ( <nskeyvalueobservance 0x7587f70: observer: 0x7587bd0, key path: origin, options: <new: yes, old: no, prior: no> context: 0x0, property: 0x7587ff0> ) really, i'm interested in y position of origin code won&

jquery - Changing text on each page load -

i'm starting jquery/javascript , i'm still kind of newbie. i have list of phrases , need them change inside <h4> everytime page loads/reloads. i think basic question, can't solution (my mind says it's easy, current coding abilities don't). thanks in advance ! if don't care order, try: var texttoshow = ['text1', 'text2', 'text3', 'text4'] $(document).ready(function() { $("h4").html(texttoshow[math.floor(math.random()*texttoshow.length)]); }); here fiddle: http://jsfiddle.net/jzdnv/ keep clicking 'run' different things.

Armadillo c++: Is there a specific way for creating efficiently triangular or symmetric matrix -

i using armadillo symmetric , triangular matrices. wanted efficient in terms of memory storage. however, seems there no other way create new mat , fill zeros(for triangular) or duplicates(for symmetric) lower/upper part of matrix. is there more efficient way of using triangular/symmetric matrices using armadillo? thanks, antoine there no specific support triangular or banded matrices in armadillo. however, since version 3.4 support sparse matrices has gradually been added. depending on armadillo functions need, , sparsity of matrix, might gain using spmat<type> implements compressed sparse column (csc) format . each nonzero value in matrix csc format stores row index along value not save memory triangular matrix. banded diagonal matrix should consume less memory.

Analysis of Prim's Algorithm -

can explain why use or what's importance of using key array(i.e key[]) in prim's algorithm deals minimum spanning tree problem. prim_mst(g,w,r)//g->graph,w->weighted matrix,r->root vertex ------------------------- v<-v[g] key[v]<-infinity pred[v]<-nil //pred[]-->predecessor array key[v]=0 q<-v[g] //q-->priority queue while q!=null u<-extract_min(q) v<-adj[u] //adj[]--> adjacency list matrix if v belongs q && w(q,v)<key[v] pred[v]<-u,key[v]<-w(u,v) key value on edge led particular vertex in graph during construction of mst on arriving on vertex during algorithm, checks minimum weighted edge connecting set a(the set of vertices traversed) , set b(the set of edges not yet traversed). follows minimum edge , puts key of newly arrived vertex(the 1 reached after following min edge) weight of minimum edge

should I be using sockets or packet capture? perl -

i'm trying spec out foundations server application who's purpose to.. 1 'receive' tcp and/or udp packets 2 interpret contents (i.e. header values) to add more detail, server receive 'sip invites' , respond '302 redirect'. i have experience net::pcap , perl, , know achieve looping filtered packets, decoding , using net::sip respond. however, there's lot of bloat in both of these modules/applications don't need. server under heavy load, , if run tcpdump on it's own, loses packets in kernel due server load, worry wont appropriate :( should able achieve same thing 'listening' on socket (using io::socket example) , decoding packet? unfortunatly debugging, it's hard tell if io::socket give me opportunity see raw packet? , instead automatically decodes message readable format! tl;dr: want capture lots of sip invites, analyse head values, , respond sip 302 redirect. there better way using tcpdump (via net::pcap) achiev

redirect - redirecting email text from procmail into bash script -

i trying redirect emails match particular pattern shell script create files containing texts, datestamped filenames. first, here routine .procmailrc hands emails off script: :0c: * subject: ^ingest_q.* | /home/myname/procmail/process and here script 'process': #!/bin/bash date=`date +%f_%n` file=/home/myname/procmail/${date}_email.txt while read line echo "$line" 1>>"$file"; done i have gotten frustrated because can pipe text script on command line , works fine: mybox-248: echo 'foo' | process mybox-249: ls 2013-07-31_856743000_email.txt process the file contains word 'foo.' i have been trying email text output date-stamped file hours now, , nothing has worked. (i've turned logging on in .procmailrc , isn't working either -- i'm not trying ask second question mentioning that, wondering if might provide hint might doing wrong ...). thanks, gb quoting attempt:

javascript - Applying a style to text that I double click? -

edited reword: i have input box <input type="text" id="some_id" /> i enter text in in browser: here text! now suppose double click on word "my", can i: capture value? yes, answer below. can style in place in text input make bold or highlight? in text input after double click end looking like: here my text! if want word selected (via double click default behaviour) $('input').dblclick(function() { $(this).addclass(yourclass); alert(getselected()); }); using getselected function found http://mark.koli.ch/2009/09/use-javascript-and-jquery-to-get-user-selected-text.html getselected = function(){ var t = ''; if(window.getselection){ t = window.getselection(); }else if(document.getselection){ t = document.getselection(); }else if(document.selection){ t = document.selection.createrange().text; } return t; } applying class selected text.. don't

vb.net - Custom DataView Grid Control -

i need create custom data grid view control solve tailored needs. presently binding dataset grid , need check data in grid , format values or clear cells , make color of cell gray (disabled.). takes huge time when data increases couple of thousand rows. so thought if can create custom datagrid has these properties time taken reduced the formatting of grid cells happen instantly. can 1 me out if possible.i need in vb.net. you can use datagridview.cellformatting event . event occurs when cell has formatted display. rows "hidden" won't have event being called upon. private sub datagridview1_cellformatting(sender object, e datagridviewcellformattingeventargs) _ handles datagridview1.cellformatting '----------------------------------- ' magic end sub normally don't have create custom control this. wire event.

c# - LINQ to Entities does not recognize the method 'Method name' method -

i'm having similar problem asked here: linq entities not recognize method 'system.string tostring()' method, , method cannot translated store expression i'm trying paginate source, in case, can't put result of getpropertyvalue in variable, because need x that: public ienumerable<tmodel> paginate(iqueryable<tmodel> source, ref int totalpages, int pageindex, int pagesize, string sortfield, sortdirection? sortdir) { totalpages = (int)math.ceiling(source.count() / (double)pagesize); if (sortdir == sortdirection.descending) { return source.orderbydescending(x => getpropertyvalue(x, sortfield)).skip(pageindex * pagesize).take(pagesize).tolist(); } else { return source.orderby(x => getpropertyvalue(x, sortfield)).skip(pageindex * pagesize).take(pagesize).tolist(); } } private static object getpropertyvalue(object obj, string name) { return obj == null ? null : obj.gettype().getproperty(name).g

ios - NSXMLParser not working -

i trying parse xml data url. working, expected data isn't being logged. here sample of xml data <?xml version="1.0" encoding="utf-8"?> <result> <row> <id>1</id> <menu_id>1</menu_id> <group_id>1</group_id> <name>merchandise</name> <image>bag of beans.jpg</image> </row> <row> <id>4</id> <menu_id>1</menu_id> <group_id>1</group_id> <name>misc</name> <image>tea.jpg</image> </row> and here code: #pragma mark - nsxmlparserdelegate - (void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring*)namespaceuri qualifiedname:(nsstring *)qname attributes:(nsdictionary *)attributedict { // if have more complex object init here // since i'm storing string won't if ([elementname isequaltostring:@"name"]) { // nslog(@"didstartele

ios - ScrollView inside View or Vice Versa? -

i working in ios , cannot find if there definitive answer this. i have screen, entire thing scroll (not part of scrolling @ top). using storyboards build , content bigger screen size. best way with: this inside of uiviewcontroller. the content inside view (child) inside fullscreen scrollview (parent) , set content size of scrollview view's frame. the content inside scrollview (child) inside fullscreen view (parent) , set content size of scrollview frame , new frame view's frame. just scrollview first child of viewcontroller , set content size frame , frame screen size (which need check @ runtime?) all of these methods seem work, make other things easier/harder (moving content keyboard, etc.). matter of opinion or there "best/correct" method? you have set content size bigger view. scroll.

android - ImageView will not update when touched. "res cannot be resolved" -

playbutton.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1) { switch(arg1.getaction()) { case motionevent.action_down: { playbutton.setimagebitmap(res.getdrawable(r.drawable.play_pushed)); break; } case motionevent.action_cancel: { playbutton.setimagebitmap(res.getdrawable(r.drawable.play)); break; } } return true; } }); the 2 res keywords underlined in red. trying change image darker version of when touched. necessary images located in res folder. idea problem is? update: updated code little , works perfectly: playbutton.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1)

performance - Lua string to number parsing speed optimization -

i trying make speedtest using lua 1 of languages , wanted advice on how make code bit faster if possible. important own speedtest, since looking @ specific parameters. the code reading file looks this, numbers randomly generated , range 1 zu 1 000 000. there between 100 , 10 000 numbers in 1 list: type (123,124,364,5867,...) type (14224,234646,5686,...) ... the type meant language, can ignored. put here know why not parsing every line. lua code: incr = 1 line in io.lines(arg[1]) incr = incr +1 if incr % 3 == 0 line:gsub('([%d]+),?',function(n)tonumber(n)end) end end now, code works , want do. not getting work, speed. need ideas , advice make code work @ optimal speed. thanks in advance answers. imho, tonumber() benchmarking rather strange. of cpu time spent on other tasks (regexp parsing, file reading, ...). instead of converting number , ignoring result more logical calculate sum of numbers in input file: local gmatch, s = string.gm

qt - Not able to access my webcam using opencv library -

i'm trying use webcam (in qt) using opencv library. error code: #include "mainwindow.h" #include <qapplication> #include <qlabel> #include <opencv2/opencv.hpp> #include <opencv/cv.h> #include <qtwidgets> #include <qimage> int main(int argc, char *argv[]) { cv::videocapture camera; camera.open(1); } saying /home/darshan/aindradesktopapp/main.cpp:27: error: undefined reference `cv::videocapture::videocapture()' /home/darshan/aindradesktopapp/main.cpp:28: error: undefined reference `cv::videocapture::open(int)' /home/darshan/aindradesktopapp/main.cpp:30: error: undefined reference `cv::videocapture::~videocapture()' /home/darshan/aindradesktopapp/main.cpp:30: error: undefined reference `cv::videocapture::~videocapture()' collect2: error: collect2: error: ld returned 1 exit status what should do?

TFS Deployment to Azure Error: cannot find ClientPerfCountersInstaller.exe -

Image
i configured our implementation use azure caching provider maintain session state between cloud instances described here: http://msdn.microsoft.com/en-us/library/windowsazure/gg185668.aspx this created new startup task on csdef file fails error: c:\program files (x86)\msbuild\microsoft\visualstudio\v11.0\windows azure tools\2.0\microsoft.windowsazure.targets (987): cloudservices64 : cannot find file named 'approot\bin\microsoft.windowsazure.caching\clientperfcountersinstaller.exe' startup task microsoft.windowsazure.caching\clientperfcountersinstaller.exe install of role myrole.web. the .exe in nuget package , in main folder included in source control tfs uses deployment. i found previous question addresses same issue: azure deployment error: cannot find clientperfcountersinstaller.exe but accepted answer states delete startup task installs .exe needed caching take place. make sure .exe marked copyalways copied \bin directory. to so, right click on .e

macros - How does a compiler change variable names? -

i've been doing research topic , haven't found concrete answers. let's have these expression in code: b = 2 … b = b + 5 … b = j + b … (these simple examples, know aren't realistic) b has many different values throughout these lines. in line 1 it's 2 , later on becomes 7 , , more later on it's 7 + j . compiler need keep track of these different values b , 1 way rename them. example, when b redefined b = b+5 , changed b1 = b+5 . last redefinition b2 = j+b1 . the motivation behind idea involves optimizing program i'm building. involves replacing variables expressions they're related to. if variable redefined, however, character 'b' can mean multiple things @ once. method i'm using keep track of things i've described above, redefining variable names. is @ how compiler's work? there name this? i'm trying find out as can process of compiler redefining variables in case of redefining variables. if helps, believe done

vb.net - Chart Series to Array -

i'm using vb.net 2010 how data series on chart array or textbox or table ? i'm using code plot graph: serie1.points.addxy(val(label4.text), val(label5.text)) i need read values serie1 . you store values in list while adding series or if want access after adding series following. using system.windows.forms.datavisualization.charting; datapoint[] arr = series.points.toarray<datapoint>(); or list<datapoint> lst = series.points.tolist<datapoint>(); and can access x , y values using foreach loop foreach(var pt in lst) { pt.xvalue // access xvalue pt.yvalue // access yvalue }

javascript - jquery dialog too many buttons -

here code jquery ui: jquery("#nodeliverydate").dialog({ resizable:false, draggable:false, modal:false, buttons:[{text:"close",click:function(){jquery(this).dialog("close");}}] }); it simple code using jquery dialog alert box. defined 1 button close dialog. however, runs in odd way dialog contain many buttons, , text on buttons function names such "each","all","clone","select","size", etc . , after close it, if dialog shows again, normal. have idea why happens? jquery("#nodeliverydate").dialog({ modal: true, title: 'delete msg', zindex: 10000, autoopen: true, width: 'auto', resizable: false, buttons: { yes: function () { // $(obj).removeattr('onclick'); // $(obj).parents(&

javascript - Call same function on page load and when form submit -

$("#getlog").submit(function (e) { e.preventdefault(); $.ajax({ //some code }); }); <form id="getlog"> <input type="submit"> </form> i want call function when page loads , when user presses submit button. i have tried document.getelementbyid("getlog").submit() on page load call function. try defining separate function , call on load , on submit function ajaxcall(){ $.ajax({ //some code }); } $(document).ready(function(){ ajaxcall(); }); $("#getlog").submit(function (e) { e.preventdefault(); ajaxcall(); }); hope help

regex - Advice about database design with tokens -

if going create app alerts, users can post little messages traffic, crimes, , other news, how difficult and/or if implement sort of compiler analyze each piece of msg, , categorize in sections crime/murder or traffic/reallyslow. i think easier approach obligate user select appropriate category more appropriate: create table alert{ id_alert int not null primary key auto_increment, alert varchar(255), id_sub_category, foreign key(id_sub_category) references sub_category(id_sub_category) } create table sub_category{ id_sub_category int not null primary key auto_increment, sub_category varchar(45), id_category, foreign key(id_category) references category(id_category) } create table category{ id_category int not null primary key auto_increment, category varchar(45), } i need advice how difficult implement first approach the database design seems appropriate enough, not knowing final solution needed. your ultimate question has nothin

Why does Maven Jetty Plugin not find a class in a standard jetty jar -

i'm using jetty 9.0.4v20130625 running using maven-jetty-plugin . have implemented own loginservice class handle users logging in realm. on 1 of lines, attempt use org.eclipse.jetty.util.security.credential class during execution throws noclassdeffounderror on line. my target directory contains being deployed jetty instance. within web-inf/lib folder not contain jetty-util-9.0.4.v20130625.jar expected because plugin should have believe rules out conflicting jars. causing jetty instance not find jar? i using eclipse, , shows no errors in code. set maven project , maven handles dependencies. set not package jetty jars should provided jetty when deployed. here pom.xml: <project ...> ... <packaging>war</packaging> ... <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>3.8.1</version> <scope>test</scope> </depe

c# - Configuration Manager is not saving in app.config -

i have app.config : <?xml version="1.0"?> <configuration> <configsections> </configsections> <connectionstrings> <add name="conexx" connectionstring="data source=192.168.1.2 ;initial catalog =ifdcontroladoria3 ;uid =sa;pwd = admin2012" providername="system.data.sqlclient" /> </connectionstrings> <startup><supportedruntime version="v4.0" sku=".netframework,version=v4.0,profile=client"/></startup></configuration> i m trying update connectring c# : coneydstr = @"data source=" + combobox1.text + ";initial catalog =" + cmbbancos.text + ";uid =" + txtusuario.text + ";pwd =" + txtpassword.text; try { coneyd.connectionstring = coneydstr; coneyd.open(); funciona = true; lblstringsalida.text = coneydstr; } catch (exception ex) { message