Posts

Showing posts from June, 2015

python - Dataframe Boolean Logic Index Match -

i have created pandas data frame , filter data based on boolean logic. i'd closer excels' index match function simple filtering. have researched lot of other threads. when apply filter, data frame returns 0 true values. why 0 true values being returned when have been flexible logic? and; if introduced 5th column, column 'd' , random.randomint(100-1000,100) , logic use conditionally find maximum values column d ? i.e. can force data frame return highest true values column, in event multiple true values returned? advice appreciated. thank in advance. import pandas pd df = pd.dataframe({ 'step': [1,1,1,1,1,1,2,2,2,2,2,2], 'a': [4,5,6,7,4,5,6,7,4,5,6,7], 'b': [10,20,30,40,10,20,30,40,10,20,30,40], 'c': [0,0.5,1,1.5,2,2.5,0,0.5,1,1.5,2.0,2.5] }) columns = ['step','a','b','c'] df=df[columns] new_df=df[(df.step == 1) & (df.a == 4|5|6|7) & (df.b == 10|20|30|40)] new_df ...

python - How to put different in magnitude values at same distance on x-axis -

Image
i'm using python plot several straight lines on same plot. have great variability in values magnitude on x values (called variable q in code), want put them @ same distance on x-axis, in order have clear vision on first part of graph. here code: def c(m,x): ''' linear cost function, describing costs each weight range :param m: slope, modelling rates :param x: abscissa, modelling quantity ordered :return: cost value each quantity ''' return m * x in range(0,9): w = np.arange(0., q[9], 0.01) plt.plot(w,c(r[i],w),'b--',linewidth=0.3) plt.plot( [q[i],breakpoints[i]] , [c(r[i], q[i]), c(r[i], breakpoints[i])], 'r') plt.plot(q[i + 1], c(r[i], breakpoints[i]), 'r.') plt.show() for sake of simplicity, here there data involved in code snippet: as can see, classical quantity discount study. so, if plot these values, can't distinguish happening @ first straight lines, since little space reserved first q ...

html php mysql secure -

i use php manage html , have problem input date in mysql. input in mysql or update or delete in mysql ok how can make security input data in mysql because if 1 open see html source code browser can see predefined inputs , can change thats in html , after enter wronk inputs in mysql. this code: options value: <select name="extend"> <option value="<?php $_end1;$newdate = date('y-m-d', strtotime($_end. " + 1 month"));echo $newdate;?>">1 month</option> now when if open browser , see code can replease 1 month several month , in mysql. how can secure , or hide in html. thx if you're wanting have fields or input can't edited user, such current date form submitted on or along lines of that, need do of on server side (not client side). data submitted client side can (and should treat will) changed. instead of having form fields preset values, fields hidden, fields disabled, data render...

JQ: maximum file path length (windows) -

i use jq (1.5) in windows 10 environment json transformation operation (to load data api sql server). checked yesterday new copy of jq transform command on test enviroment , run in morning in exception (jq command, source , destination files identical). different between old , new 1 filepath: old: c:\import\ new: c:\import\test20170725\ following command (in powershell) used: jq.exe -f c:\import\test20170725\jqfilter_cruises.jq c:\import\test20170725\dreamlines_cruises.json | out-file -encoding utf8 -filepath c:\import\test20170725\import_cruises.json i experimented today , looks path input files limited in maximum length. if reduce filepath there command works fine (like original one). tips? regards timo

scala - Spark dataframe select rows with at least one null or blank in any column of that row -

from 1 dataframe want create new dataframe @ least 1 value in of columns null or blank in spark 1.5 / scala. i trying write generalize function create new dataframe. pass dataframe , list of columns , creates record. thanks sample data : val df = seq((null, some(2)), (some("a"), some(4)), (some(""), some(5)), (some("b"), null)).todf("a", "b") df.show +----+----+ | a| b| +----+----+ |null| 2| | a| 4| | | 5| | b|null| +----+----+ you can construct condition as, assume blank means empty string here: import org.apache.spark.sql.functions.col val cond = df.columns.map(x => col(x).isnull || col(x) === "").reduce(_ || _) df.filter(cond).show +----+----+ | a| b| +----+----+ |null| 2| | | 5| | b|null| +----+----+

linux - How to create a git alias to recursively run a command on all submodules? -

i have following command run manually: $ git fetch --all && git reset --hard @{u} && git submodule foreach --recursive "git fetch --all && git reset --hard @{u}" i'm using git v2.13.0. goals are: run specified command on parent (current) repository first. execute same command on submodules, recursively. i tried create alias so: [alias] run = !f() { \"$@\" && git submodule foreach --recursive \"$@\"; }; f" which run (using earlier example): $ git run "git fetch --all && git reset --hard @{u}" however following error (with git trace enabled diagnostics): 09:38:31.170812 git.c:594 trace: exec: 'git-run' 'git fetch --all && git reset --hard @{u}' 09:38:31.170899 run-command.c:369 trace: run_command: 'git-run' 'git fetch --all && git reset --hard @{u}' 09:38:31.172819 run-command.c:369 trace: run_comma...

swift - Change a button's characteristic outside class programatically -

in code below, want able change visibility of button in class, when try change button.ishidden false, button still doesn't show up. view controller 1: override viewdidload(){ button.ishidden = true } view controller 2: viewcontroller1().button.ishidden = false how can change button's visibility controller calling viewcontroller1() creates viewcontroller1 instance instead of working viewcontroller1 instance has been instantiated. to access properties (in case button) of viewcontroller1 viewcontroller2 , have pass reference button viewcontroller1 viewcontroller2 , change properties through reference. you need set reference in prepare(for segue) function in viewcontroller1 . override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "mysegue { let nextvc = segue.destination as! viewcontroller2 nextvc.button = sender as! uibutton } } you need set segue manual , call in ...

Mybatis-3.4.2 version of rowbounds can not implement paging -

mybatis-3.4.2 version of rowbounds can not implement paging. passing new rowbounds (0, 10) arguments method implemented, value of rowbounds becomes default when skiprows (rsw.getresultset (), rowbounds) method executed, , why? there solution?

hadoop - Pig script doesn't work with MapReduce -

i'm trying use hadoop , apache pig. have .txt file data , script .pig file script : student = load '/home/srv-hadoop/data.txt' using pigstorage(',') (id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray); student_order = order student firstname asc; dump student_order; and .txt file : 001,rajiv,reddy,21,9848022337,hyderabad 002,siddarth,battacharya,22,9848022338,kolkata 003,rajesh,khanna,22,9848022339,delhi 004,preethi,agarwal,21,9848022330,pune 005,trupthi,mohanthy,23,9848022336,bhuwaneshwar 006,archana,mishra,23,9848022335,chennai 007,komal,nayak,24,9848022334,trivendram 008,bharathi,nambiayar,24,9848022333,chennai but, when execute : pig -x mapreduce data.pig 17/07/25 17:04:59 info pig.exectypeprovider: trying exectype : local 17/07/25 17:04:59 info pig.exectypeprovider: trying exectype : mapreduce 17/07/25 17:04:59 info pig.exectypeprovider: picked mapreduce exectype 2017-07-25 17:04:59,399 [main] info org.apache.p...

python - Is there a way to add arrows for nx. draw in networkx? -

Image
i using networkx in python , using nx.draw function takes in arrows=true parameter, arrows don't seem show up. when doing this, using g=nx.graph(), when use g = nx.digraph(), arrows show up, default network shape lost. there way preserve default network layout comes nx.draw , have arrows? yes, have fix positions yourself, see below example using circular_layout . import networkx nx import matplotlib.pyplot plt g = nx.erdos_renyi_graph(20, 0.2) pos = nx.circular_layout(g) nx.draw_networkx(g, pos=pos) plt.show() pos dictionary nodes keys , coordinates values. plot digraph (with same node set): g1 = nx.digraph(g) nx.draw_networkx(g1, pos=pos) plt.show()

java - unexpected char: '@' - Handling Pivots and Annotation with JpaRepository -

i test out sql queries using native sql, before bringing them spring jparespository files. i (with of @curiouskid) able perform pivot table (which displays data in "excel-friendly fashion) , separate endpoint. for brevity, display first few lines (which causing error): com.example.demo.repositories.salesrepository package com.example.demo.repositories; import java.util.list; import org.springframework.data.jpa.repository.jparepository; import org.springframework.data.jpa.repository.query; import org.springframework.stereotype.component; import com.bofa.app.entities.sales; @component public interface salesrepository extends jparepository<sales, long> { @query("declare " + "@cols nvarchar(max), " + "@convertcols nvarchar(max), " + "@query nvarchar(max), " ... note, have several other queries aren't using declare annotations (and simple queries) working fine within repository. declare keyword isn't ...

sql server - Return a column to notify row change of another column -

i have table: |----fruit----| |-------------| |--apples--| |--apples--| |--apples--| |--apples--| |-bananas-| |-bananas-| |-oranges-| |--plums---| |--plums---| i have below script: case when [fruit] = [fruit] '0' else [fruit] end what want return 2 columns. 1 fruit column , 2nd column shows when fruit column changes next fruit, have following:- |----fruit----||fruit change| |-------------||----------------| |--apples--||-------0-------| |--apples--||-------0-------| |--apples--||-------0-------| |--apples--||-------0-------| |-bananas-||--bananas--| |-bananas-||-------0-------| |-oranges-||---oranges---| |--plums---||----plums----| |--plums---||-------0-------| |--plums---||-------0-------| |--plums---||-------0-------| |--plums---||-------0-------| |--mango---||---mango---| |--mango---||-------0-------| how return column corresponding change in fruit script above doesn't allow me specify need do. you can use lag below: select fruit,case when frui...

Create an Azure VM with an unmanaged disk -

i'm trying create azure vm unmanaged disk via powershell since managed disks aren't supported in azure government yet. none of documentation find powershell vm creation references managed or unmanaged disks , default seems managed disks. vm creation fails following error: new-azurermvm : managed disks not supported in region. errorcode: badrequest here's script i'm using: $location = "usgovtexas" new-azurermresourcegroup -name myresourcegroup -location $location # create subnet configuration $subnetconfig = new-azurermvirtualnetworksubnetconfig -name mysubnet -addressprefix 192.168.1.0/24 # create virtual network $vnet = new-azurermvirtualnetwork -resourcegroupname myresourcegroup -location $location ` -name myvnet -addressprefix 192.168.0.0/16 -subnet $subnetconfig # create public ip address , specify dns name $pip = new-azurermpublicipaddress -resourcegroupname myresourcegroup -location $location ` -allocationmethod stat...

haskell - Is it possible to combine instances of a typeclass? -

i have feeling isn't possible, love input see if there's extensions or techniques i'm missing. i have generic instance of typeclass defines default methods: class testclass foo :: -> maybe text bar :: -> [int] instance testclass foo _ = nothing bar _ = [] data specifictype = somevalue | othervalue instance testclass specifictype foo somevalue = "success" foo othervalue = "other success" i believe needs overlappinginstances , problem instance of testclass specifictype doesn't implement bar . i'd declare part of second instance, , use default implementation rest. there way achieve this? in haskell 98, can put default implementations in class definition : class testclass foo :: -> maybe text foo _ = nothing -- default implementation bar :: -> [int] bar _ = [] -- default implementation now instance s not implement foo or bar yourself, take default implementation. ...

html - How can I make a div that is set in pixels resize according to the page? -

Image
i have progress bar uses arrows way know how make using pixels. wondering if there way create progress bar using pixels, , change size according page. have looked @ similar questions, none pertain type of element creating. attached bar looks like, , want able make adaptable screen size. .containerr { font-family: 'lato', sans-serif; float: left; position: relative; width: 70%; height: 100%; } .wrapperr { float: left; width: 70%; height: 100%; position: relative; /*overflow:auto;*/ } .pull-right { } a:hover { color: #999; } /* breadcrups css */ .arrow-steps { zoom: 1.4; position: relative; display: inline-flex; vertical-align: top; } .arrow-steps .step { font-size: 100%; text-align: center; color: #666; cursor: default; margin: 0 3px; padding: 10px 10px 10px 30px; min-width: 180px; float: left; position: relative; background-color: #d9e3f7; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; ...

javascript - Extract Input parameters from react component -

my input component receives index props looks this: renderlibraryinputform(props) { return ( <grid> <row> <col xs={6} md={3}> <formgroup> <controllabel>library name</controllabel> <input type="text" classname="form-control" name={`libraryname${props.index}`} onchange={this.onaddlibraryinputchange.bind(this, `libraryname${props.index}`)} /> </formgroup> </col> <col xs={6} md={2}> <formgroup> <controllabel>available status</controllabel> <input type="text" classname="form-control" name={`av...

python - Subprocess with Rscript error -

python code: import subprocess def execution(): exp=subprocess.popen(["rscript","expo.r"],stdout=subprocess.pipe, shell = false) line in exp.stdout.readlines(): line = line.strip() return(line) execution() my r script runs fine however sublime text throws back: traceback (most recent call last): file "/users/user/desktop/work/7-26-17/pyc.py", line 7, in <module> execution() file "/users/user/desktop/work/7-26-17/pyc.py", line 3, in execution exp=subprocess.popen(["rscript","expo.r"],stdout=subprocess.pipe, shell = false) file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__ restore_signals, start_new_session) file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child raise child_exception_type(errno_num, err_msg) filenotfoun...

outlook - Send POST AJAX request from Office Add-In -

i'm trying send post ajax request third party service outlook add-in, no matter tried receiving error: access denied , , status 0 (request never hit server). assuming running ie9 or 8 behind outlook tried old school hacks https://github.com/moonscript/jquery-ajaxtransport-xdomainrequest . $.ajax({ url: endpoint, data: json.stringify({'1':'2'}), // headers: {'x-requested-with': 'xmlhttprequest'}, contenttype: 'text/plain', type: 'post', datatype: 'json', error: function(xhr, status, error) { // error } }).done(function(data) { // done }); is there more need implement? of cause add domain manifest appdomain property. cheers the following needs done send request 3rd party service ... add service uri appdomain list (you've done it.) the service must have ssl endpoint; " https://your.domain " must included within of "appdomain" entry...

python - pip3 not installing in correct folder -

while python3 expects modules in /usr/local/lib/python3.4 , pip3 installs them in /usr/local/lib/python3.4/dist-packages . results in python3 not finding packages pip3 says installed. i tried cutting , pasting stuff in /usr/local/lib/python3.4/dist-packages /usr/local/lib/python3.4 , end weird errors, this: traceback (most recent call last): file "setup.py", line 13, in <module> cython.build import cythonize file "/usr/local/lib/python3.4/cython/build/__init__.py", line 1, in <module> .dependencies import cythonize file "/usr/local/lib/python3.4/cython/build/dependencies.py", line 51, in <module> ..compiler.main import context, compilationoptions, default_options file "/usr/local/lib/python3.4/cython/compiler/main.py", line 30, in <module> .symtab import modulescope file "/usr/local/lib/python3.4/cython/compiler/symtab.py", line 18, in <module> . import pyrextypes fi...

ruby - Rails 5 Rspec ActionController::UrlGenerationError -

searched through other similar questions on here, , seem related malformed request of sort (not providing id , or not including params correctly) don't seem problem i'm having. the route exists, going route in browser works fine. page loads, everything. rspec giving me urlgenerationerror reason. i've tried manually specifying controller name in routes, changing pluralized controller, , using different (pluralized) controller. it's seeming there issue other configuration somewhere, error it's urlgeneration error extremely unhelpful. appreciate other ideas. we have api controller specs elsewhere in our app seem functioning correctly, cannot tell difference in set between , one. my error: 1) spaceman::reputationenhancementscontroller show has 200 status code failure/error: :show actioncontroller::urlgenerationerror: no route matches {:action=>"show", :controller=>"spaceman/reputation_enhancements"} # ./sp...

Android splash screen / launch screen also shows when keyboard is resizing -

i have blue image splash screen startup. however inside app when open keyboard closed shows background imagine of splash screen brief second looks weird. windowsoftinputmode set to android:windowsoftinputmode="adjustresize" i think adjustresize right. what solve problem? why splash screen in background? no clue if already, activities splash screen use once , returning isn't wanted, remember call finish() . if finish activity, not in activity stack. try adding finish() after intent takes away splash screen

php - Keep delimiter when splitting string -

my code below not keep delimiter when splitting strings using preg_split . $feature_description = "- 1.read/write speed performance based on internal testing.- 2.tbw (terabytes written) values calculated capacity."; preg_split('/(- [0-9].)/',$feature_description,null,preg_split_delim_capture | preg_split_no_empty); now output was: [0] => - 1. [1] => read/write speed performance based on internal testing. [2] => - 2. [3] => tbw (terabytes written) values calculated capacity. but want output as: [1] => - 1.read/write speed performance based on internal testing. [2] => - 2.tbw (terabytes written) values calculated capacity. rather splitting should doing match using preg_match_all using lookahead based regex: -\h+\d+.+?(?=-\h+\d+|\z) regex demo regex breakup: -\h+\d+ : match hyphen followed 1+ horizontal whitespaces , 1+ digits .+? : match 0 or more of character (lazy) (?=-\h+\d+|\z) : lookahea...

android - How to use a view pager with keyboard as in fancy keyboard apps? -

i want create app keyboard while creating got know keyboard used service , there particular view has created using row tag, , of part defined in xml. want know, how apps fancy key , bobble creating keyboards services , using customized fonts , themes. searched on google nothing comes effective. most specifically, want know how create view pager has viewpager , can used service. any appreciacted.

javascript - Tumblr Masonry + Infinite scroll overlaps on loading next set of posts -

i new javascript , programming in general, therefore cannot figure out doing wrong here. want fit photoset post container perfectly, changed {photoset-500} {photoset} automatically measures size , fits in. that, however, when scroll these specific photoset containers overlap. every other img fine. it doesn't happen in first loaded posts, when scroll. website: http://tototo232.tumblr.com/ (password: 123) my script <script type="text/javascript"> $(window).load(function() { var $wall = $('#posts'); $wall.imagesloaded(function() { $wall.masonry({ itemselector: '#entry, #entry_photo,', isanimated: false }); }); $wall.infinitescroll({ navselector: '#page-nav', nextselector: '#page-nav a', itemselector: '#entry, #entry_photo,', bufferpx: 2000, debug:...

why does my functor member variable "reset" ? (c++) -

i learning how use functors, , created one, , don't understand why counter variable 0 @ end of programm. here code: #include"stdafx.h" #include<iostream> #include<vector> #include<algorithm> #include<map> #include<list> using namespace std; class myfunctor { public: myfunctor():counter(0) {} void operator()(int i) { cout << "in functor: " << ; counter++; cout << " counter=" << counter << endl; } int getcounter() const { return counter; } private: int counter; }; int main() { vector<int> v{ 1,2,3,4,5,6,7,8,9,10 }; myfunctor f; for_each(v.begin(), v.end(), f); cout << "counter=" << f.getcounter() << endl; return 0; } here result gives: in functor: 1 counter=1 in functor: 2 counter=2 in functor: 3 counter=3 in functor: 4 counter=4 in functor: 5 counter=5 in functor: 6 counter=6 in functor: 7 c...

go - How to add dependency to godep.json? -

i'm having hard time add dependency godeps.json file. think i've messed gopath . tried various suggestions on warnings none of them worked me. gopath /users/sarath/project . which go /usr/local/bin/go . if try godep save ./... , giving me following warning: godep: [warning]: godep should used inside valid go package directory , godep: [warning]: may not function correctly. outside of $gopath. godep: [warning]: current directory: /users/sarath/project godep: [warning]: $gopath: /users/sarath/project godep: unable find srcroot package . i have pkg inside /users/sarath/project . that won't work. gopath isn't path of project; it's root of directory, contains bin , pkg , , src directories; src directory contains package-named directories projects. should running godep project directory, (given current gopath) should /users/sarath/project/src/<repopath> - e.g. /users/sarath/project/src/github.com/sarath/myproject .

lapply - extracting data from nested list in R -

i have download list of addresses google_reverse_code api list of places latitude , longitude information, since i'm new in r. don't know how extract useful information. code downloading databases @ bottom of question. the structure of list in general this. `$ 60 :list of 1 ..$ results:'data.frame': 1 obs. of 5 variables: .. ..$ address_components:list of 1 .. .. ..$ :'data.frame': 8 obs. of 3 variables: .. .. .. ..$ long_name : chr [1:8] "119" "avenida diego díaz de berlanga" "jardines de anahuac 2do sector" "san nicolás de los garza" ... .. .. .. ..$ short_name: chr [1:8] "119" "avenida diego díaz de berlanga" "jardines de anahuac 2do sector" "san nicolás de los garza" ... .. .. .. ..$ types :list of 8 .. .. .. .. ..$ : chr "street_number" .. .. .. .. ..$ : chr "route" .. .. .. .. ..$ : chr [1:3] "political" "sublocality...

javascript - Windows Powershell for automating click on input tag (image type) with onclick event -

i trying automate clicking input tag image type using powershell script. script opens web page not click invoke javascript function. missing something? code in page: <input name="cv300$ctl42$g_11d90fd5_84d4_40f9_b5cc_e8ca081abd9b$btnexportcsv" title="export csv file format" id="cv300_ctl42_g_11d90fd5_84d4_40f9_b5cc_e8ca081abd9b_btnexportcsv" style="border-width: 0px; cursor: pointer;" onkeypress="" onclick='javascript:webform_dopostbackwithoptions(new webform_postbackoptions("cv300$ctl42$g_11d90fd5_84d4_40f9_b5cc_e8ca081abd9b$btnexportcsv", "", true, "", "", false, false))' type="image" alt="" src="/_layouts/15/images/icxls.gif"> my powershell script: $url = "https://sharepoint/site/page.aspx" $ie = new-object -com internetexplorer.application $ie.navigate2($url) $ie.visible = $false while($ie.readystate -ne 4) {start-sleep -m 100...

Angular 4 ngx-treeview integration with json response -

i'm new angular 4 , using ngx-treeview( https://www.npmjs.com/package/ngx-treeview ) tree structure. using static data able bind view tree. but need use rest service tree structure hence created similar class treeviewitem ngx-treeview public class treeviewitem { public string text { get; set; } public int value { get; set; } public bool collapsed { get; set; } public treeviewitem[] children { get; set; } } here json response i'm getting [{"text":"core fields","value":100,"collapsed":false,"children":null}] angular service: return this.http.get(this.apphelperssvc.apiaddress + "api/module/getstandardfields", { headers: httpheaders }) .map((response:response) => <treeviewitem>response.json()); angular component itemslist: treeviewitem[]; this.moduleservice.getstandardfields().subscribe(data => {this.itemslist = data;}); doing i'm getting uncaught typeerror: this....

reactjs - React: Prop Not Displayed in React Component -

i passing prop in react route component listed below: <route exact path='/' component={homepage} display_notification={this.display_notification.bind(this)} /> but when print props of homepage cannot find display_notification. please help. i using react-router-v4 route not recompose props you, passes internal location related props only. need use render={} api - https://reacttraining.com/react-router/web/api/route/render-func so like <route exact path='/' render={() => <homepage display_notification={this.display_notification} />} />

c# - Checking value of JSON property fails to compare to string -

i'm building user registration , store user data in json files. reason can't compare value of property string. sample code: public bool isregistered() { jobject data = jobject.parse("{\"registered\":\"yes\"}"); var registered = data["registered"]; if (registered != "yes") { return true; } return false; } i error on if (registered != "yes") operator of type != cannot used in operand of type jtoken , string because registered of type jtoken , can not compare string . can cast string this: var registered = (string)data["registred"]; if (registered != "yes")

ms access - Combo Box Hanging onto old data -

i have form have placed toggle button user may clear data they've 3 combo boxes. i've created sql delete data in table form bound to, combo boxes still retaining data despite table being clear of data. how can reset combo boxes? when have form open , close, old data still in combo box. reset combos. help! private sub reset_company_marketer_product_click() dim dltprvcompmarkprod_tablesql string dltprvcompmarkprod_tablesql = "delete user_subproducts.* user_subproducts;" docmd.setwarnings false docmd.runsql dltprvcompmarkprod_tablesql docmd.setwarnings true private sub reset_company_marketer_product_click() dim dltprvcompmarkprod_tablesql string dltprvcompmarkprod_tablesql = "delete user_subproducts.* user_subproducts;" me!company_select_combo = null me!marketer_select_combo = null me!product_select_combo = null company_select_combo.enabled = true marketer_select_combo.visible = false product_select_combo.visible = false do...

java - Cannot resolve method 'setAdapter()' -

i have found several questions similar one, none of them fix issue. here code have written - databasehelper databasehelper; arrayadapter<string> madapter; listview noteslist; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); databasehelper = new databasehelper (this); noteslist = (listview) findviewbyid(r.id.noteslist); loadnoteslist (); } public void loadnoteslist () { arraylist<string> noteslist = databasehelper.getnamelist(); if (madapter == null) { madapter = new arrayadapter<string>(this, r.layout.row, r.id.note_name, noteslist); noteslist.setadapter(madapter); } else { madapter.clear(); madapter.addall(noteslist); madapter.notifydatasetchanged(); } } ... my code seems code in tutorial following, , code seems in correct place, know missing or did wrong, because android studio gives ...

swift3 - Reusable *button* in Xcode -

i've created actionsheet 3 options push other view controllers , call number. option on button on navigation bar on each screen of app. i'm trying find way reuse code without literally re-typing every screen. understand there way through subclassing uibutton i've searched days , can't find definitive answer on how code subclass. code right following: class morebutton: uibutton { @ibaction func displayactionsheet(_ sender: any) { let alertcontroller = uialertcontroller(title: nil, message: "get roast on", preferredstyle: .actionsheet) let followaction = uialertaction(title: "follow us", style: .default, handler: {(action: uialertaction!)->void in self.performsegue(withidentifier: "movesegue", sender: self) }) let shopaction = uialertaction(title: "visit shop", style: .default, handler: {(action: uialertaction!)->void in self.performsegue(withidentifier: "shopsegue", sender: self) ...

datetime - How to convert a long date to short date from SSL certificates | Unix KSH -

i'm wondering if possible convert date show oct 31 00:00:00 2013 gmt 10-31-2013 . i'm getting date follow: notbeforedate=$(openssl x509 -noout -in ${certificate} -dates | grep "notbefore") the date i'm getting oct 31 00:00:00 2013 gmt , wanted convert 10-31-2013 . there's command that? or have manually? if so, best way create own function , send long date parameter , return short date. the openssl command make notbeforedate variable have value (at least in bash version i'm using): notbefore=oct 31 00:00:00 2013 gmt so, first need remove notbefore= part: datestr=${notbeforedate/notbefore=/} then can use date command: date --date="$datestr" --utc +"%m-%d-%y" the --date option tells command use datestr value, --utc tells date in utc (as specified gmt part) , +"%m-%d-%y" formats date desired format. the output is: 10-31-2013 ps: options can vary according linux version. ca...

arrays - Python: Creating an N-dimensional list from separate lists of varying sizes and dtypes -

say have these lists: a = [1, 2, 3, 4] b = [6,7] c = ['a', 'b', 'c'] i create 3-dimensional data structure contains new lists combining elements of each list in possible ways. access these new list using matrix indexing. so example, f function want. this: m = f(a,b,c) then m[0][0][0] give [1,6,'a'], m[1][0][0] give [2,6,'a'], , on. basically, know can using nested loops. jlist = [] j in a: klist = [] k in b: llist = [] l in c: o = [j,k,l] llist.append(o) klist.append(llist) jlist.append(klist) this gives me list of lists of lists of lists. [[[[1, 6, 'a'], [1, 6, 'b'], [1, 6, 'c']], [[1, 7, 'a'], [1, 7, 'b'], [1, 7, 'c']]], [[[2, 6, 'a'], [2, 6, 'b'], [2, 6, 'c']], [[2, 7, 'a'], [2, 7, 'b'], [2, 7, 'c']]], [[[3, 6, 'a'], [3, 6, 'b'], [3, 6, 'c...

C integer/float array strange behavior -

okay fooling around making random programs , seeing outputs understanding how things work , noticed strange thing integer/float arrays. unlike char array '\0' character not stored directly after last entered element array. in integer array stored 2 elements after last element , in float 4 elements. here's code demonstrate strange fact. please me understand why happens. #include <stdio.h> #include <string.h> void foo(int* x) { while ( *(x) != '\0' ) { printf("%i ",*x); ++x; } } void foo1(float* x) { while ( *(x) != '\0') { printf("%.1f ",*x); ++x; } } void foo2(char* x) { while( *(x) != '\0' ) { printf("%c",*x); ++x; } } int main(void) { int a[4] = {1,2,3,4}; float b[4] = {1.1,2.2,3.3,4.4}; char name[] = "muneeb"; foo(a); printf("\n\n"); foo1(b); printf("\n\n...

android - When onActivityResult is ran resultCode is 0 and data is null -

i have activity sends boolean array inventory class maingame activity. when onacivityresult runs resultcode 0 , data null. starting inventory activity: @requiresapi(api = build.version_codes.jelly_bean) public void openinventory(view v) { intent bag = new intent(maingame.this, inventory.class); bag.putextra(booinventory, inventory); startactivityforresult(bag, requestitem); } ending inventory activity: public void onpause(){ intent item = new intent(inventory.this, maingame.class);//data sent maingame activity item.putextra(tools, itemused); setresult(result_ok, item); super.onpause(); } onactivityresult: (toaster method creates toast) @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if(requestcode == 2){ if(resultcode == result_ok){ toaster("result ok",...

java - Javafx: Recovering the text of a label contained within a pane through pane.getChildren().get(index) -

this problem i've been trying deal hour now, figured might ask question. goal/question behaviour of list supplied pane.getchildren(). explain better, here's bit of example code. vbox pane1 = new vbox(); label label1 = new label("a"); label label2 = new label("b"); pane1.getchildren().addall(label1,label2); system.out.println(pane1.getchildren().size()); (int i=0; i<pane1.getchildren().size(); i++) { system.out.println(i + pane1.getchildren().get(i).(??????????) } the list pane1.getchildren() of size 2, pane1.getchildren().get(i) doesn't allow me use label related methods (such gettext(), 1 i'm interested in accessing). happening here, why isn't pane1.getchildren().get(i) acknowledged label? also worth adding, if run for (int i=0; i<pane1.getchildren().size(); i++) { system.out.println(i + pane1.getchildren().get(i).getclass().getname()); } the console output says, name of class "javafx.scene.control.label". ...

python - How to one-hot-encode from a pandas column containing a list? -

i break down pandas column consisting of list of elements many columns there unique elements i.e. one-hot-encode them (with value 1 representing given element existing in row , 0 in case of absence). for example, taking dataframe df col1 col2 col3 c 33 [apple, orange, banana] 2.5 [apple, grape] b 42 [banana] i convert to: df col1 col2 apple orange banana grape c 33 1 1 1 0 2.5 1 0 0 1 b 42 0 0 1 0 how can use pandas/sklearn achieve this? we can use sklearn.preprocessing.multilabelbinarizer : from sklearn.preprocessing import multilabelbinarizer mlb = multilabelbinarizer() df = df.join(pd.dataframe(mlb.fit_transform(df.pop('col3')), columns=mlb.classes_, index=df.index)) result: in [77]: df out[77]: col1 col2 apple banana grape orange 0 c 33.0 ...