Posts

Showing posts from June, 2015

java - Trouble with generating custom javadoc; 'cannot find doclet' -

i'm having go @ creating custom javadoc generator using doclet , i'm running issues. i'm following the official documentation , had trouble including tools.jar file in project, managed fix this. my issue after running command... javadoc -doclet listclass -docletpath . myclass.java ...i getting message... javadoc: error - cannot find doclet class listclass as said, i've been following tutorials official documentation, here code reference. listclass.java : import com.sun.javadoc.*; public class listclass { public static boolean start(rootdoc root) { classdoc[] classes = root.classes(); (int = 0; < classes.length; ++i) { system.out.println(classes[i]); } return true; } } and myclass.java : /** * documentation class */ public class myclass { public static void main(string[] args) { } /** * documentation static void method * * @param param parameter takes

xml - java.lang.ClassNotFoundException: com.springhibernatemvc.dao.PersonDAOImpl -

i having error in servlet-context.xml. saying can find below classes there exist in projecct folder. <beans:bean id="persondao" class="com.springhibernatemvc.dao.persondaoimpl"> <beans:property name="sessionfactory" ref="hibernate4annotatedsessionfactory" /> </beans:bean> <beans:bean id="personservice" class="com.springbibernate.services.personserviceimpl"> <beans:property name="persondao" ref="persondao"></beans:property> </beans:bean> it saying class not found - class 'com.springbibernate.services.personserviceimpl' my servlet-context file defined in web.xml file <servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation

.net - WPF ComboBox does not respect Background setter on Windows 10 -

Image
i have simple combobox, source attached below: <window x:class="comboboxtest.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" title="mainwindow" height="350" width="525"> <grid> <combobox background="red" height="20" width="50" verticalalignment="top" horizontalalignment="left"> <comboboxitem content="a"></comboboxitem> <comboboxitem content="b"></comboboxitem> <comboboxitem content="c"></comboboxitem> </combobox> </grid> on windows 7/server 2008, combobox show

c# - How to bulk insert into SQLITE database? -

i developing uwp application. i have database should initialized 20,000 records. records, defined follows: private static readonly observablecollection<tickrecord> tickrecords = new observablecollection<tickrecord>(); i tried insert records 1 @ time this: private void createfaketickrecords() { if ( database.database.counttickrecords() > 0 ) { return; } foreach ( var tickrecord in tickrecords ) { database.database.addorupdatetickrecord( tickrecord ); } } and public static void addorupdatetickrecord( tickrecord tickrecord ) { // create new connection using ( var db = new sqliteconnection( new sqliteplatformwinrt(), dbpath ) ) { if ( tickrecord.id == 0 ) { // new db.insert( tickrecord ); } else { // update db.update( tickrecord ); } } } this code works fine, way slow. i modify can "bulk insert". how do that? thx try inse

html - Bootstrap: Add Button to list-group-items -

Image
i need add multiple actions list group items, purple area needs follow link, , yellow area open modal. currently list group items anchors , since not valid html nest anchors or buttons, searching solution. any ideas? icon have id, give id input , use jquery code. $(document).ready(function(){ $('#simple').click(function(){ window.onload = window.location.href = "http://stackoverflow.com"; }); }); $(document).ready(function(){ $('#basic-addo1').click(function(){ window.onload = window.location.href = "http://stackoverflow.com"; }); }); <div class="input-group"> <span class="input-group-addon" id="basic-addon1">@</span> <input type="text" class="form-control" placeholder="username" aria-describedby="basic-addon1" id="simple"> </div>

ios - UINavigationController pushViewController not working -

Image
i have double-tap gesture on view controller irpimageviewerviewcontroller (topmost on navigation stack), , each time view on irpimageviewerviewcontroller double-tapped, pushes image editor view controller irpimageeditorviewcontroller onto stack, that's why there several of them, none of appeared. each time double-tap, it's added, never appears. self class houses double-tap gesture irpimageviewerviewcontroller , , in fact have navigationcontroller per lldb output po self.navigationcontroller returns navigation controller expected. po self.navigationcontroller viewcontrollers shows new view controller being added list each pushviewcontroller statement encountered, yet pushed item won't show on screen. i shouldn't have push , move front, right?? doesn't push automatically make frontmost view controller? note navigation controller not root controller in hierarchy, starting window. have full screen map view controller, half-screen 'dashboard'

ibm bluemix - Unable to communicate with Watson -

i'm using watson personality insights api return personality insights based on user's tweets. has been working fine past few weeks, today became quite slow , stopped working , gave me error message. is issue watson / bluemix / issue code? watson error an internal server error has occured - /personality-insights/api/v2/profile?include_raw=true unable access server gateway error code : ercd50-ldap-dn-srch-err unable communicate watson. request url : /personality-insights/api/v2/profile?include_raw=true error id : gateway-dp02-436619140 date-time : 2016-04-21t14:20:29-05:00 ' } url: /api/profile/twitter the error code doesn't return search results on google. thanks in advance. yup, getting exact same error watson natural language processing, looks it's ldap issue, seems watson services down right now.

java FileWriter, periodically delete file contents -

i using several java filewriter append data output files. files remain open during processing , periodically written (appended to). occasionally, hit point in logic contents of open file needs deleted (the file length become zero) , start appending again top. without closing , reopening file, there efficient method accomplish using filewriter? without closing , reopening file, there efficient method accomplish using filewriter ? no. have use randomaccessfile performance , character-set issues. create new filewriter .

python - Convert an iteration over dictionaries into a pandas dataframe -

i have generated 2 dictionaries 2 input files using conditional statements (not shown). aimed use these 2 dictionaries identify overlapping values. use output iteration pandas dataframe directly. that, first outputting iteration/for loop file (output.xls) , read file pandas dataframe. while works well, wondering if there way use 'newline' iteration below directly input empty pandas dataframe. couldn't find option on python except dataframe.from_dict . however, takes in 1 dictionary have multiple dictionaries joining together, other variables utilizing. exp1_dict.items() is: [('lnc3', ['spata1', 'ahnak', 'fgg', 'erap1', 'hz', 'saasdas', 'nlrc5', 'huwe1']), ('lnc2', ['spata1', 'fgg', 'tmem68', 'atp6ap', 'huwe1']), ('lnc1', ['spata1', 'ahnak', 'fgg', 'tmem68', 'erap1', 'atp6ap', 'saasdas'

java - How to send data from one activity to another. (Bluetooth) -

i'm creating small bluetooth messenger app. have 2 activities main activity , messenger activity. main activity have background threads creating bluetooth socket , managing connection. when socket created starts messenger activity on both devices. messenger activity have edit box, list view , button. question how can send string has been taken edit box write() function in main activity. public void write(byte[] out) { connectedthread cthread = new connectedthread(bluesocket); cthread.write(out); } when device gets message sends buffer handler. buffer = new byte[1024]; bytes = mminstream.read(buffer); // send obtained bytes ui activity mhandler.obtainmessage(message_read, bytes, -1, buffer) .sendtotarget(); handler takes string buffer. , here question: how send string messenger activity add list view. i not sure if understood - hope helps: maybe should bluetooth-socket-stuff in

portforwarding - pfsense 2.1.2 firewall port forwarding -

what trying pretty simple firewalls except pfsense. i remotely connect server via rdp :9999 being forwarded :3389 i don't want change rdp listening port on server. thanks; in: 1- firewall - nat -port forward: add o new 2- interface: wan 3- protocol: tcp 4- destination port range: other custom: 9999 port: 9999 5- redirect target ip: 192.168.1.x 6- redirect target port: ms rdp (select option) save , try

docusignapi - Docusign attachment file size limitation -

is there way limit signer attachment file size in docusign, either using api or through settings @ docusign web site. have read (in api guide ) there 25 mb limit attachments. there way restrict smaller number? curiously, document triggered issue 31 mb in size. our customer able upload document big, our application experienced timeout issues because took long download it. why customer able upload such big attachment? thanks. [1] no there not way outside applications limit platform wide limit of ~25mb per envelope docusign has in place. recommended add logic app/integration checks file size before make api call create envelope , stops user using document if it's large. [2] reason why particular 30mb document accepted platform other 30mb documents might error out due encryption. whenever create new docusign envelope system automatically encrypts , hashes each document. in turn bloats envelope larger. true limit of platform 50mb per envelope, based on act

javascript - how to set href value on all elements with a given ID? -

i have several anchor tags on page same id of 'hrefcompare'. need dynamically set value of href attribute on of these tags. i trying this: $("#hrefcompare").attr("href", "foobar.com"); however, sets first anchor tag id. there's 7 more on page same id of 'hrefcompare'. how can set of href values id? you cannot ids (they unique), try using same css class elements want (doesn't matter if class not exist) . html: <a href="javascript:void(0);" class="hrefcompare">text1</a> <a href="javascript:void(0);" class="hrefcompare">text2</a> please avoid using # in href attributes (if care behaviors). read know why: which "href" value should use javascript links, "#" or "javascript:void(0)"? then: for older jquery versions use .attr(..) otherwise use .prop(..) $('.hrefcompare').prop('href', 'http

gwt ClientBundle context.drawImage doesn't show image? my 2D engine -

my code has not errors don't see image. image located @ same place clientbundle file is. sorry chunk of code. in fact newbie in gwt (and in java well). , teach myself. made debugging , saw image loaded, classes initialized, canvas empty far. use netbeans ide 7.3. happy if give me advice how launch code. upfront! __ _ ___ resourseinspector (nothing special) __ _ __ _ __ _ __ _ __ image located @ same folder. package info.alexpi.client.engine2d; import com.google.gwt.core.client.gwt; import com.google.gwt.resources.client.clientbundle; import com.google.gwt.resources.client.imageresource; public interface resourseinspector extends clientbundle { public static final resourseinspector instance = gwt.create(resourseinspector.class); @clientbundle.source("image1.png") //gwt.gethostpagebaseurl() or gwt.getmodulebaseurl() - way, why it's not allowed use here? imageresource img(); } __ _ __ point2d _ ___ package info.alexpi.client.engine2d; publ

java - Exception in thread "main" line 37 -

i'm getting "exception in thread "main" java.lang.arrayindexoutofboundsexception: 5 @ weatheranalysis.main(weatheranalysis.java:37)" im not sure wrong @ line 37, date[currentline][0] = (int)fulldate % 100;. trying use .txt file output weather patterns 1941 2013. import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; public class weatheranalysis { public static void main(string[] args) throws filenotfoundexception { int numberofdays = 0; string station; file f = new file("portlandweathercut.txt"); //import text file. scanner input= new scanner(f); input.nextline(); input.nextline(); while (input.hasnextline()) { //assign number of days numberofdays++; input.nextline(); } double[][] date = new double[numberofdays][3]; double[] prcp = new double[numberofdays]; double[] snow = new double[num

ASP.NET in line string comparison -

i've inherited code displays list of calendar events start date , end date. values come sql db through stored procedure, making way onto aspx page. if event starts , ends on same day don't want display end date. despite having visually compared data, attempt implement using inline snippet below has failed , continues show enddate: <%# (eval("edate") == eval("sdate")) ? "blank" : "enddate" %> any advice on i'm doing wrong? or how implement on stored procedure side? code generating there is: sdate = case when str(day(startdate)) = 1 datename(mm, [startdate])+' '+ltrim(str(day(startdate)))+ 'st' + ', ' when str(day(startdate)) =2 datename(mm, [startdate])+ ' ' +ltrim(str(day(startdate))) + 'nd' + ', ' when str(day(startdate)) =3 datename(mm, [startdate])+ ' ' +ltrim(str(day(startdate))) + 'rd'+ ', '

lambda - Java - Reading a txt file line by line -

this question has answer here: how read file line line in java 8? 2 answers so have simple code i'm trying read file line line: if(new file(filesdir).listfiles() != null){ for(file file : new file(filesdir).listfiles()){ try { stream<string> stream = files.lines(paths.get(file.getabsolutepath())); for(int = 0 ; < stream.toarray().length; i++){ system.out.println(stream.toarray()[i]); } stream.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } } but when reaches sysout throws exception: exception in thread "main" java.lang.illegalstateexception: java.lang.illegalstateexception: stream has been operated upon or closed caused by: java.lang.illegalstateexception: strea

jasmine - Unit testing aurelia view -

i'm new aurelia , wondering if there way unit test aurelia views it's custom bindings? tried load aurelia html view file html fixture using jasmine-jquery, reason never of html dom elements using id. the functionality trying unit test when mouseover icon, should increase size of icon , change it's background color. view <template> <div> <span repeat.for="[automobile] of automobilesarray"> <object id.bind="automobile.id" type="image/svg+xml" style='background-color: white;' data.bind="'./images/' + automobile.id +'.svg'" class="auto-icon img-circle" width="50" mouseover.delegate="mover($event)" mouseout.delegate="mout($event)"> </object> </span> </div> view model mover(event: event) { document.getelementbyid(event.srcelement.id).style.backgroundcolor = "yellow"; document

c++ - Can I use const_cast on a copy of a pointer? -

is there undefined behavior here? #include <iostream> #include <string> int main() { std::string str = "hello"; auto p = str.c_str(); char x[] = "sup"; const_cast<char*&>(p) = x; } no, casting away constness of inherently const object , modifying gives ub not otherwise.

gcc - Getting number of command line arguments, NASM -

as far know, @ beginning of execution [esp] contains number of command line arguments. i'm doing this: global main extern printf section .data format db "%d", 0 section .text main: push format call printf add esp, 4 xor eax, eax ret however, prints garbage -145184962. code gives same result: push dword [esp] push format call printf add esp, 8 code builded nasm -f elf32 a.asm , gcc -m32 a.o .

ajax - Adding animations to static HTML page navigation -

is there simple way add animations static html page navigations? client didn't want animations initially, used static html pages on site i'm building, now, site being finished changed mind. need simple fade effect 1 specific div when using page navigation. (link tags) if had told me before wants animations on site, have used ajax always, adding fade effect (using jquery): $(target).fadeout(); $(target).load(url, function() { $(this).fadein(); }); i don't feel rewriting whole site use ajax, , client doesn't feel either pay surplus because of this.

ios - Quickblox unrecognized selector sent -

i try register in quickblox twitter digits error +[qbrequest loginwithtwitterdigitsauthheaders:successblock:errorblock:]: unrecognized selector sent class 0x1002c8e70 i tried many different methods resolve problem public static func createuserbyphonenumber(phonenumber: string, completion: ((error: nserror?) -> ())?) { let configuration = dgtauthenticationconfiguration(accountfields: .defaultoptionmask) configuration.phonenumber = phonenumber digits.sharedinstance().authenticatewithviewcontroller(nil, configuration: configuration) { (session, error) in if error == nil { let oauthsigning = dgtoauthsigning(authconfig: digits.sharedinstance().authconfig, authsession: session) createquickbloxuser(oauthsigning.oauthechoheaderstoverifycredentials(), completion: { (error) in if error == nil { completion?(error: nil) } else { completion?(error: error)

java - How to set size and various attributes for all grids in GridPane in Scenebuilder/JavaFX -

Image
note: not homework. swing application homework, it's completed. i'm doing own knowledge better understanding of javafx , scenebuilder. i created swing application contained 27x27 grid. upon clicking "normal setup", center square visible. i attemtping translate javafx, , using scenebuilder. i'm still learning how use this, , i'm unsure if have gridpane placed correctly (notice how creating 27 x 27 grid makes go beyond bounds of parent). can work on later. what know if can set of attributes each node across board. had go fxml file , manually change each node size in 27x27 grid. exhausting eventually. surely there way this? can see each node have label template, , visible when ant accesses it. in swing version, example of setting nodes looks so: setpreferredsize(new dimension(colonyview.node_size, colonyview.node_size)); where "node_size" is: public final static int node_size = 96 any appreciated. select node

php - Retrieving data from form made in javascript -

i have uploaded fiddle of js code ( http://jsfiddle.net/3mcm2/ ), @ bottom of way in calling js in php document. in order run script, remove php code comments bottom. wanted add see how outputting in php. also, above last comments 3 lines of comments in .js file, there see php echoing better understand how looks. /* following in .js file: (see bottom of script part of in php file) */ var f = document.createelement("form"); f.setattribute('method', "get"); f.setattribute('action', "index.php"); var category = (function () { var categorycount = 0; function elem(tag) { // shortcut return document.createelement(tag); } function text(str) { // shortcut return document.createtextnode(str); } function category(node) { var self = this; this.categoryid = ++categorycount; // make add button this.addbutton = elem('button'); this.addbutton.

How to get HTTP headers before downloading with Ruby's OpenUri -

i using openuri download file in ruby. unfortunately, seems impossible http headers without downloading full file: open(base_url, :content_length_proc => lambda {|t| if t && 0 < t pbar = progressbar.create(:total => t) end }, :progress_proc => lambda {|s| pbar.progress = s if pbar }) {|io| puts io.size puts io.meta['content-disposition'] } running code above shows first downloads full file , prints header need. is there way headers before full file downloaded, can cancel download if headers not expect them be? you can use net::http matter, example: require 'net/http' http = net::http.start('stackoverflow.com') resp = http.head('/') resp.each { |k, v| puts "#{k}: #{v}" } http.finish another example, time getting header of wonderful book, object orient programming ansi-c : require 'net/http' http = net::http.start('www.planetpdf.com') resp = http.h

angularjs - Angular - Should ngDisabled work on any HTML item? -

in angular app have flag icon using code: <i ng-click="detail.flag()" class="fi-flag"></i> i have boolean variable i'd use disable this. i've tried following no avail: <i ng-disabled="showduplicate" ng-click="detail.flag()" class="fi-flag"></i> and <div ng-disabled="showduplicate"><i ng-click="detail.flag()" class="fi-flag"></i></div> any ideas why dont work? thanks. ngdisabled - directive sets disabled attribute on element if expression inside ngdisabled evaluates truthy. elements can receive disabled attribute include <button> , <input> , <textarea> , <optgroup> , <option> , <fieldset> . that's why won't work on <i> (or <div> ) element.

Adjusting Font for Different Sections of Same Paragraph - Excel VBA -

i feeding data word doc excel via vba. want format following. 1. service ticket# 452345: lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. the service ticket part bold , italicized , description italicized only. service ticket number , description come different cells in excel. here's code: '' bookmark inserting data. wdapp.selection.goto what:=-1, name:="service_ticket_comments" dim integer dim serviceticket string = 4 shaudittrail.range("a4").end(xldown).row '' pulling comments comments column. if not isempty(cells(i, 11)) serviceticket = "service ticket #" & cells(i, 1) wdapp.selection.typetext "service ticket #" & cells(i, 1) wdapp.selection.font.bold = true wdapp.selection.font.italic = true wdapp.selection.typetext " - " & cells(i, 11) & c

javascript - Switch variable issue -

while working on can called "content slider" wrote piece of code up: var dayy = 1; $(".buttonsix").click(function() { dayy--; console.log(dayy); }); $(".buttonseven").click(function() { dayy++; console.log(dayy); }); switch (dayy) { case 0: var dayy = 1; break; case 1: break; case 2: $(".fist").fadeout(); $(".second").fadeout(); $(".third").fadein(); $(".fourth").fadein(); break; case 3: $(".third").fadeout(); $(".fourth").fadeout(); $(".fith").fadein(); $(".sicth").fadein(); break; case 4: $(".fith").fadeout(); $(".sicth").fadeout(); $(".seventh").fadein(); $(".eight").fadein(); break; case 5: $(".seventh").fadeout(); $(".eight").fadeout(); $(".nineth"

youtube - HTML Embedded video cut off -

i trying embed video youtube site. wondering if there way relate width , height based on window size. example, on iphone looks this . can make video shrink in width smaller display size? can tie in responsive site somehow, that? it works great on computers or other larger screened devices, not mobile. source: <center><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/zrdi1dt3afa?rel=0" frameborder="0" allowfullscreen></iframe></center> full page source thanks help! [edit: source] it possible embed youtube videos responsive overriding youtube style (css). add following css: .video-con { position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden; } .video-con iframe, .video-con object, .video-con embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } and wrap iframe div : &

python - puzzling syntax with theano -

i followed tutorial logistic theano import numpy import theano import theano.tensor t rng = numpy.random n = 400 # training sample size feats = 784 # number of input variables # initialize bias term b = theano.shared(0., name="b") print("initial model:") print(w.get_value()) print(b.get_value()) # construct theano expression graph p_1 = 1 / (1 + t.exp(-t.dot(x, w) - b)) # probability target = 1 prediction = p_1 > 0.5 # prediction thresholded xent = -y * t.log(p_1) - (1-y) * t.log(1-p_1) # cross-entropy loss function cost = xent.mean() + 0.01 * (w ** 2).sum()# cost minimize gw, gb = t.grad(cost, [w, b]) # compute gradient of cost # w.r.t weight vector w , # bias term b # (we shall return in # following secti

python - How to add up scraped strings representing integers? -

how add floats scraped? for post in posts: numberofitems = numberofitems + 1 print(numberofitems) value = float(re.sub(r"[^\d.]", "", post.text)) print("chaos orbs: %s" % value) print(value) like this, print(value1 + value2 + value3) but, random amount not know, can't make variables use sum() : for post in posts: ... # rest of code snippet posted print(sum(float(re.sub(r"[^\d.]", "", post.text)) post in posts)) outside of loop add values , print out sum. alternatively, if want use existing loop somehow avoid iterating twice, how about: summed_values = 0 post in post: ... # rest of code snippet posted summed_values += value

c# - Reading/writing transient files in an Azure Worker Role -

we have multi-tenant system consisting of azure web role, worker role , desktop/mobile apps. each client app allows uploading images routed tenant-specific azure blob storage account. the azure worker role polls these files , processes them. use third-party sdks processing require either file system path or stream. providing stream directly blob storage trivial sdk expects spit out physical metadata files our app consumes. this problem since sdk black box , not provide alternative. there way have local storage within worker roles transient files. storage required few seconds per worker role iteration , may recycled/discarded if role recycled or shut down. in addition, files rather large (500mb+) blob latency not desired. searching around revealed hacky workarounds, best of appears wraps blob storage let our role access file system. is there way have access file system similar web role app_data folders? you can use roleenvironment.getlocalresource() within azure wor

How to choose what argument a variable is assigned to in a function? -Javascript -

given normal function such; function descriptions(awesome, cool, alright){ return (awesome || "no one") + " awesome. " + cool + " cool. " + + alright + " alright"; } descriptions("jane", "jack", "jefferson"); //returns "jane awesome. jack cool. jefferson alright." i use same function, pass final 2 arguments so: descriptions(cool : "john", alright : "jane"); //i statement similar works. //should return "no 1 awesome. jack cool. jefferson alright." how above done? you can passing object: function descriptions(info) { // avoid typeerror if no argument passed if (!info) { info = {}; } return (info.awesome || "no one") + " awesome. " + (info.cool || "no one") + " cool. " + (info.alright || "no one") + " alright."; } // use: console.log(descriptions({ awesome: &quo

typescript - Why changing "const" value in Angular 2 does not give error? -

the code simple: const num = 1; num = 2; console.log('num', num); in jsfiddle , browser console show following error, great: uncaught typeerror: assignment constant variable. however, same codes in angular 2 not give error, , @ end num equals 2 . see plunker . why changing "const" value in angular 2 not give error? bug? thanks online typescript compiler default target lower 'es6', in generated code const replaced var compatibility, if change config.js to: typescriptoptions: { emitdecoratormetadata: true, target: 'es6' } compiler output const , you'll see error.

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

i have following viewset: class artistprofileviewset(viewsets.modelviewset): queryset = artistprofile.objects.all() serializer_class = artistprofileserializer def perform_create(self, serializer): if serializer.is_valid(): serializer.save() with following serializers: class simpleartisttrackserializer(serializers.hyperlinkedmodelserializer): class meta: model = artisttrack fields = (...my fields...) class artistprofileserializer(serializers.hyperlinkedmodelserializer): owners = userserializer(many=true, required=false) tracks = simpleartisttrackserializer(many=true, required=false) class meta: model = artistprofile fields = (...my fields...) i getting following error: assertionerror: cannot call `.save()` after accessing `serializer.data`.if need access data before committing database inspect 'serializer.validated_data' instead. i don't see editing serializer.data object. th

javascript - rx js aggregation for posts -

i'm trying understand functional programming rx js. i have rx.observable emits "post" objects: every post looks : { title: "sometitle", author: "someauthor" text: "sometext", date: "somedate", tags: ['tag1', 'tag2', ..., 'tagn'] } and want transform sequence sequence emits: { tag: 'tagname', postcount: n } this have far: function tags(post) { return post .tags .map(function(tag) { return { 'tag': tag, 'count': 1}); } posts .flatmap(tags) .groupby(function(tagged) { return tagged.tag }) . // don't know how continue as said before, goal create sequence/observable emits {tag: 'tagname', postcount: n } each tag thx in advance edit: i forgot mention looking "node oriented" answer. this have far. it works , i'm not sure { ..., count: 1 } part. i'm looking more "elegant" sol

python - Hosting a simple script with user inputs on PythonAnywhere -

i beginner in python, , trying host python script on pythonanywhere, fun. took code codecadamy exercise make python piglatin translator, requires user inputs. having trouble getting host actual application part. here current code. import os flask import flask app=flask(__name__) #main page @app.route("/") def translate(): return "welcome nathan's pyglatin translator!" word1= input("enter word:") pyg="ay" word2=word1.lower()[1:len(word1)] word1=word1.lower() if len(word1)>1 , word1.isalpha(): if word1[0]=="a" or "e" or "i" or "o" or "u" or "y": print(word1+" ---->"+word2+"-"+word1[0]+pyg) else: print(word1+" ---->"+word2+"-"+word1[0]+pyg) else: print("please enter word longer 1 character, without numbers.") print(&quo

wolfram mathematica - NDSolve accuracy -

we're asking ndsolve solve x'' + x == 0 20 digits, when compare true solution, see 9 correct digits. not using ndsolve correctly? clear["global`*"] sol = ndsolve[{x'[t] == v[t], v'[t] == -x[t], x[0] == 1, v[0] == 0}, {x, v}, {t, 0, 100}, precisiongoal -> 20, accuracygoal -> 20, workingprecision -> 40, maxsteps -> 10^6]; plot[(x[t] - cos[t]) /. sol[[1]], {t, 0, 100}]

python - How to return the number of times a string with specific requirements appears in a list? -

given list of strings, return count of number of strings string length 3 or more , first , last chars of string same. to solve problem created following function, def match_ends(words): firstl=words[0:1] lastl=words[-1:] x=len(words)>3 , firstl == lastl count=0 x in words: count+=1 return count then tested here, def test(got, expected): if got == expected: prefix = ' ok ' else: prefix = ' x ' print ('%s got: %s expected: %s' % (prefix, repr(got), repr(expected))) # calls above functions interesting inputs. def main(): print ('match_ends') test(match_ends(['abaa', 'xyzax', 'aa', 'x', 'bbb']), 3) test(match_ends(['', 'x', 'xy', 'xyx', 'xx']), 1) test(match_ends(['aaa', 'be', 'abc', 'hello']), 1) print result: x got: 1 expected: 3 ok got: 1 expected: 1 ok got: 1 expected: 1

matrix - MATLAB - Plotting matrices of different size on same plot - error in plot function -

i importing data 3 files , parsing obtain time , voltage values each file. these values need plotted against each other on same plot. the data held in total of 6 matrices, 1 time , 1 voltage each of 3 data sets. matrix dimensions: matlab data sets: 1000x1, ltspice: 465x1, oscope: 2500x1. matlab finds error in use of plot function: plot(matlab_t,matlab_v,'k',ltspice_t,ltspice_v,'j',oscope_t,oscope_v,'g'); is issue because matrix dimension vary between independent , dependent sets? full code script: clear; clc; %% import %read in files matlab_t=dlmread('engr_222_project_1_data.csv',',',[16 0 1015 0]); matlab_v=dlmread('engr_222_project_1_data.csv',',',[16 1 1015 1]); ltspice_t=xlsread('ltspicedata_excel.xlsx','a1:a465'); ltspice_v=xlsread('ltspicedata_excel.xlsx','b1:b465'); oscope_t=xlsread('oscope_data.xlsx','d1:d2500'); oscope_v=xlsread('oscope_data.xlsx&

arrays - How can i split string per line on file -

i have file contain string this: - ' *[0-9]-? [^a-c]@[*-^a-c]' '' < temp-test/758.inp.325.1 - ' *[0-9]-? [^a-c]@[*-^a-c]' '' < temp-test/759.inp.325.3 - ' *[0-9]@[[9-b]??[0-9]-[^-[^0-9]-[a-c][^a-c]' 'new' < temp-test/1133.inp.487.1`enter code here` - ' *[0-9]@[[9-b]??[0-9]-[^-[^0-9]-[a-c][^a-c]' 'new' < temp-test/1134.inp.487.2 - '"@@' 'm' < input/ruin.1890 i want split string per line 2 part , , hope result this: - line 1: array[0]=' *[0-9]-? [^a-c]@[*-^a-c]'; array [1]='' < temp-test/758.inp.325.1 - line 2: array[0]=' *[0-9]-? [^a-c]@[*-^a-c]'; array [1]='' < temp-test/759.inp.325.3 - line 3: array[0]=' *[0-9]@[[9-b]??[0-9]-[^-[^0-9]-[a-c][^a-c]'; array[1]='new' < temp-test/1133.inp.487.1 - line 4: array[0]=' *[0-9]@[[9-b]??[0-9]-[^-[^0-9]-[a-c][^a-c]'; array[1]='new' < temp-test/1134.inp.487.2 - line

c - How to access three dimensional array outside the loop -

i using c program. using ubuntu 14.04. following 1 of loops use. for (x=0; x<1024; x++) { (i=0; i<8; i++) { (j=0; j<8; j++) { arr[x][i][j]=vi[8*i+j+gi]; } } gi = gi+(8*8); } here 'vi' single dimensional array. array 'arr' has 1024 blocks of size 8x8. there provision access blocks such (with size 8x8) outside loop further processing? if x array defined int x[1024][8][8] , means x array of 1024 elements each element int[8][8] , namely array of arrays of int. if want element, use subscription access it, same way access normal arrays. example, use x[0] access first 8x8 block of x, x[1023] access last block.

Java - How to design a method for search? -

i designing decorator class wraps news search engine, can ship class library used other teams. the exposed interface of class java-styled one, takes lot of parameters, decorator assembles these parameters search text search engine. my method following: public list<news> search(list<string> keywords, list<string> categories, list<string> authors, list<location> locactions, list<localdate> dates, list<sortrule> sortrules, int offset, int limit); yes, know... method looks ridiculously long, error-probe , hard use clients. so, how can design better api such search functionality? you can try writing wrapper class applying rule filters , take new object of class in current class. way simple , cleaner. for example, rulefilters r = new rulefilters(); r.addfilters(type.keywords, keywords); r.addfilters(type.categories, categories); r.addfilters(type.authors, authors); here type enum holds details of different rule filters {

Why does apache camel filter out HTTP headers -

i going through link : https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.0/html/web_services_and_routing_with_camel_cxf/files/proxying-headers.html it states when building bridge applications using http or http-based components, necessary remove or filter out headings or classes of headings in route, in order ensure application behaves expected. in org.apache.camel.component.netty4.http.nettyhttpheaderfilterstrategy can seen lots of headers being filtered out follows : protected void initialize() { getoutfilter().add("content-length"); getoutfilter().add("content-type"); getoutfilter().add("host"); // add filter generic message header // http://www.w3.org/protocols/rfc2616/rfc2616-sec4.html#sec4.5 getoutfilter().add("cache-control"); getoutfilter().add("connection"); getoutfilter().add("date"); getoutfilter().add("pragma"); getoutfilter().add("trai