Posts

Showing posts from July, 2010

pymc - Mixture model of a normal and constant -

Image
i'd model distribution mixture of normal , constant 0. i couldn't find solution because in mixture examples i've found class of distribution same every category. here code illustrate i'm looking for: with pm.model() model: x_non_zero = pm.normal(...) zero_rate = pm.uniform('zero_rate', lower=0.0, upper=.0, testval=0.5) fr = pm.bernoulli('fr', p=zero_rate) x = pm.???('x', pm.switch(pm.eq(fr, 0), x_non_zero, 0), observed=data['x']) i'm interested in rate data 0 , parameters of normal when non-zero. here how data i'm modelling looks like: one option try gaussian mixture model, may think of gaussian sd=0 constant value. option use model following: with pm.model() model: mean = pm.normal('mean', mu=100, sd=10) sd = pm.halfnormal('sd', sd=10) category = pm.categorical('category', p=[0.5, 0.5], shape=len(x)) mu = pm.switch(pm.eq(category, 0), 0, mean)

angularjs - Waitforangular call timed out if there are no http call on page -

we using protractor framework e2e testing. we have seen odd behavior waitforangular(); call getting timed out if there no http call on page. working fine if using sleep call in place of waitforangular(); call. please share views solve issue. thanks in advance. try add : describe("long asynchronous specs", function() { beforeeach(function(done) { waitforangular(); done(); }, 10000); // code here waitforangular(); aftereach(function(done) { waitforangular(); done(); }, 10000); }

ios - SKNode touching other SKNode recognition -

i'm creating new game project, , requires basic interactions between sprites. wondering how implement skphysicscontact class detect when 2 skspritenodes touch. here skphysicscontact class reference: https://developer.apple.com/library/ios/documentation/spritekit/reference/skphysicscontact/#//apple_ref/occ/instp/skphysicscontact/contactnormal i'm not sure how use bodya , bodyb methods detect touches whenever try use it, can't seem figure out how use class. ideas on how use class detect touches between 2 bodies? once scene contact delegate , calls didbegincontact, , didendcontact. these methods uses both body , body b tell whats colliding. there decide want happen when collide, example make bodya = nil.

c++ - When using cout and cin, what are the "<<" and ">>" operators doing and why do we use them? -

for example: int age; cin >> age; cout << "you " << age << " years old!" << endl; why use "<<" , ">>" operators here? doing? understand bit-shifting, don't how works here. they called stream insertion operator ( << ) , stream extraction operator ( >> ). these same operators left , right bit shift operators (even though have different names). bit shift operators overloaded, when left side stream, read or write stream. they're function call - works like: leftshift(leftshift(leftshift(leftshift(cout, "you "), age), " years old!"), endl); except function called operator<< instead of leftshift . strictly speaking, there's no reason function called leftshift has left shift, , likewise there's no reason function called operator<< has left shift.

xsd - ACA AIR XML - TestFileInd no longer in 7.0 but the pub claims it needs to be there still -

so in publication 5164 (rev. 11-2015) says in 4.3: the manifest requires each transmission carry test file indicator (testfileind) indicate if transmission test or production transmission. however, cannot find anywhere in of xsd files of 7.0. see in old 6.2 xsd files however. still need include this? testfileind in fact remnant of 6.2 , need testfilecd. submitted test scenario 1 no issues without it.

sublimetext3 - Sublime text 3 plugin to get JSON path -

i after plugin or technique in sublime text 3 call qualified path of json element selected in editor window. somethink like: http://jsonpath.com/ i want result somewhere can copy, want use documentation, not programmatically. not need https://github.com/jayway/jsonpath standard, produces readable/meaningful path element.

graphics - find the point at which two Paths cross in android -

okay, have 2 simple separate path objects, 1 containing straight line created lineto , 1 containing curve generated quadto function. need point (x, y) these 2 objects insect, once distance 1 side of arc of point intersect. there lots of posts figuring out if intersect, can't find information on how figure out intersect. edit! still can't figure out, i've been trying fake measuring distance along yellow line black lines drawn apart each other , making whole new curve. it's sloppy , not working well. see image! if can distance end black curve intersects yellow line, can segment of curve, , 2 points on it's end, , work great! any ideas, anyone? :) thanks!

c++ - What are the uses of std::chrono::high_resolution_clock? -

at first thought can used performance measurements. said std::chrono::high_resolution_clock may not steady ( is_steady may false ). said std::chrono::high_resolution_clock may alias of std::chrono::system_clock not steady. can't measure time intervals type of clock because @ moment clock may adjusted , measurements wrong. at same time can't convert time points of std::chrono::high_resolution_clock calendar time because doesn't have to_time_t method. can't real time type of clock either. then can std::chrono::high_resolution_clock used for? there none. sorry, my bad . if tempted use high_resolution_clock , choose steady_clock instead. on libc++ , vs high_resolution_clock type alias of steady_clock anyway. on gcc high_resolution_clock type alias of system_clock , i've seen more 1 use of high_resolution_clock::to_time_t on platform (which wrong). do use <chrono> . there parts of <chrono> should avoid. don't

Proving a type empty in Agda -

i trying prove 2*3!=5 in agda. define function signature 2 * 3 ≡ 5 → ⊥. making use of definition of multiplication data _*_≡_ : â„• → â„• → â„• → set base : ∀ {n} → 0 * n ≡ 0 succ : ∀ {n m k j} → m * n ≡ j → j + n ≡ k → suc m * n ≡ k i have proven 1*3≡3 : 1 * 3 ≡ 3 1*3≡3 = (succ base) znn and 3+3≡5 : 3 + 3 ≡ 5 → ⊥ 3+3≡5 (sns (sns (sns ()))) but when try prove: m235 : 2 * 3 ≡ 5 → ⊥ m235 ( ( succ 1*3≡3 ) ( x ) ) = ( 3+3≡5 x ) the compiler spits out error x .j != (suc 2) of type â„• when checking expression x has type 3 + 3 ≡ 5 sorry if stupid question. in advance. first of all, forgot include definition of _+_≡_ . assume it's follows: data _+_≡_ : â„• → â„• → â„• → set znn : ∀ {n} → 0 + n ≡ n sns : ∀ {n m k} → n + m ≡ k → suc n + m ≡ suc k next, problem not finding correct syntax, have figure out how can conclude value of type 2 * 3 ≡ 5 . pattern matching have done, can ask agda values available in context, replacing right-hand-side ?, calling c-

disable chrome http request throttling in extension -

how can disable anti ddos throttling inside chrome extension? working set flag --disable-extensions-http-throttling inside extension shortcut, not acceptable when extension running on many clients (i need set manually on client). i have tried disable in background.js script, not working: chrome.webrequest.onheadersreceived.addlistener( function(info) { var headers = info.responseheaders; var throttleheader = {name: 'x-chrome-exponential-throttling', value: 'disable'}; headers.push(throttleheader); return {responseheaders: headers}; }, { urls: ['*://*/*'], // pattern match http(s) pages types: ['sub_frame', 'xmlhttprequest'] }, ['blocking', 'responseheaders'] ); are there other ways disable throttling extension? using latest version of chrome (50.0.2661.102 m) there no way disable throttling within extension. allowing developers defeat purpose

android - Kernel bash scripts compilation error -

last time tried compile kernel device runs android, faced strange issues, shown here following errors: /cmsource/kernel/samsung/msm7x30-common/scripts/mkmakefile: line 5: $'\r': command not found cmsource/kernel/samsung/msm7x30-common/scripts/mkmakefile: line 12: $'\r': command not found /cmsource/kernel/samsung/msm7x30-common/scripts/mkmakefile: line 59: warning: here-document @ line 24 delimited end-of-file (wanted `eof') cmsource/kernel/samsung/msm7x30-common/scripts/mkmakefile: line 60: syntax error: unexpected end of file the mkmakefile bash script know i tried solve compilation errors couldn't figure out. i suspecting this: made various changes in git in 1 week ago following changes: git config --global core.autocrlf input git config --global core.whitespace trailing-space,space-before-tab,inden git config --global core.autocrlf true i saw following post while searching on net: the post on stackoverflow i must downloaded kernel source u

ios - Cannot setup AVAudioPlayerDelegate in a Manager class -

i using manager class initialize global variable in appdelegate.swift class manage playing music in app. here's of code manager class import foundation import avfoundation import mediaplayer /* protocol playerdelegate : class { func soundfinished(sender : anyobject) }*/ var quotelist = [quote]() var israndomquote = false enum alarmtypes { case song case quote case randomquote } var myavaudioplayer:avaudioplayer = avaudioplayer() var mpmediaplayer = mpmusicplayercontroller() public class mediamanager: nsobject, avaudioplayerdelegate{ //weak var delegate : playerdelegate? var mpmediaitem: mpmediaitemcollection! var quoteselected = quote() var alarmtype = alarmtypes.randomquote func selectrandom(){ self.alarmtype = alarmtypes.randomquote quoteselected = pickrandomquote() } func selectsong(mpmedia: mpmediaitemcollection){ self.alarmtype = alarmtypes.song mpmediaitem = mpmedia } func selectquote(quote: quote){ self.alarmtype = alarmtypes.quote qu

vb.net - Dataadapter for each datagridview wont work -

i have 3 datagridviews datagridview1, datagridview2, datagridview3 each datagridview being bind using different data adapters , different bindings datapter1, dataadapter2, dataadapter3, binding1 binding2 , binding3 'binding dgv1 datapter1.selectcommand = mycmd datapter1.fill(dset, "something") binding1.datasource = dset.tables("something1") datagridview1.datasource = binding1 'binding dgv2 datapter2.selectcommand = mycmd datapter2.fill(dset, "something") binding2.datasource = dset.tables("something2") datagridview2.datasource = binding2 'binding dgv3 datapter3.selectcommand = mycmd datapter3.fill(dset, "something") binding3.datasource = dset.tables("something3") datagridview3.datasource = binding3 when time wanted update datagridview1 dim firstbuilder new mysqlcommandbuilder(me.dataadapter1) me.dataadapter1.update(me.binding1.datasource) me.binding1.resetbindings(false) it prompts me

linq - EntityFramework 6 in ASP.NET MVC4 Data Annotations -

i want data between db.tableas , db.tablebs using following method: class tablea.cs: public class tablea { [key] public int id {get;set;} public int tablebid {get;set;} public string description{get;set;} public virtual tableb tablebs{get;set;} } class tableb.cs: public class tableb{ [key] public int id {get;set;} public int tableaid {get;set;} public string description{get;set;} public virtual tablea tableas{get;set;} } i have functions need tableb's data tablea , functions need tablea's data tableb. doing getting error: unable determine principal end of association between types 'tablea' , 'tableb'. principal end of association must explicitly configured using either relationship fluent api or data annotations. can know how data without codes below: tableb tableb = _tablebmodel.getsingle(tablea.id); public tableb getsingle(int id) { return db.tablebs.where(e => e.id == id).firstordefault()

Android Change language of speech to text to Japanese not working -

hi i'm making japanese learning app android. 1 of features speak app in japanese check if saying words correctly. got working promptspeechinput did not ui getting in way decided go rout , have fragment implement recognitionlistener . reason japanese not working , shows english words. i'm not sure what's wrong. here code speech fragment public class speechfragment extends fragment implements recognitionlistener { private textview textviewinput; private togglebutton buttonspeak; private speechrecognizer speech = null; private intent recognizerintent; public speechfragment() { // required empty public constructor } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view = inflater.inflate(r.layout.fragment_speech, container, false); speech = speechrecognizer.createspeechrecognizer(this.getcontext()); speech.setrecognitionlisten

assembly - Simple bootloader and bochs -

i have simple bootloader written in at&t syntax. [bits 16] [org 0x7c00] jmp $ times 510-($-$$) db 0 dw 0xaa55 i use yasm -f bin -o boot.bin loader.s compile it, , bochs run. dd if=boot.bin bs=512 of=floppy.img bochs -q but bochs said there no bootable device . so, have following questions: how can rewrite at&t syntax (which construction must use instead times 510-($-$$) db 0) ? what wrong bochs? thanks! p.s. bochs compiled x86_64 support, doesn't work bochs official arch repo. i can't imagine why you're trying write at&t syntax if don't know at&t syntax! think "times" line be... .org 0x7dfe .word 0xaa55 bochs looking entire 1.44m floppy image.

MongoDB - Update or Insert object in array -

i have following collection { "_id" : objectid("57315ba4846dd82425ca2408"), "myarray" : [ { userid : objectid("570ca5e48dbe673802c2d035"), point : 5 }, { userid : objectid("613ca5e48dbe673802c2d521"), point : 2 }, ] } this questions i want push in myarray if userid doesn't exists, should appended myarray. if userid exists, should updated point. i found this db.collection.update({ _id : objectid("57315ba4846dd82425ca2408"), "myarray.userid" : objectid("570ca5e48dbe673802c2d035") },{ $set: {"myarray.$.point": 10} }) but if userid doesn't exists, nothing. and db.collection.update({ _id : objectid("57315ba4846dd82425ca2408") },{ $push: {"myarray": {userid: objectid("570ca5e48dbe673802c2d035"), point

dc.js - Making DCJS histogram based on the calculated average -

i have long format data following. year company value 2001 aaaaaaa 200 2002 aaaaaaa 300 2003 aaaaaaa 400 2001 bbbbbbb 150 2002 bbbbbbb 250 2000 ccccccc 500 2001 ccccccc 600 2002 ccccccc 550 is possible calculate average of income each company , make histogram calculated average on dc.js? what first did make dimension company , calculate average, tried make average key . problem faced there if tried make histogram out of that, have reducecount average dimension. of course average not exist on crossfilter object. this jsfiddle script. http://jsfiddle.net/adamist521/n1383zdk/3/ final image of graph included in script. probably related 1 couldn't figure out how deal non-integer average. dc.js histogram of crossfilter dimension counts to calculate running average (crossfilter running calculations) need keep track of both sum , count. once have these, calculating average trivial. in fact, should not calculate averages in crossfilter @ all, track compo

ssms 2014 - Visual Studio 2013 High DPI workaround causes debugger to fail -

similar question visual studio 2013 high dpi on 4k screen had posted answer have removed since uncovering issue below. i have bought new 4k laptop , have been having problems high dpi display of ssis package designer , dialogs in vs2013 dialogs etc in ssms. a workaround found ssms enable bitmap scaling , create manifest file - ssms.exe.manifest - in same folder ssms.exe. this article describes how fix ssms http://www.sqlservercentral.com/blogs/spaghettidba/2015/10/14/ssms-in-high-dpi-displays-how-to-stop-the-madness/ for completeness, i've duplicated process described in article. set registry key: [hkey_local_machine\software\microsoft\windows\currentversion\sidebyside] "preferexternalmanifest"=dword:00000001 and paste xml manifest file. <?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0" xmlns:asmv3="urn:sche

java - Confirming Input with multiple inputs from JFrame and JOptionPane -

i creating simulation of harmonograph, , using abstract class paint method. have made 2 separate jframes , jpanels input window asking 8 numbers each. (my main frame , panel contain main ui). have joptionpane.showconfirmdialog delay reading of variables in panel, confirmation dialog pops before panel starts. here code: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.scanner; import java.lang.math; //@mark coats 5/11/16--jadeja 3 public class harm extends java.applet.applet implements actionlistener,mouselistener { int numy = 0; int numx = 0; int numa2,numf2,nump2,numd2; int numa1,numf1,nump1,numd1; int numa4,numf4,nump4,numd4; int numa3,numf3,nump3,numd3; // add scanner scanner key = new scanner(system.in); // add jframe jframe frame = new jframe("harmonograph sim"); //add jpanel jpanel pnlf = new jpanel(); // add canvas canvas c = new canvas(); // new jtextfield jtextfield uin = new jtextfield(15); //add fonts font btnf = new fo

2d numpy array to text file -

i have 3d-array storing temperature data. , me want put text file in 1 single line. need re-write code in pythonic way. jn in range(x1, x2): jm in range(y1,y2): fl.write(str((t[jn,jm] - 273.1).astype(int))+" ") fl.write("\n") assuming array save t : t.tofile('yourfile.txt',sep=" ",format="%s") also see question: how write multidimensional array text file?

Google App Engine vs Tomcat -

i able create basic 'hello world' program. when tried understand difference between cloud , server learned cloud have access virtual instance created exclusively , free choose , install software of choice.why google app engine(gae) used tomcat not used. major differences between gae , tomcat? cloud google cloud platform @ case. app engine 1 of services. app engine platform build apps on top of it. platform service or paas . simplifies process of building scalable application, , should use when understand need , understand principles of scalable application. tomcat java web container, , there're many alternatives. google app engine using jetty. use tomcat using flexible vm, though doesn't make sense. app engine not web server, it's set of services helps build scalable app. includes memcache, datastore, task queue, images api, deployments tools , versioning, cdn static files, , important automatic scale . actually aren't limited app engin

javascript - How to add an inner wrapper to an element in angular? -

i want angular diretive add inner wrapper dom element. unfortunately it's not wrapping replacing inner part of element. ( see plunker ) so have html snippet: <body ng-app="plunker"> <div class="outer" wrapp-my-content> <label>name: </label> <input type="text" ng-model="name" /> <p>hello {{name}}</p> </div> </body> the directive should change into <body ng-app="plunker"> <div class="outer" wrapp-my-content> <div class="inner-wrapper"> <label>name: </label> <input type="text" ng-model="name" /> <p>hello {{name}}</p> </div> </div> </body> but is <body ng-app="plunker"> <div class="outer" wrapp-my-content> <div class="inner-wrapper"> </div>

database - Postgresql : createdb prompt for password for user with no password -

i have create new user in pgsql no password. when try create database user prompts password >createuser -d -s -r -u postgres test1 password: >createdb -u test1 db1 password: i have tried superuser password gives me error : createdb: not connect database template1: fatal: password authentication failed user "test1" please help, thank you there alternative way create user prompting password. can give -p option while creating user. like: createuser -d -s -r -u postgres test1

qt - Working with CLSID_FilterGraph across different threads -

i'm using directshow in qt application. to create instance of filter graph, using qtconcurrent::run (i.e. using 1 of available threads in global app thread pool). here's simplified code sample runs in qthreadpool: graph_ptr createmoviegraph(const qstring & file) { ::coinitializeex(nullptr, coinit_multithreaded); auto * dst = graph_ptr(new moviegraph(path)); ::couninitialize(); return dst; } later, delete graph_ptr object in ui thread. afaik, qapplication ui thread works in sta threading model deletion works without crashes or memory leaks. correct? sometimes need pause or resume graph_ptr object in ui thread. // ui thread _graph_ptr->pause(); here's "pause" implementatino in graph_ptr object: _mediacontrolinterface->pause(); // ... // ccomptr<imediacontrol> _mediacontrolinterface; the imediacontrol interface queried in qthreadpool @ graph_ptr object initialization time. it turns out work object ui thre

selenium - How can you pass a parameter into you fitnesse test with soapui? -

i using soapui run fitnesse test page, send request jms queue , again run fitnesse test page: in soapui execute http test step http://hostrunningfitnesse.com:8000/testpage?responder=test&format=xml in soapui send request jms queue in soapui execute http test step http://hostrunningfitnesse.com:8000/testpagenumbertwo?responder=test&format=xml step 1 needs specific unique number testing created fitnessse when test page executed soapui when step 3 executed needs same unique number created in step 1. i thinking insert random number test page fitnesse soapui , keep random number in scope of soapui don't know how. thought of passing parameter through url localhost:8000/testpage?responder=test&format=xml& randomnr=2317391 not able retrieve parameter in fitnesse test page. somebody ideas? there no functionality in fitnesse passing arguments wiki page when invoke via url. has been asked couple of times in various forums, far no 1 has contributed so

c# - Collection as key in Dictionary -

i have dictionary this: var dic = dictionary<collection<myobject>, string> then add entry this: dic.add(myobjcoll, "1"); where myobjcoll contains single entry on second run try add entry dic myobjcoll has 2 entries (one of them same 1 in first run) , exception key exists. what missing here? expect dictionary key collection , surely 2 collections different number of entries cannot identical. edit: happened myobjcoll initialized outside foreach , during second iteration updated. thought new collection 2 entries old 1 entry collection additional entry added. to elaborate bit on issue: i have collection of product row objects. each product identification object consisting of collection of key value pairs: collection<productkeyvaluepair> productidentification; myproductrow.productidentification = productidentification; i have construct collection of productkeyvaluepairs defining "owner" of each product row object (one product r

sql server - How to check if a proposed T-SQL object name is valid or needs to be enclosed in square brackets -

my stored procedure may passed arbitrary string of characters @string varchar or nvarchar , no more 128 characters long. the stored procedure needs use @string value object name, i.e. name of table, field, view or similar. how can determine if value of @string supplied valid object name in - i.e. not reserved word , not contain invalid characters - or if require enclosure within (and escape of contained) square brackets in order make valid object name. for example, "x", "foo" , "c:\temp\x.csv" valid object names (yes, i've used "c:\temp\x.csv" as-is) , can used unmodified, while "select", "ab]c" , "1_abc" not valid, , need changed "[select]", "[ab]]c]" , "[1_abc]" i prefer solution doesn't attempt create object name , checks see if worked. preference given answers applicable on wider range of sql server versions rather latest version, , shorter, less complex c

jquery - Cross origin resource origin -

i have 1 page in joomla in have displyed 1 div use of $.ajax method. when i'm seeing page in other browsers firefox,chrome, safari etc looks fine.and data fetch ajax server looks good. but generates problem in ie browser.in ie when choose browser mode-ie-7 , document mode ie-7 div fetched ajax request not displaying(same occurs ie8-ie8, ie9-ie9). when change document mode standards looks of browser mode.but displaying warning "sec7118: xmlhttprequest http://ajaxrequesturl.com required cross origin resource sharing (cors). " as know warning generates problem in ie-7(browsermode) ie-7(documentmode) please let me know how solve problem?

android - How to get the Context of an Application in a Fragment -

first have error message caused by: java.lang.nullpointerexception: attempt invoke virtual method 'android.database.sqlite.sqlitedatabase android.content.context.openorcreatedatabase(java.lang.string, int, android.database.sqlite.sqlitedatabase$cursorfactory, android.database.databaseerrorhandler)' on null object reference @ android.database.sqlite.sqliteopenhelper.getdatabaselocked(sqliteopenhelper.java:223) @ android.database.sqlite.sqliteopenhelper.getwritabledatabase(sqliteopenhelper.java:163) @ net.purplebug.mydoctorfinder.mydbhandler.showdoctors(mydbhandler.java:133) @ net.purplebug.mydoctorfinder.homefragment.showdoctorlist(homefragment.java:131) so thought

html - how to make height of a div responsive? -

i want div if height of div exceeds 450px there scroller. able adding classname say, fixedscroll_450 div. <div class="fixedscroll_450" id="content"></div> now div's content generated dynamically, , if exceeds 450px of height there scroller otherwise not. styling add in class .fixedscroll_450{ min-height: 450px; max-height: 450px; width: 100%; margin: 0; overflow-y: auto; } it working fine.. want give height in percentage value not in pixel. but .fixedscroll_450{ min-height: 30%; max-height: 30%; width: 100%; margin: 0; overflow-y: auto; } is not working. height set 100% code. plz guide me.. use vh css unit height max-height: 30vh .fixedscroll_450{ max-height: 30vh; width: 100%; margin: 0; overflow-y: auto; } <div class="fixedscroll_450" id="content">lorem ipsum dolor sit amet lorem ipsum dolor sit ametlorem ipsum dolor sit ametlorem ipsum d

php - How to loop the query in this case? -

i have been trying loop query first value. when same command in workbench values. doing wrong here? answers appreciated! global $db; $stmt12 = $db->query('select `value` overriddenpropertyvalues parentguid "' . $itemguid . '";'); $propertyvaluerow = $stmt12->fetch(); while ($propertyvaluerow != null) { you fetching 1 value ->fetch() . that's why receive 1 value. example here : $query = $db->prepare('select `value` `overriddenpropertyvalues` parentguid :like'); $query->execute([':like' => $itemguid]); $stmt->bind_result($value); while ($query->fetch()) { echo $value."<br/>" }

java - How to import sun.misc.Unsafe in android studio? -

i trying use protobuf3 source code , uses "sun.misc.unsafe". can please let me know how import necessary package it. here sample code this class return unsafe instance on existing jvm implementations including android (both vm versions): https://github.com/noctarius/tengi/blob/master/java/tengi-core/src/main/java/com/noctarius/tengi/core/impl/unsafeutil.java this answer copy of noctarius' answer here: in android, how invoke sun.misc.unsafe methods using java reflection?

java - Hibernate Mapping - How to Join Three Tables -

this question has answer here: hibernate criteria returns children multiple times fetchtype.eager 6 answers i have 3 entity: person, car, , proffesion. @entity @table(name = "person") public class person implements serializable { @id private long id; @onetomany(mappedby = "person", fetch = fetchtype.eager) private list<car> cars; @onetomany(mappedby = "person", fetch = fetchtype.eager) private list<profession> professions; } @entity @table(name = "profession") public class profession implements serializable { @id private long id; @manytoone @joincolumn(name = "person_id") private person person; } @entity @table(name = "car") public class car implements ser

python - Returning concatenated string as global variable -

so here code using : global output_res output_res = "" def recurse(left, right, threshold, features, node, depth): spacer = spacer_base * depth if (threshold[node] != -2): """print(spacer + "if ( " + features[node] + " <= " + \ str(threshold[node]) + " ) {")""" output_res += spacer + "if ( " + features[node] + " <= " + \ str(threshold[node]) + " ) {" if left[node] != -1: recurse (left, right, threshold, features, left[node], depth+1) """print(spacer + "}\n" + spacer +"else {")""" output_res += spacer + "}\n" + spacer +"else {" if right[node] != -1: recurse (left, right, threshold, features, right[node], depth+1) """pri

performance - Why does the sorting algorithm work correctly? -

Image
i got sorting algorithm. know have been written in many other , more simple ways that's not point of question. here the algorithm : sort(a : array of n, : n, j : n) assert j-i+1 istwopotency if a[i] > a[j] swap a[i] , a[j] if i+1 < j k:= (j − + 1)/4 sort(a, i, j − 2k) sort(a, j − 2k + 1, j) sort(a, + k, j − k) sort(a, i, j − 2k) sort(a, j − 2k + 1, j) sort(a, + k, j − k) my question is, why algorithm work correctly in following case? sort(a, 1, length(a)) and array be: a[1 . . . length(a)] length(a) 2 potency , can assume there no identical numbers inside array . tested it, got no errors assume works correctly. how can prove algorithm works correctly in these conditions? and wondering how long algorithm needs running time. great if give me running time big theta notation (that's 1 understand best) f(n) = Θ(g(n)) correctness divide array 4 quarters, a1 through a4, , consider sub-array each element should end i

android - how to show the content of an xml file without knowing how many nodes are in that file -

i working on app suppose store photo , couple of strings few times day , show them. photo , strings stored in xml (photo's path not actual data) , want read xml file , show them. problem don't know how many instances of data in xml file can't prepare set number of photos , textviews in advance. show them in scrollable way of sorts , shown in gallery. the real question pretty best way show data in xml file without knowing how many node in file.

ios - get indexpath from collectionView, sometime get the wrong indexPath -

in uitableview can use code indexpath uitableview extension uiview{ func getbuttonindexpath(tableview:uitableview) -> nsindexpath{ let buttonoriginintableview = self.convertpoint(cgpointzero, toview: tableview) return tableview.indexpathforrowatpoint(buttonoriginintableview)! } } but doesn't work in uicollectionview extension uiview{ func getindexpath(uc:uicollectionview) -> nsindexpath?{ let senderp = cgpointmake(0, self.frame.height / 2) let point : cgpoint = self.convertpoint(senderp, toview:uc) let ind = uc.indexpathforitematpoint(point) print("what click is", point, ind) return ind } i put in button of cell in uicollectionview delbtn.addtarget(self, action: #selector(favviewcontroller.delfavaction(_:)), forcontrolevents: .touchupinside) and function func delfavaction(sender:uibutton){ guard let indexpath = sender.getindexpath(self.collectionvi

django - How to use special chars in admindocs? -

i have comments models special chars, examle: [...] informacjÄ… [...] but when run admin get: 'ascii' codec can't decode byte 0xc4 in position 23: ordinal not in range(128). passed in <django.utils.functional.__proxy__ object @ 0x7f0e3b35aa50> (<class 'django.utils.functional.__proxy__'>) i have: # -*- coding: utf-8 -*- at beginig of file. happen when install django-admin-tools try use unicode function: output = unicode(stringwithspecialchars)

entering regular expressions in javascript -

im trying add regular expression ^[a-za-z0-9,.&#-]{1-45}@[a-za-z]{1-45}.[a-z]{3}$ validate email addresses javascript code. if(email=="" || email==null) { document.getelementbyid("em_error").innerhtml="*you must enter email address"; error=true; return false; } else document.getelementbyid("em_error").innerhtml=""; you can use match function. if(email=="" || email==null || !email.match(/^[a-za-z0-9,.&#-]{1-45}@[a-za-z]{1-45}.[a-z]{3}$/,i)) note please review pattern, because there should longer , shorter tld 3 characters, .museum , .eu , .nowanytldcantakenformoney

java - How do I generate random address of a multi-dimension array? -

i'm stuck please help! the size of matrix n , m. for eg- n=4, m=3 1, 2, 3, 4 5, 6, 7, 8 9, 10, 11, 12 how generate random address? for eg- (0,0), (1,1), (1,2), (2,2), (3,3); -> last address should represents end element of matrix. -> next address should address of element either right or down. random random = new random(); list<integer> list = new arraylist<>(); int random_int_1 = 0, random_int_2 = 0; int = 0; list.add(2); list.add(1); while (list.get(i) < list.get(i + 1)) { list.add(random_int_1 = random.nextint(5)); list.add(random_int_2 = random.nextint(5)); i++; } (int j = 0; j < list.size() - 1; j++) { if (list.get(j) < list.get(j + 1)) system.out.print(list.get(j)); } and i'm improving skills solving such examples please tell me how should solve such problems. give to-do tasks oke, i'll try along. per example have current point, there

java - How can I default constants in IntelliJ to private? -

Image
when creating constant in intellij (using ctrl+alt+c), default public static final . how can make private static final instead? after ctrl + alt + c , press shortcut again, shows dialog more options. there visibility section. if select private here, new default when extracting constants next time.

How to manage absolute coordinate window in gtk3 python -

i translated treeview gtk2 tooltip in gtk3 it's running have problem manage coordinate of tooltip window. i tooltip window locate near mouse et follow near. instead of project tooltip window located in corner of screen my code #!/usr/bin/env python # coding: utf-8 ''' warning data not update !!!!!!!!!!!!! treeviewtooltips.py provides treeviewtooltips, class presents tooltips cells, columns , rows in gtk.treeview. ------------------------------------------------------------ file includes demo. execute file: python treeviewtooltips.py ------------------------------------------------------------ use, first subclass treeviewtooltips , implement get_tooltip() method; see below. add number of gtk.treevew widgets treeviewtooltips instance calling add_view() method. overview of steps: # 1. subclass treeviewtooltips class mytooltips(treeviewtooltips): # 2. overriding get_tooltip() def get_tooltip(...): ...