Posts

Showing posts from June, 2012

pandas - Array length does not match index length -

i'm looking combine few time series varying dates single dataframe. each time series' column names date , px i've created date index dates , tried combine time series doing: dates = pd.date_range('01/01/2017', periods=12, freq='m') df = pd.dataframe({ 'date': dates, 'a': df2['px'], 'b': df3['px'] . . etc }) expected output: date b c d e 2017-01-31 -0.4579 nan . . . 2017-02-28 0.5787 nan . . . 2017-03-31 -2.2319 -1.0244 etc etc etc 2017-04-30 -2.0713 -2.1069 2017-05-31 nan 2.0158 2017-06-30 nan 1.0541 2017-07-31 nan 1.8901 2017-08-31 nan nan 2017-09-30 nan nan . . etc iiuc: dfs = [df1,df2,df3] pd.concat([df.set_index('date') df

ionic2 - Accessing array in component from ionic view -

this.tribesprovider.getmytribedetailsbytriberid().subscribe(tribeids=>{ tribeids.foreach(tribeid=>{ this.tribesprovider.getmytribedetailsbytribeid(tribeid).subscribe(tribe=>{ this.mytribelist.push(tribe); console.log(this.mytribelist); }) }) }) i have access array mytribelist view this <ion-item *ngfor="let tribe of mytribelist"> <ion-list> <h2>{{tribe.tribedesc}}</h2> <h2>{{tribe.tribename}}</h2> <h2>{{tribe.created}}</h2> <h2>{{tribe.updated}}</h2> </ion-list> </ion-item> but above code not possible. suggestions? update issue occurs because doing this.angularfire.database.list for getmytribedetailsbytribeid(tribeid) method instead of this.angularfire.database.object which in turn generated additional array of objects -array -array -object -array -obj

arrays - For loop only displays last data retrieved from firebase -

Image
i have loop retrieve user's progress typescript: his.userprogress = af.object('/userprogress/' + this.currentuser + '/', { preservesnapshot: true }); this.userprogress.subscribe(snapshots => { snapshots.foreach(snapshot => { this.userscores.push(snapshot.val()); }); console.log(this.userscores); //set 1 i<=8 because total no. of quizzes 9. means this.userscores.length -1 for(var i=0; <= 8; i++){ if (this.userscores.length == i) { this.scores = [{ none: "nothing recorded" }]; console.log("nothing"); } else if (this.userscores.length >= i) { this.scores = [{ chapter:this.userscores[i].chapter_quiz, quizno:this.userscores[i].quiz, score:this.userscores[i].score, }];

dependency injection - How to prevent Controller Constructor argument from growing -

i have project in .net core , have dependency injection going on there. wrapper business layer classes 1 class inject 1 instance controller. need add other things project grows aws s3, ses , other things, started notice have more 4 parameters in controller constructor. is design flaw in part? there way clean up?

ios - How to vertically center the text in WKWebView? -

Image
i using wkwebview in ios (swift) app , using loadhtmlstring(string, baseurl: ). problem want html vertically centered in frame. text variable in length. how can that? this screenshot of html xcode: this image of output. top html on upper side, want centrally aligned in view (the view 300 points top): try using html inline css, can replace stuff in between divs want centered: <div style="display:flex;align-items:center;height:100%;justify-content:center;"> <p>you content here</p> </div> this code works me using swift 3.0 on iphone 6 simulator import uikit import webkit class viewcontroller: uiviewcontroller { var webview:wkwebview? override func viewdidload() { super.viewdidload() } override func viewdidappear(_ animated: bool) { webview = wkwebview(frame: self.view.frame) self.view.addsubview(webview!); addhtml() } func addhtml() { let html = "&

Why does zoom level affect/hinder procedures in Excel VBA? -

so while working on data collection macro noticed gave run-time error when zoomed far out (cells had # symbol), when zoomed in enough see numbers involved in code works fine. reasoning behind this? have thought numbers displayed in excel window printed other source, rather being source of data themselves. for each cell in .range("b2:gl2") if cell.text = trussarray(0) col1 = cell.column goto nextloop end if next nextloop: each cell in .range(.cells(3, col1), .cells(3, col1 + 7)) if cell.text = trussarray(1) col2 = cell.column goto done end if next

python - Trac packages not properly installed -

i checking in redhat server see if there trac installation, trac-admin not in /usr/bin(is found). in /usr/lib/python2.7/site-packages/ there no trac packages @ all, found following paths trac directory in them: /root/.cpan/build/alien-svn-v1.8.11.0-1/src/subversion/subversion/bindings/swig/python/tests/trac /root/.cpan/build/alien-svn-v1.8.11.0-0/src/subversion/subversion/bindings/swig/python/tests/trac /opt2/trac these directories show following: __init__.py test.py versioncontrol and /opt/trac environment of trac: conf db files htdocs log plugins readme templates trac_banner.png version does mean trac installed? can delete directories , try new installation? the directories found under /root/.cpan not indicate trac installed. presence of trac environment @ /opt/trac important find. please make backup of directory @ least, , preferably backup of entire server, before proceeding. to check if trac installed, start python 2.x interpreter session ,

c# - Displaying individual element of objects in arraylist on combobox -

i have object 2 element fields c#, , have inserted them arraylist. trying them display on combobox. this have arraylist mylist = new arraylist(); mylist.add(new myobject("name1", "value1")); mylist.add(new myobject("name2", "value2")) mylist.add(new myobject("name3", "value3")); combobox1.itemssource = drinksarray; the following code display 3 elements "classname.myobject" combobox. i trying display "name1", "name2" , "name3". i have getname() method object not know how implement combobox. you have set combobox.displaymemberpath . https://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.displaymemberpath(v=vs.110).aspx

ruby on rails - Save loop of xml to database table -

please see below xml file: <event id="12987613" link="https://www.skiddle.com/whats-on/bolton/bolton-arena/dldk---dont-let-daddy-know/12987613/?sktag=xxx"> <name><![cdata[dldk - don't let daddy know]]></name> <date>2017-10-07</date> <eventcode>club</eventcode> <shortdesc><![cdata[don't let daddy know returns greater manchester october biggest ever uk show! featuring steve angello, knife party, blasterjaxx]]></shortdesc> <doorsopen>21:00</doorsopen> <doorsclose>06:00</doorsclose> <image>https://d31fr2pwly4c4s.cloudfront.net/9/f/f/962862_3_dont-let-daddy-know_th.jpg</image> <venue id="3764"> <name><![cdata[bolton arena]]></name> <address>bolton arena, arena approach, horwich</address> <city>bolton</city> <town>bolton</town> <citycode>bl6</ci

swift - How do I take a photo programmatically in iOS using takePicture()? -

i working on app assist visually impaired people read restaurant menus, need photo captured via single double-tap of screen. i've used uiimagepickercontroller take photos using standard capture interface. in order via double-tap, have set overlay view general imageview, disabled camera controls , called .takepicture() method. reason, delegate method handles capturing of image doesn't work. can please point me missing? i have commented line on present image picker if called can never leave it. overlay has no buttons photo taking supposed carried out double-tap. any assistance appreciated. best regards, andre. code below: import uikit class viewcontroller: uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { @iboutlet weak var debuglabel: uilabel! @iboutlet var tapchangestate: uitapgesturerecognizer! @iboutlet weak var imageview: uiimageview! var imagepicker = uiimagepickercontroller() // instantiates image pick

OkHttp how to set maximum connection pool size (not max idle connections) -

in okhttp cannot find way set hard maximum connection pool size. documentation https://square.github.io/okhttp/3.x/okhttp/okhttp3/connectionpool.html clear can set maximum idle connections, not overall max. means high load can grow beyond limit. is there way maximize pool? if not, why not? connections either active , held particular in-flight call, or idle , in pool. limit total number of connections limiting number of threads executing http calls. if you’re using call.execute() (synchronous) size thread pool appropriately. if you’re using call.enqueue() (asynchronous) limits in dispatcher .

increase items in shopping cart using rails and redis -

i having trouble increasing quantity of items in cart. add one, switches 'remove' button. there way can reconfigure can add more 1 of each item? carts_controller.rb def add $redis.sadd current_user_cart, params[:item_id] render json: current_user.cart_count, status: 200 end carts.coffee $(window).load -> $('a[data-target]').click (e) -> e.preventdefault() $this = $(this) if $this.data('target') == 'add to' url = $this.data('addurl') new_target = "remove from" else url = $this.data('removeurl') new_target = "add to" $.ajax url: url, type: 'put', success: (data) -> $('.cart-count').html(data) $this.find('span').html(new_target) $this.data('target', new_target) $('#mycart .remove').click (e) -> e.preventdefault() $this = $(this).closest('a') url = $this.data('targe

python 2.7 - Error while using cql connect -

con = cql.connect(host="127.0.0.1",port=9160,keyspace="my_keyspace",cql_version='3.0.0') traceback (most recent call last): file "<stdin>", line 1, in <module> file "build/bdist.linux-x86_64/egg/cql/connection.py", line 143, in connect file "build/bdist.linux-x86_64/egg/cql/connection.py", line 63, in __init__ file "build/bdist.linux-x86_64/egg/cql/thrifteries.py", line 177, in set_initial_keyspace file "build/bdist.linux-x86_64/egg/cql/cursor.py", line 80, in execute file "build/bdist.linux-x86_64/egg/cql/thrifteries.py", line 77, in get_response file "build/bdist.linux-x86_64/egg/cql/thrifteries.py", line 98, in handle_cql_execution_errors cql.apivalues.programmingerror: bad request: have not logged in i new cassandra,please let me know wrong doing here. assuming using https://pypi.python.org/pypi/cql , if go home page, says deprecated https://code.google.co

gcloud - Opensuse Images No Longer Visible in Default Compute Instance -

all, opensuse images not listed active in gcloud showing in gloud commands in project.... opensuse project not mine... can link else's [gcloud shell output my apologies found suitable answer: is possible in google cloud web client create instance image in different project? the command syntax gloud shell is: gcloud compute instances create production-instance-from-staging-image --image staging-image-1 --image-project staging-project for opensuse have link staging project opensuse-project includes images. exact command attached..... enter image description here

amazon web services - Need to screen mirror/cast... not sure if EC2 is the right solution -

i multiple users around world type specific address in browser , able see screen on ec2 instance. i because ec2 instance run live dashboard. can please tell me best service run in order achieve this? you run teleconferencing-type software lets people connect computer , view screen (eg webex). webinar, no humans talking. however, inefficient way share screen. overhead protocol of having send every pixel change every client overkill. instead, easier regularly capture screen of ec2 instance , save s3 . each other computer retrieve picture s3, updating every few minutes, , display on screen. (of course, simpler solution publish dashboard html rather sharing screen of machine, assume have rather complex application cannot publish using web technologies.)

android - Custom Relative layout not rendering any children -

intro: i attempting add various view s custom relativelayout , i.e. button s, imageview s, etc none of them render/show. documentation: as shown on numerous questions: here , here , here , here , many more, i have standard requirements extending layout, i.e. 3 constructors, being: public relativelayout(context context) {} public relativelayout(context context, attributeset attrs) {} public relativelayout(context context, attributeset attrs, int defstyleattr){} referred here on android developer site. implementation: my relativelayout named diceroller has following implementation: public class diceroller extends relativelayout { private diecontainer diecontainer; private context mcontext; private int speed; private runnable movedies; private handler handler; private timer timer; public diceroller(context context) { super(context); mcontext = context; init(); } public diceroller(context context,

How can I use a string as a method name in C#? -

Image
i made short method make easier change console color. string c = red; if (c == "red") console.foregroundcolor = consolecolor.red; i have every color. can type color method , use string color name? like: string c = red; console.foregroundcolor = consolecolor.c; so don't need specify every color. hope mean. i think you're looking enum.tryparse method, take string , try convert enum value (in case you're working consolecolor enum). if parsing successful, method returns true , out parameter contain converted value; otherwise returns false . here's example of method takes string , changes console color if conversion successful: static bool trychangeconsoleforecolor(string newcolor) { consolecolor forecolor; if (enum.tryparse(newcolor, true, out forecolor)) { console.foregroundcolor = forecolor; return true; } return false; } usage static void main() { string color = "red";

angular - Array push is not working correctly -

this problem should quite simple: want push status of each query array called currentvalues. unfortunately, currentvalues-array remains unpopulated (the output of check values 0vs2. missing here? @input() public wantedvalue: string[]; @input() public querysensor: string[]; @input() public slideid: number; @output() wantedstateaccievedevent: eventemitter<any> = new eventemitter<any>(); public currentvalues: string[] = []; inititems() { ( let sensor of this.querysensor ) { console.log("sensor: " + sensor); this.itemservice.getmockitemstate(sensor).subscribe( status => { this.currentvalues.push((status)); }); } this.checkvalues(); } checkvalues(): void { console.log("called checkvalues" + this.currentvalues.length + "vs " + this.wantedvalue.length); let = 0; let allsatisfied: boolean; ( let value of this.currentvalues) { console.log("wert: " + value + '

sql - ER diagram entity generalization -

i'm trying write diagram, have following question: site must manage user entity , signed-in user one. since signed in entity must generalized user 1 attribute can inserted user-father entity make diagram correct? otherwise, can exist father entity without primary key attribute? can suggest me advice solve problem? thank you

javascript - HTML/JS Integration with Ruby -

i have script; trying functional takes images , renders selections on page before user hits submit upload them. script calls input html using ruby code generate input/form submission/uploads. there way can tweak script grab ruby input? script: $(function() { // multiple images preview in browser var imagespreview = function(input, placetoinsertimagepreview) { if (input.files) { var filesamount = input.files.length; (i = 0; < filesamount; i++) { var reader = new filereader(); reader.onload = function(event) { $($.parsehtml('<img>')).attr('src', event.target.result).appendto(placetoinsertimagepreview); } reader.readasdataurl(input.files[i]); } } }; $('#gallery-photo-add').on('change', function() { imagespreview(this, 'div.gallery'); }); }); ruby: <!-- image upload form --> <di

python - How to select specific entry widgets for function calls in tkinter using a touch screen? -

i creating touchscreen gui multiple entry widgets edited using keypad. how can know entry widget user selected? i've created roundabout way each entry coded button , when clicked, button edits 'selected' variable keypad uses know edit there better way? possibly using focus? (i have button widgets working want use commented entry widget, irrelevant code has been deleted post wasn't overly long) class myapp(tk): def __init__(self,*args, **kwargs): tk.__init__(self, *args, **kwargs) container = frame(self) container.pack(side="top", fill="both", expand = true) self.shared_data = { 'codeone' : stringvar(), 'codetwo' : stringvar(), 'selectedcode' : stringvar(), } def setcode(self, value): #function updates selected variable selectedvar = self.shared_data['selectedcode'] if selectedvar.get() == 'codeone&#

Is it possible to get a human readable, nested JSON representation of a GraphQL schema in JavaScript? -

i trying object representation of our graph without writing custom parse output of introspectionquery . ideally json object had keys of type name , type value in shape of results of query. i have been playing around graphql/utilities don't find way 1 thing. any ideas on this? something this: import { graphql } 'graphql'; import { introspectionquery } 'graphql/utilities'; import schema '../schema'; export default async function(req, res) { const result = await graphql(schema, introspectionquery, {}, {}, {}); return res.json(result); } outputs schema, it's not visual representation of our data. found answer here: https://github.com/apis-guru/graphql-voyager represent graphql api interactive graph. it's time see graph behind graphql. can explore number of public graphql apis our list. with graphql-voyager can visually explore graphql api interactive graph. great tool when designing or discussing data model.

ruby on rails - Multiple objects from list of names in an array -

Image
i'm trying create individual record each name in array. array originates via form in 1 controller , individual records need saved in join (type) table (i know there not "join" tables in mongo, it's best way describe it). running rails 5 mongoid/mongodb. originating form: <%= form_tag create_multiple_batch_keg_index_path, method: :create |form|%> <div class="field"> <table class="table table-hover table-condensed"> <thead> <tr> <th>select all</th> <th>keg name</th> </tr> </thead> <tbody> <% keg.each |batch_keg| %> <tr> <td><%= check_box_tag 'batch_keg_ids[]', batch_keg.id -%> </td> <td><%= batch_keg.name -%> </td> </tr> <% e

excel - vba copy and paste rows of data by salesperson into new workbooks by salesperson -

Image
what have here sales report includes sales persons date range. what need macro each salesperson, move sales new workbook, save workbook number , close. here data looks , want macro do i going include code hasn't been working , may not find useful, give idea of im trying accomplish public function reportsummaries() dim row, col, origpersonslastrow, origsaleslastrow, integer dim original workbook dim cell range dim vendorssheet, rawdatasheet worksheet set original = application.workbooks("salesreportrpt (7).xlsm") set vendorssheet = original.worksheets("sales person") set rawdatasheet = original.worksheets("sheet1") 'optimize macro speed application.screenupdating = false application.enableevents = false application.calculation = xlcalculationmanual 'retrieve target folder path user set fldrpicker = application.filedialog(msofiledialogfolderpicker) fldrpicker .title = "select target folder" .allowmultiselect

oop - Representing a status array within a PHP class -

i'm not entirely sure best way handle status field relates integers in database table within class. say have following: $status = array(1 => 'active', 2 => 'inactive', 3 => 'cancelled'); i'm thinking clarity in system, want class constants , getter retrieving status in associative array, , class uses better defined "1" or "2". class user { const user_status_active = 1; const user_status_inactive = 2; const user_status_cancelled = 3; public function getstatuslist() { return array(user::user_status_active => 'active',user::user_status_inactive => 'inactive',user::user_status_active => 'user_status_cancelled'); } } this allows setting status using constants with: class user { private $status_id; const user_status_active = 1; const user_status_inactive = 2; const user_status_cancelled = 3; static public function statuslist() { return array(user::user_status

c# - Xamarin iOS: How to open a .pdf file using the default reader? -

i'm using xamarin ios. i'd have our application open .pdf file in default reader. android managed done following two-fold process: (1) copy file assets folder android device's downloads folder, , (2) starting activity view file. i cannot find similar resources ios. don't want use control in xamarin website, involves downloading lots of javascript (?) code, making size of app bigger, , doesn't support pinching screen zoom. want use os's default pdf reader. thank you. method 1: set build action bundleresource. can set build action file right-clicking on file , and choosing build action in menu opens. create uiwebview , add view: webview = new uiwebview (view.bounds); view.addsubview(webview); load file using nsurl , nsurlrequest classes: string filename = "loading web page.pdf"; // remember case-sensitive string localdocurl = path.combine (nsbundle.mainbundle.bundlepath, filename); webview.loadrequest(new nsurlrequest(new nsurl

android - How create debug keystore for a "Google Play App Signing" project -

for debug keystore (when run application directly out of android studio working google play services - doing sign in , on) have make debug keystore. new feature "google play app signing" generated keystore "upload key (google invented it)" special upload signature. problem (i guess) need debug keystore app signature (i guess). question is: how can create debug keystore "app signature" (the md5 , sha-1 know this), make possible run signed apps out of ide can sign google play services? debug keystores automatically created android studio first time run or debug project in android studio in $home/.android/debug.keystore, , sets keystore , key passwords. however, if you're looking sign app, can execute command in command line : keytool -genkey -v -keystore my-release-key.jks -keyalg rsa -keysize 2048 -validity 10000 -alias my-alias

android - nativescript extend jar class throw exception -

i use nativescript + tyepscript need extend android jar throw exception “type 'any' not constructor function type.” declare var com : any; export class mypushtestreceives extends com.baidu.android.pushservice.pushmessagereceiver.extend { static constructorcalled: boolean = false; // //constructor init() { mypushtestreceives.constructorcalled = true; // necessary when extending typescript constructors return global.__native(this); } }

javascript - Scripting to automate deletion of all Youtube comments -

i'm trying delete old youtube comments via comment history page on youtube. see: https://www.youtube.com/feed/history/comment_history . it's long , tedious process. i've tried record macro run through them doesn't quite work 'menu' button delete comment doesn't appear in same place every time depending on length of comment. i've since decided try , record javascript events via chromes developer menu, feel i'm barking wrong tree here. 'menu' button appears on-hover won't work. any ideas/solutions appreciated.

tuples - Composition of a "List of lists" in Haskell -

i'm quite beginner here, i'm trying make composition of relations ( https://en.wikipedia.org/wiki/composition_of_relations ) of 2 given lists of n-lists funcomp :: ord => [[a,a]] -> [[a,a]] -> [[a,a]] funcomp [[a,b]] [[c,d]] | b == c = [[a,d]] for example, given: [[1,1],[1,2],[2,2],[2,3],[3,3],[3,4],[4,4]] and [[1,4],[1,4],[2,3],[2,3],[3,2],[3,1],[4,1]] should return: [[1,4],[1,4],[1,3],[2,2],[2,1],[3,2],[3,1],[4,1]] how 'make so'? i've included full answer below, in hopes might find helpful. agree @erisco if you're starting out, problem might little advanced. might want start problems involve working one list/relation instead of combining two. (for example, how make relation antireflexive removing elements of form x r x ? how produce set of values y such x r y fixed value x ? can solve these problems both built-in haskell functions , scratch?) anyway, start, may find helpful, standpoint of making easier read, us

Why can't a 3, 2 matrix be multiplied by a 2, 2 matrix with NumPy? -

using numpy , attempting multiply matrices doesn't work. example import numpy np x = np.matrix('1, 2; 3, 8; 2, 9') y = np.matrix('5, 4; 8, 2') print(np.multiply(x, y)) can return traceback (most recent call last): file "vector-practice.py", line 6, in <module> print(np.multiply(x, y)) valueerror: operands not broadcast shapes (3,2) (2,2) i understand can't multiply these shapes, why not? can multiply these 2 matrices on paper, why not in numpy? missing obvious here? np.multiply multiply arguments element-wise. , it's not matrix multiplication. when have matrices, need use * or np.dot matrix multiplication. x * y #matrix([[21, 8], # [79, 28], # [82, 26]]) np.dot(x, y) #matrix([[21, 8], # [79, 28], # [82, 26]])

angularjs - Pass Angular Expression into Javascript -

below have angular expression {{usa_visits.maximum.value |number:0 }} use within javascript in order generate chart. current code: <!-- angular expression --> {{usa_visits.maximum.value |number:0 }} <!-- chart code --> <script> var chart = amcharts.makechart("chartdiv", { "theme": "light", "type": "serial", "startduration": 2, "dataprovider": [{ "country": "usa", "visits": {{usa_visits.maximum.value |number:0 }}, "color": "#ff0f00" }, { "country": "taiwan", "visits": 500, "color": "#333333" }], "valueaxes": [{ "position": "left", "axisalpha":0, "gridalpha":0 }], "graphs": [{ "balloontext": "[[category]]:

SharePoint Form for Master and Detail data? -

Image
i know anyway build master/detail form on sharepoint form allow user enter master/detail @ 1 form?

Matrix dot-product in R -

i tring figure out how dot product. b = matrix(1:70, ncol=7) g= matrix(1:48, ncol=6) resulta = matrix(0,6,7) (c in 1:ncol(b)){ (i in 1:ncol(g)){ resulta[i,c] <- sum((g[,i]) * (b[,c])) } } warning messages: 1: in (g[, i]) * (b[, c]) : longer object length not multiple of shorter object length 2: in (g[, i]) * (b[, c]) : longer object length not multiple of shorter object length ...........................total 42 alike messages whenever multiply matrices, have make sure dimensions such #columns of first matrix same #rows of second i.e. if first matrix a x b , second matrix has b x c (c , may or may not equal) resultant matrix a x c . in case, matrix b 70 x 7 meaning matrix g should 7 x something matrix. in other words, matrix g should have 7 rows. once have fixed dimensions, try quick matrix multiplication: resulta <- b %*% g resulta

asp.net - How can i change/edit SOAP response in ASMX -

im creating soap web service our client , need change response from: <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body> <send_messageresponse xmlns="send_message_response"> <message_response> <message_id>2001</message_id> <description>sent</description> <status>sent</status> </message_response> </send_messageresponse> </soap:body> </soap:envelope> to <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body> <send_message_response xmlns="send_message_response">

set - Finding a greatest pair of combinations of numbers to reach a given sum -

as subject says, how find greatest pair of combination sum given set of number? below example. we given number set {1, 2, 3, 4, 5}. can generate 2^5 combinations out of them. here want find 2 combinations sum equal, , possibly greatest. example) {1, 2} = {3} = sum 3 {1, 3} = {4} = sum 4 .. {1, 5} = {2, 4} = sum 6 .. {2, 5} = {3, 4} = sum 7 out of many combinations, {2, 5} , {3, 4} pair generates equal , greatest sum. here program wants return sum, 7. constraints: no element duplication. element included in 1 combination not included in paired combination. {1, 2, 4} = {3, 4} = sum 7 impossible 4 belongs both combinations. all combination should consist of @ least 1 element. total number of elements in given set 35. (i.e. 2^35 combinations available) (fortunately) need find combinations sum less or equal rounded half of sum of element in given set. e.g) in example above, (1 + 2 + 3 + 4 + 5) / 2 = 7 maximum sum of combination want find out.

html - Javascript array and image -

okay i've asked question before didn't answer solved problem, i'll try explain better. let have array 3 items , let landed on 0 have code set display in div need image displayed right next array displayed. example have array of cars, bmw, civic, , mercedes , let have random number generator , chooses 1 bmw word displayed in div , if civic picked civic has civic logo next , if mercedes picked mercedes have logo next it. if possible want id added in i'll put css of background-image ever pic is(reasoning want add design in picture) <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>js bin</title> </head> <body> <script src="https://code.jquery.com/jquery-3.1.0.js"></script> <ul id="carlist"> </ul> <button id="getrandomcar">get random car</

text - Python, extracting key aspects from consumer reviews -

i have data set of consumer reviews. these reviews extract occurring aspects. process applying includes - step 1: tokenizing reviews sentences - step 2: tokenizing sentences words after basic nlp pre-processing. pre-processing removes punctuation , english stop words. - step 3: pos_tagging , extracting words pos tag of 'nn','nnp','nns','nnps' - step 4: combining words across reviews find occuring words - step 5: using top 40 terms aspects is approach or recommend doing different?

React native detect loading image -

i have problem. use onload, onloadstart , onloadend in image. want wait while server response link image , show image, add loading. jerking constantly. constructor (props) { super(props) this.state = {loading: true}} return( <image onload={(e) => this.setstate({loading: true})} onerror={(e) => this.setstate({loading: false})} onloadstart={(e) => this.setstate({loading: false})} source={this.state.loading ? require('../../img/loading.gif') : { uri: getbesturl(artwork)}} style={styles.artworkimage} resizemode={image.resizemode.cover} />) are returning image constructor or didn't post code? now question, think won't work way since seems change state while it's loading 'loading.gif' or uri image. setting height , weight image? needed can see in docs unlike static resources, need manually specify dimensions of image. https://facebook.gith

arrays print out method java -

i try write program displays values of array , composed of 2 classes. one of these classes contains method uses system.out.print in loop: public class methodsforarray{ int numbers[]; public void printoutarray(){ (int i=0; i<numbers.length; i++){ system.out.print(numbers[i]); } } } in other class method printoutarray() applied: public class application1{ public static void main(string[]args){ methodsforarray myobject=new methodsforarray(); myobject.numbers[]={1,3,4}; myobject.printoutarray(); //here apply method } } this way of doing works display strings or integers. why not work arrays? , how fix program? trying compile class application1, results in following error message: application1.java:5: error: not statement myobject.numbers[]={1,3,4}; ^ application1.java:5: error: ';' expected myobject.numbers[]={1,3,4}; ^ application1.java:5: error: not statement myobject.numbers[]={1,3,4}

java - Null Pointer Exception in Unit test in spock -

i have class "comparisonservice" following fn- public hashmap <string, map<string, object>> fetchtabledata(datasource datasource, list<object> tableinfo){ table.settableinfo(tableinfo); hashmap<string, map<string, object>> records = table.fetchdata(datasource); system.out.println(records.size()); return records; } here table object of other class table i writing spock test method- class comparisonspec extends spock.lang.specification{ table table=mock() def datasource datasource def list<object> tableinfo=[1] def setup() { //def datasource datasource } def "first function"() { given: def comparisonservice comparison= new comparisonservice() when: comparison.fetchtabledata(datasource,tableinfo) then: 1*table.settableinfo(_ string)>>true 1*table.fetchdata(_ datasource) } when run get null pointer exception @ comparison.fetchtabledata(datasource,tableinfo).

ios - Table View (Inside View Controller) Segue Not Working -

Image
i have table view embedded in view controller, , want able setup segues 4 other view controllers depending on cell in view controller clicked. however, can't seem figure out how control+drag segue table view view controller. i believe relevant section of code be: import uikit class viewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { let options = ["home", "my account", "settings", "support"] //mark: properties var selecteditem: string? @iboutlet weak var nametextfield: uilabel! @iboutlet weak var tableview: uitableview! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecell(withidentifier: "cell", for: indexpath indexpath) cell.tex

php - Most straight forward way to retain selected dd option on form submission? -

i have webform has validation functions each field. when submit form, if fails validation, user brought form previous values in input fields , receives error text. working properly. the 1 field not retain selected value/list of values dropdown gets options via ajax on change of dropdown. i've read 1 option submit form via ajax i'd rather not go down path. maybe function on click submit button? ajax: function fillsomelistdropdown(val){ $.ajax({ type: 'get', url: 'ajax/somelist.php?q=' + val, success: function(data){ $('#my-id option:not(:first)').remove(); $('#my-id').append(data); } }); } somelist.php $q = $_get['q']; $response = sp_things_select_all($q); // generate html foreach ($response $value) { echo '<option class="option-input" value="' . $value['value'] . '">' . $value['value'] . '</o

linux - centos samba folder share read as file -

i using centos 7 mount shared network folder (smth), share (smth) using samba (ters), other computer (windows or linux) read shared folder (ters) file, can't open directory, fyi: /etc/fstab //10.11.12.13/smth /smth cifs auto,rw,uid=501,gid=501,username=xxxx,password=xxxx ,inode64 0 0 /smb.conf [ters] writeable = yes path = /smth follow symlinks = yes wide links = yes create mode = 0777 directory mode = 0777 read file, should folder instead thank you whats important here browseable setting: [ters] writeable = yes browseable = yes path = /smth follow symlinks = yes wide links = yes create mode = 0777 directory mode = 0777 also make sure restart samba server after changes(if on debian based, there 2 services restart [smbd , nmbd])

function - R Extract and get the corresponding Numeric values of a string -

need looking function extract , values of requested string separated "-" data: x <- c("aa-aa/bb-11/cc-22/dd-1", "aa-aa/bb-33/cc-331") desired output: bb should vector of (11, 33) cc should vector of (22, 331) you can use stringr task: library(stringr) x <- c("aa-aa/bb-11/cc-22/dd-1", "aa-aa/bb-33/cc-331") bb <- as.numeric(str_match(x, "/bb-([0-9]+)")[, 2]) cc <- as.numeric(str_match(x, "/cc-([0-9]+)")[, 2])

java - How to resolve NullPointerException in JSP -

i developing web application using jsp , servlet , want show records database , number of records in table. i have created dao in performed queries returned data correctly , put in session in servlet giving name of sessaolistamotoristastodos , totalmotorista . but when passing values ​​retrieved session , assigning variables, values ​​are not assigned, called variables list listmotoristas , integer totalregistros giving java.lang.nullpointerexception protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { motoristasdao dao= new motoristasdao(); motoristasdao dao2= new motoristasdao(); string pesquisa=request.getparameter("pesquisa"); try { if(pesquisa==null){ pesquisa=""; } integer totalmotorista=dao.totalregistros(pesquisa); request.setattribute("totalmotoristas", totalmotorista); list listamotoristas2=dao2.mostr

vagrant up or reload error,await_response_state -

i got error yesterday, that's suddenly, upgraded node js version 6.9 8.4 in virtual machine, don't know how resolve it. vagrant version vagrant 1.8.7 host operating system win10 virtual machine operating system centos linux release 7.3.1611 (core) this vagrantfile vagrant.configure(2) |config| config.vm.box = "centos-7-vagrant-1505-x86_64-01" config.vm.network "private_network", ip: "192.168.33.10" config.vm.synced_folder ".", "/home/vagrant/sync", type: "virtualbox" config.vm.synced_folder "../project", "/home/vagrant/project", type: "virtualbox" config.vm.provision "shell", inline: <<-shell shell end and latest output, or reload can't done c:\www\htdocs\vagrant>vagrant reload ==> default: attempting graceful shutdown of vm... ==> default: forcing shutdown of vm... ==> default: clearing set forwarded ports... ==> de