Posts

Showing posts from January, 2012

c# - Checks whether log event should be logged or not NLog -

i'm using nlog library logging in asp.net website. want check whether log event should logged or not in order create "stackframe". according nlog documentation have given "check" method this. doesn't work me. check method not available. great if can me on this. http://nlog-project.org/documentation/v2.0.1/html/m_nlog_filters_filter_check.htm you should use filters described here, https://github.com/nlog/nlog/wiki/filters

ios - How to segue to a view managed by Navigation Controller? -

i working working on app (ios 5+) contains stacks of views managed navigation controller: mynavcontroller -> myrootviewcontroller -> mytableviewcontroller -> mydetailviewcontroller i have view controllers not managed navigation controller handling login (loginviewcontroller) , registration (regviewcontroller) of app. when app launched, check if account has been created. if so, seque loginviewcontroller user login, , segue myrootviewcontroller. however, if no login detected, user presented regviewcontroller scene create account. then, take user directly mytableviewcontroller scene, bypassing rootviewcontroller scene. possible (via storyboard or programatically)? have attempted define modal segue regviewcontroller mytableviewcontroller, seems partially work - able go scene nav bar missing on top of screen. when select table item fails go mydetailviewcontroller. crashes error "push segues can used when source controller managed instance of uinavigationcontroller....

Beginner with iOS - SIGABRT when referring to a simple method in my app? -

i'm starting ios development, trying call method(function?) in code. in .h file have: - (void)changecolour; in .m file have: - (ibaction)leftswipedetected:(uiswipegesturerecognizer *)sender { [self changecolour]; } - (void)changecolour { colourcount++; switch (colourcount) { case 1: self.view.backgroundcolor = [uicolor redcolor]; break; case 2: self.view.backgroundcolor = [uicolor bluecolor]; break; } } this prompts sigabrt abandonment when run program, didn't when didn't try calling method. there wrong this? thanks. ok way try this, @interface viewcontroller () { int count; } @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. uiswipegesturerecognizer *rec = [[uiswipegesturerecognizer alloc]initwithtarget:self action:@selector(leftswi...

matrix - Mathematica SequenceAlignment SimilarityRules -

in mathematica's option similarityrules http://reference.wolfram.com/mathematica/ref/similarityrules.html sequencealignment http://reference.wolfram.com/mathematica/ref/sequencealignment.html possibility of pushing simmilarity matrix - "blast" "blosum62" "blosum80" "pam30" "pam70" "pam250". if want use own ones? have define {{a_,a_}->1,{a_,b_}->-1} etc each combination of letters?? or there possibility of writing own , storing matrix, importing it? quickest option of defining such object using mathematica's matrices? any appreciated, cheers, m. i did grep on 'blosum' (one of named similarity rules matrices) see it's defined , in hope of discovering mechanism implementation. found seems defined in file called similarityscorematrices.mx, binary mathematica file, equivalent object file in compiled language. looked files "blosum' in found none. looks wolfram did not in...

Whats the best way to store a Global/Class Variable in Rails thats updated through a dashboard? -

i need store global/class variable updated managers web dashboard. variable array, lets call car_types. once week managers need go in , change value. maybe they'll update ['suv', 'convertible', 'sedan'] ['suv', 'convertible']. what i'm not sure on store variable. create database table 1 record in gets updated, seems overkill. use memecached, send variable there, though i'm not sure if thats persistent enough. thinking of having dashboard update class variable, have dozens of servers running same app, , i'm unclear if change replicated boxes or stay on 1 box. thanks global variables prefixed $, example: $cars but if application goes down? global var reinitialized default value. recommend database, caching if want save on performances. you cache database values in $cars variable that's personal approach: database + cache records being updated not often. cache cleared when change made in table, , cache ...

gettext - Python line numbers with xgettext -

it understanding uses of gettext python files use nice python library/utility create .pot files. in odd circumstance need use python mode of xgettext extract not strings, line number , filename. examples of such have seen have used processes other xgettext . how can add line number , filename info python mode of xgettext ? in c-mode like: #line 8 "superior_science.c" _("facial hair has been shown improve intelligence factor of 5."); in python, input file need like? (note: code needs work xgettext , not compiler or interpreter.) you can use xgettext extract comments line above gettext call. these comments go .pot , .po files, translator can see them. you choose prefix character comments want translate, prefix comments it, , call xgettext -c option , character prefix. so example, if use prefix ~ , line above be #~ line 8 "superior_science.c" _("facial hair has been shown improve intelligence factor of 5.") and wh...

javascript - calling the function from <div> attribute? -

for example, have next code: var sale = {}; sale.maincontent = function(p) { alert("this handler main-content"); } and have next html div: <div id="content-data" data-handler="maincontent">{"name":"john"}</div> i try do next things - parsing content of div in jquery, this: var cd=$("#content-data"); var obj = jquery.parsejson(cd.text()); and when attribute fo data-handler: var hname=cd.attr("data-handler"); so, next step - call function name hname = 'maincontent' in sale object this(?): sale.hname(obj); how can call function name in variable? you can - sale[hname](obj);

javascript - Updating JQueryUI .button() when called again? -

i have post returns new page. page has <a> link </a> upon pages return call $( "a" ).button(); . have called on original page of buttons formatted jqueryui button. however, new button isn't formatted until make post. there way $(".maprelation") .click(function( event ) { var closestrow = $(this).closest("tr"); var nextrow = closestrow.next("tr"); $(this).css("display", "none"); if(nextrow.attr("id") != "map"){ $.ajax({ url: "addtask.aspx/insertmappingrow", type: "post", datatype: "json", contenttype: "application/json; charset=utf-8", success: function (res) { closestrow.after(res.d); }, error: function (res) { debugger; alert("error"); } ...

ZooKeeper interface for PHP -

i have zookeeper cluster , running, want interface through php code? i've seen zookeeper php extension on github ( https://github.com/andreiz/php-zookeeper ) i'm new php/zk , i'm not sure how started connecting zk using php. i have used same php client , did not have problem. pretty api. followed steps here started: http://systemsarchitect.net/distributed-application-in-php-with-apache-zookeeper/ and can view example code on github.

objective c - Cocos2d Selector with multiple args -

lets wanna call cocos2d method after 2 seconds, this: [self runaction:[ccsequence actions: [ccdelaytime actionwithduration:2], [cccallfunc actionwithtarget:[gamescene sharedscene] selector:@selector(gameoverandlost:) withobject:true], nil]]; i'm trying send bool method, somehow doesn't seam way - (void) gameoverandlost:(bool)bol anyone know's i'm doing wrong here? quite simple task, i'm not used objc one mistake in code: used cccallfunc instead of cccallfuncn. (cccallfunc not takes argument). [cccallfuncn actionwithtarget:self selector:@selector(gameoverandlost:)]; to send multiple argument, better go cccalblockn. id calfun = [cccallblockn actionwithblock:^(ccnode* node) { //control comes here when block executed... //here can access class member variables , variables in same function } ];

javascript - Sorting a JScript Array on a String Field with leading No.s -

i have js object, internal array of js object. internal onw like function outerobj() { this.items = new array(); this.clear = function () { this.items = new array(); } function __item(v1, v2, v3, v4) { this.val_1 = v1; this.val_2 = v2; this.val_3 = v3; this.val_4 = v4; } this.add = function (va, vb, vc, vd) { this.items.push( new __item(va, vb, vc, vd) ); } ... } the array loaded through spservices getlistitems() call, using .each( . . . ) on resultant xml. results ordered ( <orderby> ), results common irritation: 1 10 11 2 21 3 42a 42b i cannot away inclusion of letters (this name of real-world items), while want sort be 1 2 3 10 11 21 42a 42b suggestions? just use javascript array.sort() code this: this.items.sort() heres link: javascript sort reference

java - "Non-terminating decimal expansion; no exact representable decimal result" happens even when divide by 100 -

this question has answer here: arithmeticexception: “non-terminating decimal expansion; no exact representable decimal result” 7 answers my java code running on hp-ux hpdev b.11.23 u ia64 , produce following exception: java.lang.arithmeticexception: non-terminating decimal expansion; no exact representable decimal result. the code causes it: bigdecimal p_change = (bigdecimal)record.get("p_chng"); p_change.divide(new bigdecimal(100)); record simple collection of column values sql query.p_change comes table in oracle database column number(10,2). i understand why happens.the frequency random, divide fine same data sometimes. wondering if has hardware. could system.out on value p_change? bigdecimal p_change = new bigdecimal(math.pi); system.out.println(p_change.divide(new bigdecimal(100))); // yields 0.0314159265358979311599796346854418516...

angularjs - (Help) Input prepopulated with db value, need to be able and save back to db -

very new angularjs (and javascipt in general). here's have know works: 1) input db data 2) working function submits php i have input populated data local mysql server (via $http, ng-repeat). (seemingly) since $scope of $http data response applies the ng-model belonging ng-repeat, dont know how pass input value submit function. any ideas of simplest way this? once basic way of doing it, i'll explore more complex methods. many thanks! function usercardeditctrl ($scope, $routeparams, $http) { $scope.cardid = $routeparams.cardid; $http({ url: 'php/display.php?cardid=' + $scope.cardid, method: "get"} ) .success(function(data) { $scope.gut = data; } ) var master = { fname: 'j' }; $scope.run = function () { $scope.form = angular.copy(master); }; $scope.sbmt = function () { var send = $scope.form; $scope.run(); $http({ method: 'post', url: 'views/getlength.php', ...

c++ - How to change fontsize on drawText? -

qstring str = qstring::number((double)i, 'd', 1); painter->drawtext(100 + * 800/9 - 6, 910, 40, 40, 0, str ); i increase fontsize 2x showing? you try (haven't compiled code see if works!): qfont font = painter->font() ; /* twice size current font size */ font.setpointsize(font.getpointsize() * 2); /* set modified font painter */ painter->setfont(font); /* draw text etc. */ painter.drawtext(....);

ios - Application tried to push a nil view controller on target -

i got below error: application tried push nil view controller on target uinavigationcontroller: 0x7b98940. it caused when 'click' cell of uitableviewcontroller . code: #pragma mark - table view delegate - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { verifyinfoviewcontroller *verifyinfovc = [self.storyboard instantiateviewcontrollerwithidentifier:@"verifyinfovc"]; [self.navigationcontroller pushviewcontroller:verifyinfovc animated:yes]; } this error means viewcontroller has not been allocated properly, , guess self.storyboard nil, if yes means didn't initialise master viewcontroller , can below trick: uistoryboard *storyboard = [uistoryboard storyboardwithname:@"mainstoryboard" bundle:[nsbundle mainbundle]];

xml - Schematron sh script not behaving -

i found shell script schematron supposed able feed schematron schema, , xml document, apply schematron rules xml document. found script here: https://code.google.com/p/schematron/wiki/runningschematronwithgnomexsltproc the various xsl files used script downloaded schematron distribution here: http://www.schematron.com/implementation.html i'll repeat shell script here, convenience. #!/bin/bash echo step1 ... xsltproc iso_dsdl_include.xsl $1 > step1.xsl echo step2 ... xsltproc iso_abstract_expand.xsl step1.xsl > step2.xsl echo step3 ... xsltproc iso_svrl_for_xslt1.xsl step2.xsl > step3.xsl echo validation ... xsltproc step3.xsl $2 > result.svrl i run script this: run_schematron.sh docbook1.sch my_xml.xml the shell script generates intermediate files, step1.xsl, step2.xsl, , step3.xsl. off rails @ step2.xsl, since looks this: <?xml version="1.0"?> @linkend on footnoteref must point footnote. @linkend on synopfra...

vb.net - Syntax Error in From Clause deleting MSystem table records, relationship issue -

i looking delete relationship created code in access 2007 db, using vb.net. db may have been upgraded older level. so here has been done, open db ado connection string, db encrypted , password protect, open in mode =12, exclusive rights. works. grant select, delete, , alter permissions on msysobjects, , msysrelationships admin user. the issue relationship used guid, stored in these system tables text, can not deleted tables relationship made, ie. alter table [mytable] drop constraint '{d86827c0-some-guid-6a6449f1fb07}'; or alter table [mytable2] drop constraint '{d86827c0-some-guid-6a6449f1fb07}'; this fails becuase guid can not found on table, have tried tables on both sides of relationship. able szrelationship value, how have apply above alter query, yet stated, not found relationship name on either table. led me believe db may have been migrated older access. system object tables show relationship, know exists , appears in relationships diagram. can d...

apache kafka - Is there any workaround for simpleConsumer module to read only the new messages? -

as mentioned simple consumer here https://cwiki.apache.org/confluence/display/kafka/0.8.0+simpleconsumer+example also note explicitly checking offset being read not less offset requested. needed since if kafka compressing messages, fetch request return entire compressed block if requested offset isn't beginning of compressed block. message saw may returned again. finally, keep track of # of messages read. if didn't read on last request go sleep second aren't hammering kafka when there no data. as in program reads 1 of old messages first, goes sleep old, , reads new records. any work around simpleconsumer reads new messages? from same page public static long getlastoffset(simpleconsumer consumer, string topic, int partition, long whichtime, string clientname) { topicandpartition topicandpartition = new topicandpartition(topic, partition); map<topicandpartition, partitionoffsetrequestinfo...

python - Switch Django's version -

i'm using different django framework version(1.3, 1.4, 1.5) different projects. on laptop, have reinstall django pip, every time want switch project. there easier(less stupid! :d) way, can automatically switch version need? nvm node? in opinion easiest way use requirements.txt file virtualenv . requirements.txt file can specify version , every other person uses project can use pip install -r requirements.txt . this way how big projects (the "pythonic" way). here have small introduction .

mysql - Join multiple tables where id may not exist -

i have 2 tables follows: table_a: id, title table_b: id, table_a_id, status i want select total number of entries in table_b each value of table_a, total number of entries in table_b not reference table_a. for example, let's table_a has values: {id, title} (1, "value 1") (2, "value 2") (3, "value 3") and table_b has following entries {id, table_a_id, status} (1, 1, 'open') (2, 1, 'closed') (3, -, 'open') (4, 2, 'closed') what trying along lines of: ("value 1", 2) ("value 2", 1) ("value 3", 0) (-, 1) without nulls, write as: select table_a.id, table_a.title, count(table_b.id) table_a left join table_b on table_a.id = table_b.table_a_id group table_a.id, table_a.title however, doesn't give me values entries in table_b not reference table_a. if reverse join, can values table_b, not table_a. how can both in single query? i'm using sql server, gues...

change the stack on the fly of c program -

i writing following code able change stack of function call. runs segfault on printf. debugged code assembly, stack switched. printf statement created segfault , not sure reason. has clue direction should more? thanks. char stack[4000000*4]; void foo(int ad) { int = 100; int sum = i*i + ad; printf("stack changed %x\n", stack); } /* in example, foo (and decendents) live on new stack */ void change_stack(void *newstack) { void *ctx[5]; // jump buffer setjmp/longjmp. if (0 == __builtin_longjmp(ctx)) { ctx[2] = newstack; // switch stack __builtin_longjmp(ctx, 1);/* here stack switched */ } else { /* live on new stack, can pass parameters ? */ int ad = 20; foo(ad); } } int main (int argc, char** argv) { int = 10; change_stack(stack); printf("return, %d\n", i); return 0; } you switch stacks without copying contents of old one. when change_stack returns, results undefined (it may, examp...

asp.net - LINQ and web service cannot return anonymous types, and you cannot construct an object in a query? -

web services cannot return anonymous type. if building linq query using classes through datacontext... cannot construct instances of classes in query. why want this? want join 3 "tables" or sets of objects. have 3 items foreign key each other. , lowest, detailed of these represented class had fields other 2 represent data those. in linq query want return list of lowest, detailed class. 1 way have decided "join tables together" , return data each of them via linq sql via webservice. may bad practice. not adding additional properties lowest level class. consider this... (please ignore naming conventions, driven internal consideration) reason need instantiate anonymous type join... don't know why is... if not way error... from su in _datacontext.gettable<stateupdate>() join sfs in _datacontext.gettable<systemfacetstate>() on new { su.lngsystemfacetstate } equals new { lngsystemfacetstate = sfs.l...

c# - Concat return values from different methods in same class to one value in another method -

is possible concat different return values different methods in same class 1 method? trying want take return values methods/functions , trying bring them 1 string or number in public static int generateid(). here code: static void main(string[] args) { int dateofbirth; string name; string surname; string firstletr; console.writeline("please enter date of birth in next sequence: yymmdd"); int dob = int.parse(console.readline()); dateofbirth = idenity.dateofbirth(dob); console.clear(); console.writeline("please enter firsletter of name :"); name = console.readline().toupper(); console.writeline("please enter firsletter of surname:"); surname = console.readline().toupper(); firstletr = idenity.firstletters(name, surname); console.clear(); } } class idenity { int dateofbirth, x, y, z; string name, surname, male, fem...

How can I set application wide proxy settings in Qt? -

i have posted efforts google maps display in webview. discovered needed install openssl https used of google apis. that's , on different machine having touble configuring qt use system proxy. 1 have 1 system proxy not require authentication , 1 does. default proxy 1 require authentication. i have following code specify proxy: #include <qtgui/qguiapplication> #include "qtquick2applicationviewer.h" #include <qnetworkproxy> int main(int argc, char *argv[]) { qguiapplication app(argc, argv); qnetworkproxy proxy; proxy.settype(qnetworkproxy::httpproxy); proxy.sethostname("url.of.proxy.not.requiring.authentication"); proxy.setport(8080); qnetworkproxy::setapplicationproxy(proxy); qtquick2applicationviewer viewer; viewer.setmainqmlfile(qstringliteral("qml/maps/main.qml")); viewer.showexpanded(); return app.exec(); } when run application web page displayed in webview contents state ther...

c# - EntityFramework Generic Repository, multiple include? -

i trying change generic retrieve method generic repository. want instead pass string includeproperties, pass this: params expression<func<tentity, object>>[] includeproperties = null thing when call method: public virtual ienumerable<tentity> retrieve(expression<func<tentity, bool>> filter = null, params expression<func<tentity, object>>[] includeproperties = null) i want example: tentityexample.retrieve(filter: c=>c.id=id, includeproperties:c=> c.propertynav1, e=> e.propertynav1.propertynav3, e=> e.prop4) or if dont need navigation properties tentityexample.retrieve(filter: c=>c.id=id) but dont know why includeproperties: not working, not accepted, know why, or if doing wrong. want possibility dont pass includeproperties or pass specifying includeproperties: public virtual ienumerable<tentity> retrieve(expression<func<tentity, bool>> filter = null, string includeproperties = "") ...

javascript - object.style.fontSize not retrieving value -

i moved css styling on div tag inline styling external stylesheet. css tag follows: #ntext{ position:absolute; top:204px; left:100px; width:197px; height:45px; text-align:center; font-size:24px; white-space:nowrap; color:#ffffff; font-family:times new roman, times, baskerville, georgia, serif} i have javascript function meant reduce font size of div follows: function rdtext() {var txt = document.getelementbyid("ntext"); var fstring = txt.style.fontsize; var fnum = parseint(fstring); fnum -=1 ; txt.style.fontsize= fnum+"px"} this function worked before moved styling not. tracked problem down .style.fontsize not receiving value of font size attribute didn't return correct value ("24px") when tested alert(). css appears attached because functions change other parts color work fine. able adjust font size manually in style sheet. i'm making stupid mistake here life of me don't know is. this job getcomputedstyle() f...

Grails Service Calls From TagLib Overhead -

i have simple taglib , service: class testtaglib { fooservice fooservice static namespace = "bar" def test = { out << "text" } } class fooservice { //this empty method absolutely nothing void foo() { } } if repeat taglib 20 times on page, executes instantly. if call service: ... fooservice.foo() out << "test" ... suddenly 20 taglibs cause page take 2 seconds load. doesn't seem right overhead of service call high...or it? how go debugging this? service methods default transactional. so, every call of fooservice.foo() getting overhead of complete database transaction creation , commit.

ios - Core Data not Persisting -

i'm having problem core data. have table view viewcontroller1 populated array populated data in core data model. when cell selected, push segue viewcontroller2 , can view saved data. there, have button called "edit" that, when selected, modal segue viewcontroller3 can edit data. here's code have saving edited data. //editmodel [self.editmodel setvalue:self.editnametextfield.text forkey:@"name"]; [self.editmodel setvalue:self.edittextview.text forkey:@"text"]; [self.editmodel setvalue:[nsdate date] forkey:@"date"]; nserror *error; if (![[self.delegate managedobjectcontext] save:&error]) { nslog(@"can't save edit: %@", [error localizeddescription]); } if (self.delegate) [self.delegate dismissedit:self]; else nslog(@"there no delegate"); however, whenever try calling this, nslog: can't save edit: (null) viewcontroller2 reflects change; table view in viewcontroller1 . but, when quit ...

php - How to call a function of a class from other function file? -

i know thats not best title question coulnd't come better 1 (suggestions welcome) well, situation, have 3 files: 1) classdbconn.php - in file connect db , have functions this: class dbconn{ var $conexion; private $querysql; var $respuesta; var $resultado; function __construct() { $this->conexion = @mysqli_connect('localhost', 'root', 'pass', 'database'); if(!$this->conexion){ die('error de conexion('.mysqli_connect_errno().')'.mysqli_connect_error()); } } function checkbracketganador($id_torneo){ $this->querysql = "select count(id_ganador) brackets id_torneo = '$id_torneo'"; $this->respuesta = mysqli_query($this->conexion,$this->querysql); $this->resultado = mysqli_fetch_array($this->respuesta); return $this->resultado[0]; } // more functions queries note: queries , functions fine 2)inc_conf.php - in file create session , object dbconn....

uibutton - Programmatically created a button on iOS, but no action when pressed -

i created button code below, not respond in log (supposed show "ha"). strangest part have been able exact code work inside collection view, not on viewcontroller. doing wrong button press "myaction"? -(void)viewdidload { uibutton *buttonz = [uibutton buttonwithtype:uibuttontypecustom]; buttonz.frame = cgrectmake(160, 0, 160, 30); [buttonz settitle:@"charge" forstate:uicontrolstatenormal]; [buttonz addtarget:self action:@selector(myaction:) forcontrolevents:uicontroleventtouchupinside]; [buttonz setenabled:yes]; [buttonz setbackgroundcolor:[uicolor bluecolor]]; //add button view [backimageview addsubview:buttonz]; } -(void)myaction:(id)sender { nslog(@"ha"); [self resignfirstresponder]; nslog(@"ha"); } 1) you don't need " resignfirstresponder " on button (seems of time see " resignfirstresponder " in text fields or text views)....

c# - Using a XML DataReader -

i using sqldatareader read data scenarios table such: string data = reader["scenariodata"].tostring(); however, scenariodata field xml ntext . how can read xml data datareader ? example, lets wanted read url " http://google.com ". scenario data field: <scenario name="scenario1" feature="feature1"> <steps> <step url="http://google.com"></step> </steps> </scenario> given fact have xml in variable of type string, suggest following : sqldatareader reader= cmd.executereader(); while (reader.read()) { ..... // have xml string stocked in data string data = (string)reader["scenariodata"]; // parse var doc = xdocument.parse(data); var step = doc.descendants("step").attributes().firstordefault(); var url = step != null ? step.value : string.empty; ...... } there way read xml using sqlxml, can find more information here

python - QLineEdit change border color without changing border style -

i can change background color of qlineedit widget in pyqt4 doing this: myeditfield.setstylesheet("qlineedit { background-color : green;}") changing border color requires me this: myeditfield.setstylesheet("qlineedit { border : 2px solid green;}") this undesirable because changes default shape , size of border, i've tried using border-color instead, apparently works if have specified border. there easy way this? you can set stylesheet following values: border-style: outset; border-width: 2px; border-color: green;

asp.net mvc - showing hatchstyles in javascript -

i want set background hatchstyle don't know how access system.drawing.drawing2d in javascript. table created javascript. example of table below. <table style="background:hatchstyle.cross> </table> thanks in advance you cannot access asp.net members in javascript. have define own css values hatch style in order javascript.

multithreading - Concurrent execution of scheduled tasks in Java -

i have timertask designed gather metrics @ specific interval. possible period of task execution less time of task execution (occasionally if times out , gets delayed). is there way execute multiple timertasks or runnables, threads, etc. concurrently without waiting previous task complete? i know timer uses single thread, , scheduledthreadpoolexecutor delay execution regardless of rate. thanks. i recommend using executors.newcachedthreadpool() or newcachedthreadpool(threadfactory threadfactory) own thread factory, in conjuction timer. code should this executor executor = executors.newcachedthreadpool(); timer time = new timer(); timer.scheduleatfixedrate(new timertask() { public void run() { executor.execute(new runnable() { public void run() { //your business logic } }); } }, delay, period); this way schedule tasks period , run concurrently.

c++ - Error in ffmpeg when reading from UDP stream -

i'm trying process frames udp stream using ffmpeg. run fine while av_read_frame() return either averror_exit (immeditate exit requested) or -5 (error number -5 occurred) while stream should still running fine. right before error prints following message console [mpeg2video @ 0caf6600] ac-tex damaged @ 14 10 [mpeg2video @ 0caf6600] warning mvs not available [mpeg2video @ 0caf6600] concealing 800 dc, 800 ac, 800 mv errors in frame (the numbers in message vary run run) i have suspicion error related calling av_read_frame quickly. if have run fast possible, error within 10-20 frames, if put sleep before reading run fine minute or , exit error. realize hacky , assume there better solution. bottom line: there way dynamically check if 'av_read_frame()' ready called? or way supress error? psuedo code of i'm doing below. in advance help! void getframe() { //wait here?? seems hacky... //boost::this_thread::sleep(boost::posix_time::milliseconds(25)); ...

asp.net - How does, for example, pastie.org work? Where code comes in and posted elswhere in the right format -

im working on asp.net mvc4 , im n00bie.. have done groudwork of website. sql server , linqtosql framework. i want able code , post somewhere else people change share friends , stuff. what find problem put in right format, in html.. how can set in html format. hope making self clear.. and help on right side above input field see dropdown menu. select html / xml.

html - Responsive Circle-cropped photos -

on site, i've created these little quote boxes contain 2-4 line quote, byline , byline description (or title/subtitle, whatever), , circularly cropped photo, absolutely positioned @ bottom left of box. i've done basic js fiddle . (the way works in actual code have sass mixin, class feeds circle diameter.): haml .circle-photo-div{ style: "background: url(#{photo_url})" } sass .circle-photo-div @include circle-photo(110) position: absolute bottom: -19% left: -7% @mixin circle-photo($diameter) width: #{$diameter}px height: #{$diameter}px border-radius: #{$diameter / 2.0}px -webkit-border-radius: #{$diameter / 2.0}px -moz-border-radius: #{$diameter / 2.0}px margin: 1em auto background-size: cover background-repeat: no-repeat background-position: center center -webkit-border-radius: 99em -moz-border-radius: 99em border-radius: 99em border: 5px solid white box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.8) at rate, i've m...

php - encoding issues with gbk pages , domxpath -

i'm trying curl link below in gbk. want extract title of product , image. when echo document test if it's working , dont chinese character. need extract using domxpath , display characters on website, same characters , not weird characters. how work? $ch = curl_init("http://item.taobao.com/item.htm?spm=a2106.m874.1000384.41.ag3kbi&id=20811635147&_u=o1ffj7oi9ad3&scm=1029.newlist-0.1.16&ppath=&sku="); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_binarytransfer, true); $content = curl_exec($ch); curl_close($ch); $doc = new domdocument(); $searchpage = mb_convert_encoding($content, 'utf-8', "auto"); $doc->loadhtml($searchpage); echo $doc->savehtml(); check if mbstring.language in php.ini set gbk, or explicitly use $searchpage = mb_convert_encoding($content, 'utf-8', "gb18030");

air - Supported languages contains an invalid value -

Image
when build flash builder 4.6 apache flex 4.9.1 , air 3.7, error indicating problem "supportedlanguages" node. i have tried of following , have failed: way worked in previous versions of flex sdk: <supportedlanguages>en es de fr ja ko pt ru zh ar pl</supportedlanguages> second attempt add local code: <supportedlanguages>en_us es_es de_de fr_fr ja_jp ko_kr pt_br ru_ru zh_cn ar_sa pl_pl</supportedlanguages> i tried adding commas: <supportedlanguages>en_us,es_es,de_de,fr_fr,ja_jp,ko_kr,pt_br,ru_ru,zh_cn,ar_sa,pl_pl</supportedlanguages> i have local directories each locale specified in: e:\program files (x86)\adobe\adobe flash builder 4.6\sdks\4.9.1_3.7\frameworks\locale e:\dev\myapp\src\locale i use line compiler: -swf-version=20 -locale=en_us,es_es,de_de,fr_fr,ja_jp,ko_kr,pt_br,ru_ru,zh_cn,ar_sa,pl_pl -allow-source-path-overlap=true -source-path=locale/{locale} if can avoid it, i'll never develop in fl...

mysql - Return to default value after field equals zero -

so need in trying make database field it's default 7 , each day minuses 1 until 0 day count starts again 7. possible? if how? select 7 - abs(0-dayofweek(now())) work. of course, since there 7 days in week, go 7,6,5,4,3,2,1,7. if want 0 indexed, use select 6 - abs(0-dayofweek(now())) 6,5,4,3,2,1,0,6. i've interpreted question liberally, however. if want count 8 days (7,6,5,4,3,2,1,0,7), want select 8 - (to_days(now())%8) .

sql - querying using two attributes in xml column -

i have seen examples querying using single attribute puzzled on how use 2 attributes. <componentcache> <component name="calc_todaydatelong" value="monday, may 06, 2013" /> <component name="calc_officename" value="default office" /> <component name="staffinfo_fullname" value="lee lee, jr" /> <component name="patinfo_fullname" value="jayne h doe" /> <component name="patinfo_birthdate" value="11/07/1901" /> <component name="patinfo_patientno" value="ag000003" /> <component name="encount_dxdesc1" value="abc" /> <component name="encount_dxdesc2" value="def" /> <component name="encount_dxdesc3" value="hijk" /> </componentcache> select documentstoreid, doctemplateid, personid, document documentstore datacache.value('/com...

asp.net - how to make the blue border on the image disappears in IE -

Image
so have image, linked page, here's example: the blue border appeared on image has links in them when refreshed page, it's appeared in ie, other browser don't make border appeared. caused this? idea? found solution! just add border-style:none; in css style code, , cheers :d

How to insert a variable in spss? -

i wanted inserted variable in middle of data file through syntax, not find way this, know how do? regards, ramamoorthy. match files file=* /keep=var1 var2 var3 . execute. using syntax can order variables in way want.

c# - Catch the exception thrown at client side when the server closed the pipe -

i checked similar questions question seems simpler , straightforward: there server , client , named pipe between. the client listens messages server sends (while loop). how detect server closed pipe, softly close client well? i saw 3 options: put pipehhandle.isclosed in while condition of listening client loop catch objectdisposedexception hoping catch end of communication , not other failures (this exception not give exception errorcode ). catch system.componentmodel.win32exception , check inside exception errorcode (-2147467259). standard put "if" in catch code? i did not find specific exception "ended pipe" although program (without catch) throw exception number 109 or -2147467259, confused. thanks help. the common way know other side dead "echo": once in while(let's every 10 seconds) client sends "echo" - meaning simple request server replay. if 3 echo in row(could more, depend on you) did not answered se...

Android FragmentActivity finish close twice -

i have fragmentactivity , add fragment below, fragmenttransaction ft = fm.begintransaction(); ft.add(r.id.main_fragment_container, mfragment, mtag); ft.commit(); but when call activity finish(), activity close normal, far good, after fragment show again , close. it's fast it's hard see on device (nexus 4). in galaxy s3, it's obvious see flash , disappear. have same problem? a fragment should attached fragmentactivity holds it, try calling fm.begintransaction().remove(mfragment).commit(); in onstop() method of fragmentactivity way can force fragment die before activity gone.

Uk Post Code Regex -

possible duplicates regex validate uk post codes i need regex syntax accepts posts codes following formates cr03jp cr03jp cr0 3jp cr0 3jp what have ^([a-pr-uwyz0-9][a-hk-y0-9][aehmnprtvxy0-9]?[abehmnprvwxy0-9]? {1,2}[0-9][abd-hjln-uw-z]{2}|gir 0aa)$ which accepts cr0 3jp rejects cro3jp cr03jp i have tried following also /((gir 0aa)|((([a-pr-uwyz][0-9][0-9]?)|(([a-pr-uwyz][a-hk-y][0-9][0-9]?)|(([a-pr-uwyz][0-9][a-hjkstuw])|([a-pr-uwyz][a-hk-y][0-9][abehmnprvwxy])))) [0-9][abd-hjlnp-uw-z]{2}))/i if has been answered please point me link use regex ^ ?(([beglmnswbeglmnsw][0-9][0-9]?)|(([a-pr-uwyza-pr-uwyz][a-hk-ya-hk-y][0-9][0-9]?)|(([enwenw][0-9][a-hjkstuwa-hjkstuw])|([enwenw][a-hk-ya-hk-y][0-9][abehmnprvwxyabehmnprvwxy])))) ?[0-9][abd-hjlnp-uw-zabd-hjlnp-uw-z]{2}$

java - How to fill a ScrolledComposite? -

i have class extending scrolledcomposite, within class have created composite intended fill parent scrolledcomposite. whenever add labels inner composite wraps upper right corner only. want inner composite fill outer scrolledcomposite. there way this? public class container extends scrolledcomposite { final composite comp; label namelabel, sizelabel, datelabel; arraylist<label> entrysize, date; arraylist<simpleentry> entry; color white; font font; public container(composite parent, int style) { super(parent, style); white = new color(getdisplay(), 255, 255, 255); font = new font(getdisplay(), "arial", 16, swt.bold); setbackground(white); setlayout(new gridlayout(1, false)); comp = new composite(this, swt.border); griddata compdata = new griddata(swt.fill, swt.fill, true, true); comp.setlayoutdata(compdata); setcontent(comp); comp.setbackground(w...

c# - Update & Insert into database using Odata service and linq -

i building windows-phone 8 app uses remote database. access database i've created odata dataservice (running on iis). i have ready succeeded in retrieving data database using data service. want update , insert data database using service. how do using linq? note: have read this but cant link work allready have: private void mainpage_loaded(object sender, routedeventargs e) { var ctx = new measurmententities(new uri("http://192.168.11.240:85/nfcdataservice.svc/")); var coll = new dataservicecollection<device>(ctx); lst.itemssource = coll; coll.loadcompleted += new eventhandler<loadcompletedeventargs>(coll_loadcompleted); var query = g in ctx.devices g.deviceid > 2 orderby g.devicename select g; coll.loadasync(query); } void coll_loadcompleted(object sender, loadcompletedeventargs e) { if (e.error !=...

Extract single quoted html attributes using xpath -

i want extract values of single quoted html attributes using xpath. have used jtidy clean html doc , code looks this: try { string data = string.tostring(); inputstream input = new bytearrayinputstream(data.getbytes()); document document = new tidy().parsedom(input, null); xpathfactory factory = xpathfactory.newinstance(); xpath xpath = factory.newxpath(); xpathexpression expr = xpath.compile("//a[@class='swatch-2011-link']/@color"); object evaluate = expr.evaluate(document, xpathconstants.nodeset); nodelist list = (nodelist) evaluate; system.out.println(list.getlength()); (int = 0; < list.getlength(); i++) { string name = list.item(i).getnodevalue(); system.out.println(name); } } catch (xpathexpressionexception e) { e.printstacktrace(); } <a class="swatch-2011-link" style='background:url(somelink); background-size:26px 26px; filter:progid:dximagetransform.microsoft.alphai...

c# - ASP MVC 4, passing data in custom editor template -

i'm using line of code call custom editor template. @html.editor("country", "customdropdown", countryselectionlist) i'd access countryselectionlist in customdropdown view , iterate on items: how can that? countryselectionlist of type selectlist . this tried in view: @model selectlist @foreach (var item in model.items) { <div>@item.tostring()</div> } but got object reference not set instance of object error. so how can that? i'd own dropdown list: impossible without iterating on key + value pairs of selectlist. @html.partial("~/views/shared/editortemplates/customdropdown.cshtml", customercountryselectionlist) and models goes straight view. @html.editor() , despite having 6 overloads, have none of them designed pass model inside custom editor.

python - splitting lists and values -

within python script have 2 floating values , 2 lists write in csv file. lonwgs84 , latwgs84 floating values , col1s , col2s lists. when write csv file with: with open(ausgabe, "wb") f: datawriter = csv.writer(f) each in zip(lonwgs84 , latwgs84, col1s, col2s): cols = each[0] , each[1], each[2] + each[3] datawriter.writerow(cols) i following output: 51.821336803,11.6756790532,"['~11:16:05.833', '$gpgga', '091607.00', '5149.28020818', 'n', '01140.54074319', 'e', '', '', '000.01']" but need is: 51.821336803,11.6756790532,~11:16:05.833,$gpgga,091607.00,5149.28020818,n,01140.54074319,e,,,000.01 i tried split, seem work strings. maybe has idea how this? lot! simply slice row first 2 elements, concatenate 3rd , 4th: datawriter.writerow(each[:2] + each[3] + each[4]) alternatively, unpack elements first: for fp1, fp2, lst1, lst2 in zip(lon...

android - Detect winning in TicTacToe game.... in 'for' loop -

i new in android programming, want write tictactoe game more learning, followed this article ( enter link description here ) , changed part of article better understanding ;) my problem in validategame() method, when write cross in 1 horizontal line (i mean exapmle : coordinate[0][0]=x, coordinate 0 =x, coordinate[0][2]=x), method should run first 'for' loop , write in log , toast "horizontal x", method run second 'for' loop , write in log "vertical x". anyway, method can detect x or o can not detect horizontal line or vertical line. problem? how can solved this? can not understand validate_game() method in article , want write method myself ;) please me. cheers. public boolean validategame(){ cell check=null; int counter=0; xsymbol xsym=new xsymbol(); osymbol osym=new osymbol(); //horizontal for(int i=0;i<coordinate.length;i++){ check=null; for(int j=0;j<coordinate.length;j++){ ...

C#: Gets unmatched elements between 2 collections with Linq & Lambda -

i have 2 collections, compare them , want unmatched items , put new collection. don't want use conventional method using 2 foreach loop. how implement using linq , lambda expression? e.g. int[] collection1 = new int[] { 1, 2, 3, 4, 5 }; int[] collection2 = new int[] { 2, 3 }; // goal: using linq , lambda expression: new collection3 should contain 1, 4, 5 edited: sorry forget mention: collection2 subset of collection1, therefore elements in collection2 must exist in collection1. var result = collection1.except(collection2).concat(collection2.except(collection1)).toarray();

sharepoint - Sharepint document library design- customization -

i seek in customizing document library in sharepoint site particular requirement. as per requirement, student record created , need go through workflow approved. few relevant documents attached student record. these attached documents need go through workflow , need approved taking example: student record, have 4 documents uploaded there 5 workflows (1 student , 4 individual documents) can achieved using 1 document library? what design/solution scenario? create custom list stores student details , add workflow list. create document library , add lookup column of student details list , add workflow document library. this way, multiple documents can added student , approval workflow go through documents added student record. think not possible achieve requirement using 1 document library.

sql - Creating a table with data from 2 other tables -

i working in access , utilizing vba make queries in wich have variable names, can't use query wizard in access i have following 2 tables: tblkabelinfo and table name varies depending on else in program tblname1 string the tables this: tblkabelinfo: +--------------+----------+----------+----------+ | kabelnummer | data |more data |even more | +--------------+----------+----------+----------+ | 1 | x | x | x | +--------------+----------+----------+----------+ | 2 | x | x | x | +--------------+----------+----------+----------+ | 3 | x | x | x | +--------------+----------+----------+----------+ | 4 | x | x | x | +--------------+----------+----------+----------+ tblname1: +--------------------------------+----------+----------+ | filename | bla | databla | +--------------------------------+---------...

php - Windows Azure MaxSizeInByte Statement -

i want current max size of db. have found statements checked out. works fine in vs2012 sql explorer. when im using php im geting no data. this function: function getload() { $conn = connect(); $string = 'databasepropertyex ( 'database' , 'maxsizeinbytes' )'; $stmt = $conn->query($string); return $stmt->fetchall(pdo::fetch_num); } the problem error in fetching $stmt. error is: can not fetchall(11) this code print database edition , max size in gb: <?php function get_database_properties($server, $database, $username, $password) { try { $conn = new pdo ("sqlsrv:server=tcp:{$server}.database.windows.net,1433; database={$database}", $username, $password); $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); $conn->setattribute(constant('pdo::sqlsrv_attr_direct_query'), true); $query = "select convert(nvarchar(128), databasepropertyex ('{$database}', ...

hadoop - Cloudera-Agent giving error - 'Hostname is invalid; it contains an underscore character.' -

i'm trying setup hbase cluster on 4 virtual machines using cloudera-manager installer (as suggested in installation guide). cloudera-manager version 4.6.1, cdh version 4.3 , os centos-6.4. after parcels installed , cloud-era agent tries start, following errors reported : 'hostname invalid; contains underscore character.' /usr/lib64/cmf/agent/src/cmf/agent.py : 315. i can see underscore( '_') check in host-name @ line 315 of agent.py. cross-checked our previous setup of cdh3.4 , there no such validation. can some-one developer/user confirm if check relevant , whether underscore('_') not used internally in cdh code parsing logic? did able install underscore in hostname? appreciate input on issue. thanks, abhishek ps : disabled check , cloud-era agent started , configured roles various hdfs services on these nodes. services not coming healthy. changing host-name not in hand , have been told due xyz reasons, it'll take time. excerpt wi...

objective c - Move x and y coordinates of object on selection -

is possible on selection of object in case search bar, move top of application view? how that? currently search bar in middle of screen , when press/click on table view appears under it. normally, when press/click search bar navigation bar disappears , search bar moves up. because have moved search bar middle of application , hid navigation bar no longer jumps top on selection. you try uiview animatewithdurations . so you'd have code along lines of: [uiview animatewithduration:0.3f animations:^{ [yoursearchbar setframe:cgrectmake(newx, newy, yoursearchbar.frame.size.width, yoursearchbar.frame.size.height)]; } completion:^(bool finished) {} ]; that'll animate move new x , y coordinate can set want bar to. have in function that's triggered when uisearchbar receives touch event.

vb.net - How to print a scrollable winforms application which has scrollable textbox vb .net -

i using vb .net , print scrollable winform has scrollable textbox. i have tried use following codes: private sub btnprintform_click(byval sender object, byval e system.eventargs) handles btnprintform.click me.printform1.printersettings.defaultpagesettings.landscape = true printform1.print(me, powerpacks.printing.printform.printoption.scrollable) end sub and print preview shows half of winforms, not complete. 1) how can print winforms (full width , height) although of winforms areas hidden due scrollable feature? refer screenshot in following website: print error screenshot 2) recommended method prompt user change page orientation? 3) in winforms, there scrollable textbox. how affect print function , changes should include scrollable textbox , content in scrollable winforms? maybe me, not print forms.. more... used in vb6 , quite upset when .net removed functionality. think re-learning printing .net intended way, physically drawing document... or using r...

mysql - Converting String to date in PHP for Date and time like 18 July, 2013 12:00 -

i have date , time stored string in following format "18 july, 2013 12:00" in mysql database. i using wordpress website, date meta_key of post. i need them converted, string date , time. strtotime() function not working format. want saperate month , date. also tried echo date( 'format', strtotime("18 july, 2013 12:00") gives 01/01/1970 output i think reason why it's not working because of format passed on str_to_date() invalid. try this, select str_to_date(yourcolumn, '%d %m, %y %h:%s') newdatetime tablename but if want separate month , date, resulting value string month. select date_format((str_to_date(yourcolumn, '%d %m, %y %h:%s'), '%m') month, date(str_to_date(yourcolumn, '%d %m, %y %h:%s')) dateonly tablename tablename

How should I assigned the same value to two different keys in this Perl hash? -

when have 2 data structures meaning same thing, ex: $c->req->cookies->{app1} = $c->req->cookies->{general}; $c->req->cookies->{app2} = $c->req->cookies->{general}; can write: ( $c->req->cookies->{app1}, $c->req->cookies->{app2} ) = $c->req->cookies->{general}; ? also, can write: $c->req->cookies->{app1} = $c->req->cookies->{app2 } = $c->req->cookies->{general}; ? the second form possible , people use frequently $x = $y = $z; the first form not need. assings value first variable. ($x, $y) = $z; you need 2 member list on right hand side well: ($x, $y) = ($z) x 2; update: in case, can use x operator if methods involved return same values both invocations, otherwise, can use ($x, $y) = map $obj->method, 1, 2;

javascript - converting format of JSON -

i using ajax query fuseki , want visualize in d3.js collapsable tree . fuseki returns json in format d3.js code not recognise. this: { "head": { "vars": [ "s" ] } , "results": { "bindings": [ { "s": { "type": "uri", "value": "http://www.co-ode.org/ontologies/pizza/2005/05/16/pizza.owl#fourcheesestopping" }, "p": { "type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#subclassof" }, "o": { "type": "uri", "value": "http://www.co-ode.org/ontologies/pizza/2005/05/16/pizza.owl#cheesetopping" } ] } } i need convert json format: { "name": "pizza", "children": [ ...