Posts

Showing posts from September, 2013

python - Read in a file, splitting and then writing out desired output -

i new python, , having problems can't seem find answers to. have large file trying read in , split , write out specific information. having trouble read in , split, printing same thing on , on again. blast_output = open("blast.txt").read() line in blast_output: subfields = [item.split('|') item in blast_output.split()] print(str(subfields[0][0]) + "\t" + str(subfields[0][1]) + "\t" + str(subfields[1][3]) + "\t" + str(subfields[2][0])) my input file has many rows this: c0_g1_i1|m.1 gi|74665200|sp|q9hgp0.1|pvg4_schpo 100.00 372 0 0 1 372 1 372 0.0 754 c1002_g1_i1|m.801 gi|1723464|sp|q10302.1|yd49_schpo 100.00 646 0 0 1 646 1 646 0.0 1310 c1003_g1_i1|m.803 gi|74631197|sp|q6bdr8.1|nse4_schpo 100.00 246 0 0 1 246 1 246 1e-179 502 c1004_g1_i1|m.804 gi|74676184|sp...

python - Pass some random value returned from a function to another function -

i stuck in situation need pass value (which random/different) returned function function, , sequence in functions called undefined figured @ run-time based on user inputs. for example, def func1(some_value): # use some_value whatever purpose # code return some_random_value def func2(some_value): # use some_value whatever purpose # code return some_random_value def func3(some_value): # use some_value whatever purpose # code return some_random_value so let's assume if func2 called first, initial/default value passed parameter some_value , function return some_random_value . now, don't know function called next, whatever function called some_random_value returned previous function (in case func2 ) should passed parameter some_value next called function (let func1 ). , process goes on , on. what recommended way achieve this? should done using global variable value amended each time function runs store function's return value...

Why does my variable's value is changed by a line that doens't touch it in Python? -

this question has answer here: why original list change? 2 answers the answer question seems pretty straightforward : can't doesn't. yet believe happening me , driving me crazy. therefore appreciate opinion. here's situation. i'm writing script has following function in : def reducereferencecode(): code = referencecode if e == 7: critlimit = 2 elif e == 4: critlimit = 1 if d < critlimit: in [4, 5, 6]: if code[i] >= critlimit: print referencecode code[i] = code[i] - critlimit print referencecode break else: code[7] = code[7] - critlimit code[9] = 1 return code the value of referencecode variable - passed argument program sys.argv - cha...

mysql - How to obtain value from inner request. Function return undefined -

i'm trying quiz table quizzes , after obtaining trying array of answers table questions. doesn't work i send questiondto(json) this.add method, question i've added in table , need add answers , var question = require('../models/question'); function quiz() { this.getbyid = function(quizid,res) { connection.acquire(function(err, con) { con.query('select * quizes `id` = ? ', quizid, function(err, result) { con.release(); result.questions = question.getallbyquizid(quizid); res.send(result); }); }); }; question.getallbyquizid(quizid); has return array of questions. here implementation function question() { this.getallbyquizid = function(quizid) { return connection.acquire(function(err, con) { return con.query('select * questions `quizid` = ? ', quizid, function(err, rows) { if (err) throw err; con.release(); console.log(json.parse(json.stringify(rows)...

ios - How to store database into struct using swift3? -

i have function database , return in mutablearray, need database in struct. do need mutablearray struct or should data straight struct? i have no idea how approach or how store database struct my code: class crimesinfo: nsobject { var name: string = string() var detail: string = string() var time: string = string() } the function: func getallcrimesdata() -> nsmutablearray { sharedinstance.database!.open() let resultset: fmresultset! = sharedinstance.database!.executequery("select * crimetable", withargumentsin: nil) let marrcrimesinfo : nsmutablearray = nsmutablearray() if (resultset != nil) { while resultset.next() { let crimesinfo : crimesinfo = crimesinfo() crimesinfo.name = resultset.string(forcolumn: "name") crimesinfo.detail = resultset.string(forcolumn: "detail") crimesinfo.time = resultset.string(forcolumn: "time") marrcrimesinfo.add(c...

How to display XML in a listbox and pass it to a textbox in C#? -

i'm struggling make basic c# app gets number of items xml file, shows "title" node in listbox, and, when title selected, displays other nodes of item in textbox. textbox meant allow user edit xml content , save changes. my problem quite basic think: listbox works fine, textbox isn't updated when new title selected in listbox. guess shouldn't complicated, me - i'm stuck here. i'm aware questions 1 pop frequently, of them seem me imprecise or overly complicated: i'm (obviously) new c# , keep code simple , transparent possible. my xml sample: <?xml version='1.0'?> <book genre="autobiography" publicationdate="1981" isbn="1-861003-11-0"> <title>the autobiography of benjamin franklin</title> <author> <first-name>benjamin</first-name> <last-name>franklin</last-name> </author> <price>8.99</price> </book...

ios - UITableViewRowAction Cell with Corner Radius Changes Background Color -

Image
when uitableviewrowaction swipe happens cell background associated action changes it's background color white, instead of black typically is. in other words, color can see behind corner radius of cell changes swipe action. see example image below. i've set background color black on view, tableview, cell, i'm not sure how white showing up. ideas or suggestions welcome! // swiping setup tableview. func tableview(_ tableview: uitableview, editactionsforrowat indexpath: indexpath) -> [uitableviewrowaction]? { let dislikeactivity = uitableviewrowaction(style: .default, title: "don't this") { action, index in print("dislike button tapped") } return [dislikeactivity] } to fix issue changed background color of cell default in interface builder (xib) , set background of cell in willdisplay cell function noted below. func tableview(_ tableview: uitableview, willdisplay cell: uitableviewcell, forrowat inde...

html - Is it possible to use the :not() selector to target specific text nodes? -

this question has answer here: select text node css 6 answers consider following html: <div class="status-date"> <strong>date available:</strong> 10/05/2016 </div> i'd expect :not() selector capable of targeting date string "10/05/2016" follows: .status-date *:not(strong) { text-decoration: underline; } two questions : 1. :not() selector capable of this? 2. if not, any css selector capable of this? context : not styling text nodes. doing web scraping , i'd ignore <strong> tag in case. if styling, target div directly , overwrite styles on <strong> "cancel out". further context : can see naïve attempt doesn't work expected. example, shown in codepen: http://codepen.io/anon/pen/rwezqk it's possible i'm misunderstanding deep selector or dom structure i'...

html - Align elements to the center of another element -

this html: .hcsi { background-color: #fff; height: auto; width: 100%; text-align: ; position: fixed; left: 0; top: 0; z-index: 0; border: 2px solid #000; border-radius: 25px; } .home, .csgo, .steam, .info { z-index: 1; background-color: rgba(50, 150, 250, 0.5); border: 2px solid #000; padding: 10px 15px; border-radius: 20px; float: center; } .home:hover { background-color: rgba(50, 150, 250, 1); } .hcsi, li { color: #000; padding: 0px; display: inline-block; font-size: 21px; font-weight: 100; letter-spacing: 2.5px; word-spacing: 90px; } <!doctype html> <html> <head> <title>vusicvoid</title> <link href="https://fonts.google.com/specimen/shrikhand" rel="stylesheet"> </head> <body> <div class="hcsi"> <ul> <a href=""> <li class="home">home...

C# - Error casting object to interface -

Image
yes, there similar questions, none of them solved problem. created new solution 3 projects: firstplugin : library project, compiled dll. mainapp : console application, import firstplugin. shared : shared project interface declared. both firstplugin , mainapp projects have project on it's references. shared project the project structure: the icrawler.cs code: namespace shared.data.structures { public interface icrawler { void sayhello(); } } firstplugin project the project structure: the fp.cs code: using system; using shared.data.structures; namespace firstplugin { public class fp : icrawler { public void sayhello() { console.writeline("hello firstplugin.dll"); } } } mainapp project the project structure: the program.cs code: using system; using system.collections.generic; using system.reflection; using system.io; using shared.data.structures; namespace mainapp { cl...

java - How do I check that login and password entered is valid -

i trying create login funcitonality in android studio in verify entered password , login exist in database , go together(based on information in login database) should happen when user clicks "button check login" if info accurate should take user welcome screen. i struggling how check information according database. please help! please @ following : databasehelper.java package com.example.login; import android.content.context; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqlitedatabase.cursorfactory; import android.database.sqlite.sqliteopenhelper; import android.util.log; public class databasehelper extends sqliteopenhelper { public databasehelper(context context, string name,cursorfactory factory, int version) { super(context, name, factory, version); } // called when no database exists in disk , helper class needs // create new one. @override public void oncreate(sqlitedatabase _db) { _db.execsql(...

fortran - Prevent changing variables with intent(in) -

so reading following question ( correct use of fortran intent() large arrays ) learned defining variable intent(in) isn't enough, since when variable passed subroutine/function, can changed again. how can avoid this? in original thread talked putting subroutine module, doesn't me. example want calculate determinant of matrix lu-factorization. therefore use lapack function zgetrf, function alters input matrix , compiler don't displays warnings. can do? module mathelper implicit none contains subroutine initmat(aa) real*8 :: u double complex, dimension(:,:), intent(inout) :: aa integer :: row, col, counter counter = 1 row=1,size(aa,1) col=1,size(aa,2) aa(row,col)=cmplx(counter ,0) counter=counter+1 end end end subroutine initmat !subroutine write matrix file !input: aa - double complex m...

javascript - I want to display the contents of html file (with formatting) on TextView in android -

this html file want display on textview : <html> <head> <link rel="stylesheet" href="highlight/styles/default.css"> <script src="highlight/highlight.pack.js"></script> <script>hljs.inithighlightingonload();</script> </head> <body> <h1>c program calculate area of circle</h1> <p class="test"><pre><code class="c">#include&lt;stdio.h&gt; int main() { area = 3.14 * radius * radius; printf("\narea of circle : %f", area); } </code></pre></p> <br> <!--output--> <div><br>enter radius of circle : 2.0<br> area of circle : 6.14<br>&nbsp;</div> </body> </html> it has external linking .js , .css files i've stored in assets folder. htmlcontentinstringformat=""; string htmlfilename = "www/"+filename; assetmanager mgr = ...

javascript - How to check and see if a child node in Firebase has data in it -

my plan check see if child node called '1' has data in it. , if does, when user types name , presses 'submit', create new node called '2' them. $(document).on('click', '#enter', getname); function getname() { var name = $('#user').val().trim(); if(database.ref('players').child(1).exists()) { database.ref('players').child(2).update({ name: name, choice: '', losses: '', wins: '' }); } database.ref('players').child(1).update({ name: name, choice: '', losses: '', wins: '' }); }

python - Clicking on image after I find it with template matching OpenCV -

recently i've been playing opencv. i wrote small program find image in picture take on screen. find images expect, try move mouse location found these same points. mouse goes bottom right of screen, kind of confuses me. ( based program based on 1 mario coins here ) import cv2 import numpy np matplotlib import pyplot plt import pyscreenshot imagegrab import tkinter tk import time import pyautogui im=imagegrab.grab() imagegrab.grab_to_file('current.png') print "done image" img_rgb = cv2.imread('current.png') img_gray = cv2.cvtcolor(img_rgb, cv2.color_bgr2gray) template = cv2.imread('coin.png',0) w, h = template.shape[::-1] res = cv2.matchtemplate(img_gray,template,cv2.tm_ccoeff_normed) threshold = 0.8 loc = np.where( res >= threshold) counter=0 pt in zip(*loc[::-1]): cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2) counter=counter+1 print counter cv2.imwrite('res.png',img_rgb) pt in zip(*loc[::-1]): ...

java - JRE included in JDK cannot be used as public JRE? -

so installed latest java se development kit (jdk1.8.0_112) come jre (jre1.8.0_112) notice have 2 jres 1 got java.com (jre1.8.0_111) so did uninstalled (jre1.8.0_111) when tried visit java.com verify if jre working seems not work. ask me download version (jre1.8.0_111). my question jre included in sdk development purposes only? , different jre end users get?? both jre foot prints same. difference additionally development libraries(+ jre) jdk(java development kit) opposed standalone jre installtion

ios - fix while converting NSString to NSDictionary -

i getting nsstring * responsestring below format utf8 encoded. data webserver database. nsstring *jsonstring = @"{\"id\":{\"content\":\u0e09\u0e31\u0e19\u0e23\u0e31\u0e01\u0e04\u0e38\u0e13,\"type\":\"text\"},\"contracttemplateid\":{\"content\":\u0e09\u0e31\u0e19\u0e23\u0e31\u0e01\u0e04\u0e38\u0e13,\"type\":\"text\"}}"; //trying convert utf nsstring *utf = [jsonstring stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]; //convert data nsdata *data = [utf datausingencoding:nsutf8stringencoding]; //trying create nsdictionary json id json = [nsjsonserialization jsonobjectwithdata:data options:0 error:nil]; nslog(@"json: %@", son); nslog(@"utf: %@", utf); i need convert nsdictionary can parse , value of content output results: utf: (null) utf: {"id":{"content":ฉันรักคุณ,"type":"text"},...

Assign constructor parameter to object variable - Delphi -

this question has answer here: delphi: access violation @ end of create() constructor 2 answers i keep getting error dialog: access violation @ address xxxx in module 'xxxx.exe'. write of address xxxx. what should do? constructor tcustomclass.create(id: integer); begin self.id := id; end; any thoughts? the odds problem you're calling constructor incorrectly. you're doing similar following: var linstance: tcustomclass; begin linstance.create(1); ... end; the problem linstance doesn't exist yet, you're calling method on it. need create instance follows: linstance := tcustomclass.create(1);

How to use scala type lambda -

with following code, val x: ({type x[y] = function1[y, unit]})#x = (y: int) =>println(y) it compiles, how use it? when call x(1) an compiling occurs complains type mismatch, y expected: y accutal: int you can't have value of type ({type x[y] = function1[y, unit]})#x , can't have value of type option or function1 . thing can apply parameter, or use type argument type/method, apply parameters.

swift - Hide the Right Reveal View -

i have 2 reveal view controller 1 left(menu) , 1 right(chat bar button) . in myprofile view controller don't want open chat menu when swipe right left. how should stop ? see example project: [ http://www.appcoda.com/sidebar-menu-swift/] i made revealview of tutorial. can see in photo viewcontroller there no right reveal button on nav bar when swipe right left opens right reveal.

actionscript 3 - AS3 How to assign value of an array to the Keys of an object? -

i think eval-related. here, have array of unknown length in run-time. say, example, wish assign values array keys of object, below: var myarr:array = ['a','b','c',...]; //unknown length var finalvalue:int = 20; var myobj:object = new object(); assignvaluetoobject(); //logics of assignvaluetoobject function /* //todo.. black box */ //in end, myobj has value stored , can accessed myobj["a"]["b"]["c"][...] = 20; i not sure if need resort eval.hurlant , wish there simple way of doing (either recursion or sth) simply use loop iterate on elements of array , create objects except last element of array, should not object desired value. code untested. var myarr:array = ['a','b','c',...]; //unknown length var finalvalue:int = 20; var myobj:object = new object(); // variable holdsthe msot created sub-object var currentobject = myobj; // create nested objects second last property name (var i...

WPF two-way binding with internal setter -

i'm using wpf's two-way binding on clr property, implements inotifypropertychanged. set property internal , while get public . unfortunately, following error: system.windows.markup.xamlparseexception unhandled message: unhandled exception of type 'system.windows.markup.xamlparseexception' occurred in presentationframework.dll additional information: twoway or onewaytosource binding cannot work on read-only property 'name' of type 'mytype'. is expected behavior? have thought internal setters should work fine... note clr-type defined in assembly, , visible in current assembly, [assembly: internalsvisibleto("myassembly")] attribute. does have workarounds/suggestions? declaring assembly class library, it's not option me change set public . you can create own new public wraper property , use getter , setter of interact internal property internal string _sidetabheader; public string sideta...

actionscript 3 - TinkerProxy and Arduino with LDR sensor to Flash -

to explain i'm trying achieve, let me draw exhibit out you. projected screen divided 5 sections. each section have it' own ldr sensors. i'm trying achieve, have bird start flying in section ldr sensor triggered on (when walks in front of it). want able detect multiple sensors going on , have individual birds come on screen. if sensors 2 , 5 on, bird animations play in section 2 , 5. on , forth. i trying connect arduino flash through tinkerproxy, i'm having difficulties. below i've included code wrote far, , i'm getting error "scene 1, layer 'layer 2', frame 1, line 110 1046: type not found or not compile-time constant: arduinoevent." the code import net.eriksjodin.arduino.arduino; import net.eriksjodin.arduino.arduinowithservo; import net.eriksjodin.arduino.events.arduinoevent; import net.eriksjodin.arduino.events.arduinosysexevent; import flash.display.sprite; import flash.net.socket; import flash.utils.bytearray; import flash.uti...

c# - How to trigger the setter of a property of an enum when passing as parameter? -

imagine have property , private field: private messageboxresult donotuseme_result; public messageboxresult myresult { { return donotuseme_result; } set { donotuseme_result = value; } } messageboxresult enum used result of messagebox (wpf). nevertheless getting problems when passing myresult methods, because automatically uses value type of enum , changed results getting collected gc , because totally new variable specified inside scope of method ( taskbasedshow )... my current setup: public delegate void onresult(messageboxresult res); private messageboxresult donotuseme_result; public mainwindow() { initializecomponent(); onres += messagebox_onres; taskbasedshow("my message", "my caption", messageboxbutton.yesno, messageboximage.question, myresult); } public messageboxresult myresult { { return donotuseme_result; } set { donotuseme_result = value; onres?.invoke(value); } } pub...

android - How to set from-to date from one DatePickerDialog class -

i want set , to(end) date in edittext 1 datepickerdialog class optimise app performance. i've implemented 2 datepickerdialog class (named: fromdatepicker, todatepicker) set from-to date individually want use 1 class of datepickerdialog both from-to date minimise classes. kindly guide me how that. code, public class fromdatepicker extends dialogfragment implements datepickerdialog.ondatesetlistener { @override public dialog oncreatedialog(bundle savedinstancestate) { final calendar c = calendar.getinstance(); int year = c.get(calendar.year); int month = c.get(calendar.month); int day = c.get(calendar.day_of_month); return new datepickerdialog(getactivity(), this, year, month, day); } public void ondateset(datepicker view, int year, int mont, int day) { if(view.isshown()) { textview fromdate = (textview) getactivity().findviewbyid(r.id.from_date); string date = string.valueof(new stringbuilder()....

codenameone - WebBrowser issue (add infinite progress in web browser) -

it takes couple of seconds load url in webbrowser. takes more time load. how add infinite progress of connectionrequest in webbrowser? @override protected void postwebview(form f) { webbrowser wb = new webbrowser(); if (businesswebsiteurl != null && !businesswebsiteurl.equals("")) { wb.seturl("http://" + businesswebsiteurl); f.add(borderlayout.center, wb); } else { } f.revalidate(); } what did doesnot work protected void beforewebview(form f) { ip = new infiniteprogress(); f.add(borderlayout.center, flowlayout.enclosecentermiddle(ip)); } that's inherently problematic since browser peer component , while can paint on top of peers in android still not portable. even if i'm not sure if idea. overall have following options: place progress indicator above/below browser component fetch data separately html progress , set html should instant use javascript , potentially iframe indicate progres...

php - Undefined variable id in CodeIgniter -

i have todo list project. my model class model_lists extends ci_model { function model_list(){ parent::__construct(); } function list_get($id){ $this->load->database(); $query = $this->db->get_where('lists', array('id'=>$id)); return $query->row_array(); } my controller public function view_list($id){ $this->load->model('model_lists'); $data["query"] = $this->model_lists->list_get($id); $this->load->view('lists/view_list',$data); } list view <?php echo $query['list_by']; ?> however, when access view 2 php errors 1) message: missing argument 1 lists::view_list() 2) message: undefined variable: id this how call list: <a class="view_list" href="<?php echo site_url("lists/view_list?lid={$row->list_id}");?>"><i class="icon-eye"> </i></a> your site url not correct. ...

What is the simplest way to completely replace an assertion message using FA (and nunit)? -

for example; results.errors.count.should().be(0, $"because {results.errors[0]}"); produces result message: expected value 0 because 'name' should not empty., found 2. but want, in particular instance (invocation of assertion) value of results.errors[0] , message just: 'name' should not empty. (as aside want pass concatenated string representation of entire results.errors array, linq/lambda skills aren't there yet)! so how can fa use supply message string? you can't that. because part baked language promote failure messages natural possible.

mysql - Php while codes show just 1 row -

i'm using these codes. $blog = mysql_query("select * blog order id"); while($sutun = mysql_fetch_array($blog)) { $fake = $sutun["date"]; echo "$fake"; } when use echo"$fake"; can see of rows. when use <?php echo "$fake" ?> , shows 1 row me. i want of rows while i'm using <?php echo "$fake" ?> . beacuse echo"$fake"; in in loop echo @ every iteration thats why can see rows <?php echo"$fake"; ?> executed when loop done last row echoed;

Is it possible to create a custom object type in Doxygen? -

i want use doxygen document http api , have descriptions of http queries parameters, return results etc similar description of classes. need \query structural command can followed \brief , \param , \return , on , have corresponding tab "queries" in top navigation menu. in other words need 100% replication of \class different name. possible , how? don't think possible cleanly hope for, way accomplish using groups. /** * \defgroup query queries */ then document each query group in query group /** * \defgroup getuser user id * \ingroup query * \brief brief * \param id user id * \return user given id */ now need add tab query group in navigation menu. first generate doxygen layout file using doxygen -l . in doxyfile set layoutfile = doxygenlayout.xml . finally change doxygenlayout.xml file add new tab: <navindex> ... <tab type="user" visible="yes" title="queries" url="@ref query" in...

Swift iOS 10 didReceiveRemoteNotification only pops notification ignores other command -

my intention pretty straight forward: receive remote notification send local notification user update local database new data tell server data received func application(_ application: uiapplication, didreceiveremotenotification userinfo: [anyhashable : any], fetchcompletionhandler completionhandler: @escaping (uibackgroundfetchresult) -> void) { // receiption code here nslog("received remotely:: \(userinfo)") let content = unmutablenotificationcontent() content.body = message.body() content.title = message.body() content.subtitle = "new message" content.sound = unnotificationsound.default() content.badge = nsnumber(value:uiapplication.shared.applicationiconbadgenumber+1) let trigger = untimeintervalnotificationtrigger(timeinterval: 1, repeats: false) let request = unnotificationrequest(identifier: message.thread(), content: content, trigger: trigger) let center = unusernotificationcen...

Cant't config downloaded (zip) NDK for Android Studio (windows 7) -

so tried download ndk standalone sdk manager , didn't have option! went google developers , read guides , understood how via android studio there ndk option in sdk manager -> sdk tools tab , checked , after applying started downloading it, reason after download, fails install (tried 2 time fails @ end of unzipping process @ 100% :| ) ***note: have enough space available, 4gb on windows drive, 20gb on sdk drive ***note2: deleted ndk bundle folder , contents created failed install in sdk folder so went ndk download , downloaded package there , can't work, gradle says "error:ndk not configured. download sdk manager.)" i tried adding ndkfolder path variable or adding ndk_home variable still same error update 1 : added android_ndk_home variable says : error:a problem occurred configuring project ':tmessagesproj'. i had issue of error:ndk not configured. download sdk manager.) but solved problem link: add c , c++ project you can ...

asp.net - asp:c# Print checked rows using checkbox -

i want print selected rows in repeater table when button clicked, .aspx code: <asp:repeater id="rptitems" runat="server"> <headertemplate> <table class="table table-bordered table-hover table-responsive table-striped table-condensed"> <tr> <th> </th> <th>goods desc</th> <th>balance units</th> <th>exit units</th> </tr> </headertemplate> <itemtemplate> <tr> <td><asp:checkbox id="cbitem" runat="server" clientidmode="autoid" autopostback="true" /></td> <td><asp:label runat="server" id="lblcampcode" text='<%#eval("itemdesc") %>'></asp:label></t...

c# - Popup dimensions on screen -

i thought understood wpf content scaling system ran issue that's mysterious me. have simple popup supposed used loupe opens on top of image when user clicks image. xaml this: <popup name="loupepopup" allowstransparency="true" isopen="false" staysopen="true"> <border borderthickness="2" borderbrush="azure" /> </popup> in code behind, tie popup's placement image showing when popup opened. set loupe size half size of image code: loupepopup.placementtarget = fullimg; loupepopup.placement = placementmode.relative; loupepopup.width = fullimg.actualwidth / 2; loupepopup.height = fullimg.actualheight / 2; further code moves loupe along mousemove, not relate issue here: i'd expect loupe half width/height of image, not - quite bit larger (by 18%). verified actual image size , actual size of window on displayed, mouse coordinates. dimensions/point coordinates m...

Python - why can I call a class method with an instance? -

new python , having done reading, i'm making methods in custom class class methods rather instance methods. so tested code hadn't changed of method calls call method in class rather instance, still worked: class myclass: @classmethod: def foo(cls): print 'class method foo called %s.'%(cls) def bar(self): print 'instance method bar called %s.'%(self) myclass.foo() thing = myclass() thing.foo() thing.bar() this produces: class method foo called __main__.myclass. class method foo called __main__.myclass. instance method bar called <__main__.myclass instance @ 0x389ba4>. so i'm wondering why can call class method (foo) on instance (thing.foo), (although it's class gets passed method)? kind of makes sense, 'thing' 'myclass', expecting python give error saying along lines of 'foo class method , can't called on instance'. is expected consequence of inheritance 'thing' object inheri...

swift3 - swift 3 error xcode 8.1 while assigning rootviewcontroller says it is a get-only property -

Image
i migrating project swift 2.2 3.0, when reached point strange error, not allow me set rootviewcontroller in app delegate didfinishlaunching. self.window?.rootviewcontroller = self.container.resolve(dpslidemenucontroller.self)! i guess you're using library slidemenucontrollerswift . great if show whole code inside didfinishlaunching function. anyway, try following : func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { // create viewcontroller code... let slidemenucontroller = slidemenucontroller(mainviewcontroller: mainviewcontroller, leftmenuviewcontroller: leftviewcontroller, rightmenuviewcontroller: rightviewcontroller) self.window?.rootviewcontroller = slidemenucontroller self.window?.makekeyandvisible() return true }

java - The system cannot find the file C:\play\bin\..\conf\sbtconfig.txt -

activator_home=c:\play system cannot find file `c:\play\bin\..\conf\sbtconfig.txt. 'findstr' not recognized internal or external command, operable program or batch file. syntax of command incorrect. i'm facing problem while installing play framework. i intalled sbt , scala referenced 1 tutorial on internet, in vain. my java jdk working , sbtconfig.txt file not in play bin above file point to. please can me? if not provide sbtconfig.txt installer throw warning not stop. have installed play2 after message. so please check sbt_home , activator_home correctly configured. got other error 'findstr' not found. try both creating command shell , double clicking batch file. hope can solve problem.

How to create a while loop to cycle through a list and count instances of a certain word? Python -

this question has answer here: how find duplicate elements in array using loop in python? 15 answers i thinking, how make while loop cycle through list , count instances of word 'hello' example. list = ['bob','hello','jacob','hello','count'] so expected output 2. just use count (bonus: have "count" item in list ^^): >>> ['bob','hello','jacob','hello','count'].count('hello') 2

java - The data is not added into linked list and display correctly. Why? -

i creating system store data using linked list in gui form. have encountered problem when comes store , display linked list. looks after input data, did not stored linked list what doing library system, need store book name, author name, isbn number , number of copies of book single node in linked list. information come user input such jtextfield1. lecturer had taught me how insert single data need insert multiple data. i have recreate constructor , getter method in node class , change in linkedlist class well. reason data seems not add linkedlist, when display list in textarea, shows null not data input. why that? this node class: public class node { string name; string author; int isbn; int number; node next; node() { name = null; author = null; isbn = 0; number = 0; next = null; } node(string name, string author, int isbn, int number) { this.name = name; this.author = autho...

c# - Converting gl.MapBuffer to struct throws System.MissingMethodException Exception -

i need cast gl.mapbuffer struct vertexdata throws error public struct vertexdata { public vector3 vertex; public vector4 color; } public override void submit(renderable2d renderable) { gl.bindbuffer(opengl.gl_array_buffer, _vbo); _buffer = (vertexdata[])marshal.ptrtostructure(gl.mapbuffer(opengl.gl_array_buffer, opengl.gl_write_only), typeof(vertexdata[])); vector3 position = renderable.getposition(); vector2 size = renderable.getsize(); vector4 color = renderable.getcolor(); _buffer[0].vertex = position; _buffer[0].color = color; _buffer[1].vertex = new vector3(position.x, position.y + size.y, position.z); _buffer[1].color = color; _buffer[2].vertex = new vector3(position.x + size.x, position.y + size.y, position.z); _buffer[2].color = color; _buffer[3].vertex = new vector3(position.x + size.x, position.y, position.z); _buffer[3].color = color; } ...

Java iterator stuff -

public class show { public static arraylist ara = new arraylist(); public static iterator snake; public static void kai(){ ara.add(1); ara.add(2); ara.add(5); ara.add(7); ara.add(10); ara.add(13); snake = ara.iterator(); while(snake.hasnext()){ system.out.println(snake.next()); if(snake.next()==7)break; } } public static void main(string[] args){ kai(); } } at execution, 1, 5, 10 consecutively prints out. how explain this? expected 1, 2, 5 print out instead. you should change code following: public static void kai(){ ara.add(1); ara.add(2); ara.add(5); ara.add(7); ara.add(10); ara.add(13); snake = ara.iterator(); while(snake.hasnext()){ int value = (int) snake.next(); system.out.println(value ); if(value ==7)break; } } that way call iterator.next() 1 ...

in app purchase - iOS in-app payments without AppStore -

i writing ios client-server game. client side: - server comunication, - game user interface etc. server side: - logic game - responsible delivering data , logic ios client - manage payments - manage user privilages in system have own virtual currency. user can buy virtual money via payment system. user can spent virtual money in game. spending money builds own reputation in own loyalty program. level of loyalty have privilages, example access other functionality of app. as mentioned, server responsible payments, using variety of payments system (paypal, sms, etc.) , now... have question: can use in case other payment systems without apple's iap? don't want use it, because server manages payments platforms. make payments in ios app using webviews. possible? thanks replies :) you must use iap, since payments providing functionalities game. apple review guidelines : if want unlock features or functionality within app , (by way of example: s...

java - Spring Data Cassandra driver gets stuck after few hours, with single-node database on the same node -

i've been having problems apache cassandra database access via spring-data-cassandra: sometimes server cannot connect database @ start - typically works in 2nd attempt once started, couple of times hour, in random moments, few requests fail timeout , continues working fine finally, after few hours, driver starts consistently refusing requests, reporting timeouts - , server needs restarted the application small spring boot (1.4.0) server application using spring data cassandra (tried 1.4.2 , 1.4.4). application collects data remote clients , implements administrative gui based on rest interface on server side, including dashboard prepared every 10 seconds using spring @scheduled tasks , delivering data clients (browsers) via websocket protocol. traffic secured using https , bilateral authentication (server + client certificates). the current state of application being tested in setup database (2.2.8), running on same cloud server (connecting via loopback 127.0.0.1 addr...

c - Aliasing with char *, unsigned char * and signed char * -

a char * (and qualified variants) may alias anything. signed char * , unsigned char * (and qualified variants) exempt this? in other words, i've learned it's idea apply restrict char* function arguments if don't expect them alias pointer parameters of other types (because alias them): int func(struct foo *f, char * restrict s /*different object*/); can drop restrict keyword signed , unsigned char variants so? int sfunc(struct foo *f, signed char *s /*different object*/); int ufunc(struct foo *f, unsigned char *s /*different object*/); also may pointers signed , unsigned variant of same type alias each other? in other words if expect pointer int , pointer unsigned , should point different objects, should int * , unsigned * parameters each restrict -qualified? /* , u should different */ int uifunc(int * /*restrict?*/ i, unsigned * /*restrict?*/ u); the rule (c11 6.5/7): an object shall have stored value accessed lvalue expression has 1 o...