Posts

Showing posts from May, 2010

android - React Native: Get flexDirection row items to render on next render if outside of view's boundaries -

i have view container containing multiple view tags using flexdirection: 'row' property. however, issue arises when have many elements in container view . reasons, view components inside container don't wrap , overflow outside container. see image here you can see view container has border, contents flowing outside of it. my render function render() { let test = ["acute pain","acute pain","acute pain","acute","acute","acute","acute"] let tagnames = test.map((tagname, index) => { return ( <view style={{backgroundcolor: '#1bb393', padding: 3, borderradius: 5, marginright: 5}}> <text style={{color: 'white', fontfamily: 'facit'}}>{tagname}</text> </view> ) }) return ( <view style={{flexdirection: 'row', flex: 1, borderwidth: 1}}>{tagnames}</view> ) }

c# - I have an existing interface (with properties) whats the best way to segregate read and write -

using c# have existing interface wish split read , write interfaces still keep original. best way? i make 3 independent interfaces: interface iexistingreadwrite{ int width {get; set;} } interface iread{ int width {get;} } interface iwrite{ int width {set;} } or make iexistingreadwrite inheret iread , iwrite, clearer other coders when @ iexistingreadwrite there segregated iread , iwrite interfaces available too... interface iexistingreadwrite: iread, iwrite{ new int width {get; set;} } interface iread{ int width {get;} } interface iwrite{ int width {set;} } but i've had use 'new' on iexistingreadwrite shadow properties in iread , iwrite otherwise warnings ambiguity occur. shadowing not intention iexistingreadwrite 'pass work on' interfaces inhereted define new property (so there no opportunity there being seperate implementations each of seperate interfaces occuring). there better way. it looks corak has best answer far...

regex - Match last dir before filename in unix path -

i need find regex extract last dir before file in full path strings these: ./resources/views/product/edit.html.twig ./resources/views/product/show.html.twig ./resources/views/product/new.html.twig so these strings yield 'product'. you may use ([^/]+)/[^/]*$ see a demo on regex101.com . broken apart, says: ([^/]+) # capture not /, @ least once / # / [^/]* # 0+ not / $ # end of line depending on actual language and/or delimiters used, may need escape forward slashes \/ .

numpy - Python / py2exe - How to resolve / suppress OMP warning messages? -

first, installed versions of python / various modules: python: 2.7.1 numpy: 1.13.1 scipy: 0.19.1 py2exe: 0.6.9 the modules installed wheels available here: http://www.lfd.uci.edu/~gohlke/pythonlibs/ i have python code have written compiling single, stand-alone executable "future-proof" it, , allow run on other pc's might not have same modules installed do. having same issue described in following posts: omp warning when numpy 1.9.2+mkl packaged py2exe omp warning when numpy 1.8.0 packaged py2exe the news is, omp warning message not negatively affecting code. however, either resolve issue causing warning message, or suppress warning messages, since not affect performance of code, might confuse / annoy user. can provide advice? sounds previous posters have tried lot of things already, figured might time fresh look. there part of numpy can modify doesn't make reference omp, since i'm not using (at least, i'm not

javascript - jquery 3 document ready is blocking turbolinks from executing -

i using jquery 1.12.4 far , ok, had : $(document).ready -> console.log "document ready yaay!" start = -> alert "hello world!!!" document.addeventlistener('turbolinks:load', start) i upgraded rails 5.1 yesterday , decided add , upgrade jquery (yep still need it) installed jquery 3 using yarn, same code above doesn't executed, @ least turbolinks part (the console.log executed every time document loaded "start" method not) i removed $(document).ready -> , code start working expected !!! to make sure removed jquery 3 , installed jquery 1.12 , worked! $(document).ready -> why happening ? make sure add //= require jquery application.js file. in command line, run yarn install jquery lower case here application.js file 1 of project using jquery through yarn. //= require rails-ujs //= require turbolinks //= require jquery //= require_tree . edit: if want console.log , alert fire @

api - Ajax call returns undefined -

i trying make api call , following errors ajax not being function: import $ 'jquery'; const apicall = function () { var url = 'https://images.nasa.gov/#/search-results'; var request = { q: 'sun', media_type: 'image' }; var result = $.ajax({ url: url, datatype: 'json', data: request, type: 'get' }) .done(function() { alert(json.stringify(result)); }) .fail(function() { alert('failed'); }) } module.exports = apicall; i importing above in module , calling on button click in react's render() function like: import apicall './../api/apicall'; class gallery extends react.component { render () { return ( <section id="gallery" classname="g-site-container gallery"> <div classname="grid grid--full"> <div classname="gallery__intro"> <button extraclass="&quo

Configuring remote access with ssh - Flink -

i'm following guide configure flink cluster: flink cluster setup see "configuring remote access ssh" section. when scp .ssh/authorized_keys <worker>:~/.ssh/ substituting < worker > ip of other nodes of cluster. unfortunately obtain following output: ssh_exchange_identification: read: connection reset peer lost connection some knows problem?

netbeans - Why is padding not appearing for this css class? -

i learning use netbeans , gulp develop in wordpress, following great tutorial @ lynda.com. have sass set compile partial .scss files style.css file project, compiles fine. however, when attempt add padding around specific class, css not take effect. can see code added in style.css file here: site-content { padding: 2em; } and included in style sheet page; when webpage rendered, no padding appears (as in tutorial). i thought maybe other css overriding padding, , found this: <link rel='stylesheet' id='casse_dev-style-css' href='//192.168.0.26:8080/wp-content/themes/casse_dev/style.css?ver=4.8' type='text/css' media='all' /> <link rel='https://api.w.org/' href='//192.168.0.26:8080/wp-json/' /> <link rel="edituri" type="application/rsd+xml" title="rsd" href="//192.168.0.26:8080/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlw

tensorflow - keras combining two losses with adjustable weights -

Image
so here detail description. have keras functional model 2 layers outputs x1 , x2. x1 = dense(1,activation='relu')(prev_inp1) x2 = dense(2,activation='relu')(prev_inp2) i need use these x1 , x2, merge/add them , come weighted loss function in attached image. propagate 'same loss' both branches. alpha flexible vary iterations it seems propagating "same loss" both branches not take effect, unless alpha dependent on both branches. if alpha not variable depending on both branches, part of loss constant 1 branch. so, in case, compile model 2 losses separate , add weights compile method: model.compile(optmizer='someoptimizer',loss=[loss1,loss2],loss_weights=[alpha,1-alpha]) compile again when need alpha change. but if indeed alpha dependent on both branches, need concatenate results , calculate alpha's value: singleout = concatenate()([x1,x2]) and custom loss function: def weightedloss(ytrue,ypred): x1true =

javascript - Java/Spring : Form validation to avoid URLs as input -

we have form user enters firstname, lastname , address. users entering firstname/lastname website. ex: www.google.com, google.com or other spam site. is there way validate these kind of inputs? note : don't want replace or avoid special characters causing issues when people enter name in different language other english. those "some users" hackers penetration testing web site. use regular expression filter out fake names match pattern. name start http:// or www. ? name end in .com or .net ? if so, don't allow users enter name. if google "regular expression url matching", should plenty of examples of regular expressions match url strings. need validation not allow names match url regex, , conversely, allow names don't match.

javascript - CKEditor, mathematics and content filter -

i have configured ckeditor remove margin, color , font styles. here's ckeditor config : ckeditor.editorconfig = function( config ) { // add wiris plugin list config.extraplugins += (config.extraplugins.length == 0 ? '' : ',') + 'ckeditor_wiris'; // allow elements config.allowedcontent = { $1: { // use ability specify elements object. elements: ckeditor.dtd, attributes: true, styles: true, classes: true } }; // disallow font, margin, color styles , span elements config.disallowedcontent = '*{font*}; *{margin*}; *{color*}; span;'; }; i'm using wiris plugin create math equations. when create math equation plugin, can see equation in ckeditor , when save it, it's saved intended. when want edit, equation no longer math equation simple text. think config removing math elements keeping text. don't know what's wrong config since

reactjs - Custom content of React Bootstrap Modal -

i'm trying customize react bootstrap modal such customized piece of html+css replace default content of modal. in other words, want keep bootstrap effects replace white background , content of modal own custom html , css. html , css want use put in react component. have tried dialogcomponentclass, dialogclassname etc etc, cannot understand docs how this. want replace content of bootstrap modal component "custompopup". how? here 2 components: import react 'react'; import './../styles/popup.css'; import {modal, button} 'react-bootstrap'; class custompopup extends react.component{ constructor(props) { super(props); this.state = { text: props.text }; } render() { return ( <div classname="modalcontainer"> <div classname="container"> <div classname="outerframe"> <div classname="innerframe"> <label cl

python - Pandas sorting MultiIndex after concatenate -

when create multi-indexed table in 1 shot, sortlevel() works expected. however, if concatenate multiple tables create same multi-indexed table, cannot sortlevel() anymore. full example below: import pandas pd a=pd.dataframe({'country':'zimbabwe','name':'fred'}, index=[1]) b=pd.dataframe({'country':'albania','name':'jeff'}, index=[0]) not_working = pd.concat([a,b],keys=['second','first']) working = pd.dataframe({'country':['zimbabwe','albania'],'name':['fred','jeff']}, index=pd.multiindex.from_tuples([('second',1),('first',0)])) not_working_sorted = not_working.sortlevel(0) working_sorted = working.sortlevel(0) i expect both of these produce: country name first 0 albania jeff second 1 zimbabwe fred however, "working". knows doing wrong ? using pandas 0.19.2 try ? working.sort_index() out[702]:

android - Spinner won't show item selected through data in firebase -

when fetch data firebase can show list through spinner when item selected doesn't show anything, list, works if hardcode list string values. , onitemselectedlistener doesn't work, can please me? here's how fetch data. private arraylist <string> fetchdata (string league){ final arraylist<string> teamname = new arraylist<>(); /* return arraylist of type string of teams in league*/ databasereference databasereference = firebasedatabase.getinstance() .getreference() .child("standings").child(league); query query = databasereference.orderbychild("name"); query.addlistenerforsinglevalueevent(new valueeventlistener() { @override public void ondatachange(datasnapshot datasnapshot) { for(datasnapshot mdatasnapshot: datasnapshot.getchildren()){ string name = (string) mdatasnapshot.child("name").

regression - How to perform a 70/30 holdout in R -

Image
i'm trying make prediction based on below linear regression model: i want predict intercept (market share) based on formula given value each of response variables. formula these results , can plug numbers in each variable? or need holdout/training sets first? edit: added text of results. summary(fit2) call: lm(formula = headache_panel_cleaned$private_label_cleaned ~ income_cleaned + age_cleaned + education_cleaned, data = headache_panel_cleaned) residuals: min 1q median 3q max -53.880 -33.804 -5.473 32.589 68.171 coefficients: estimate std. error t value pr(>|t|) (intercept) 52.02867 0.96849 53.721 <2e-16 *** income_cleaned -0.22711 0.01199 -18.949 <2e-16 *** age_cleaned -0.11363 0.01334 -8.516 <2e-16 *** education_cleaned 0.13104 0.01213 10.807 <2e-16 *** --- signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 residual standard error: 35.09 on 3811

html - Align elements in a fieldset -

i'm trying align combination of labels , inputs. using fieldset > table > tr > td structure. i've read online typically poor practice, however, i'm having difficult time using css accomplish need. here sample: td.right { text-align: right; } fieldset { display: block; margin-left: 2px; margin-right: 2px; padding-top: 0.35em; padding-bottom: 0.625em; padding-left: 0.75em; padding-right: 0.75em; border: 2px groove; } <fieldset> <table> <tr> <td class="right">date of call:</td> <td><input class="datepicker2" name="calldate"></td> <td class="right">caller code number:</td> <td><input class="codemaker" name="callercodenum"></td> <td class="right">what jurisdiction?</td> <td><input type="text" name=&

Is it needed to add reCaptcha to built in Django's login form? -

hello i'm new django , i'm using django's built in forms login users, have contact form i'm using google recaptcha avoid attacks. i wondering if needed add recaptcha login form. have heard django takes care of security , don't want repeat code if default login form prepared brute force attacks. in case better add recaptcha default login form how can process validation? in contact form call google's api verify user click within views, don't feel comfortable adding code inside auth_views.loginview class. thanks! django not take care of rate-limiting forms, including login. i think idea include sort of rate-limiting security measure login form. re-captcha might overkill default, unless there several incorrect attempts within timeframe. take @ django rate-limit project easy implement alternative captcha. in order add recaptcha login view, rather modifying auth_views.loginview class, create new view extends class. can add recaptcha form

php - extracting link from a string containing html and javascript -

i have string contains following: <img data-bind="defaultsrc: {srcdesktop: 'http://desktoplink', srcmobile: 'http://mobilelink', fallback: 'http://baseurl'}" > i trying extract srcdesktop contained inside string. want final result yield me link http://desktoplink . best way achieve other str_replace ? have dataset contains strings looking formula extract in php. here how have been doing it, there got more efficient way: $string = '<img data-bind="defaultsrc: {srcdesktop: \'http://desktoplink\', srcmobile: \'http://mobilelink\', fallback: \'http://baseurl\'}" >'; $test = explode(" ",$string); echo "<br>".str_replace(",","",str_replace("'","",$test['3'])); you can use preg_match $string = '<img data-bind="defaultsrc: {srcdesktop: \'http://desktoplink\', srcmobile: \'http://mobi

How to Intercept Windows Service Traffic from Fiddler? -

i have tried mentioned in links below, none of them showing me traffic flowing through fiddler windows service. windows service running in remote desktop machine , editing machine.config file mentioned in links below nothing's happening. there more configurations required? how use fiddler monitor windows service? capturing traffic .net services fiddler

reactjs - React 16 upgrade fatal errors ag-grid? -

has upgraded ag-grid installation react 16 aka fiber? upgraded react@next , react-dom@next, , instantly got fatal error. tool closely based on ag-grid-react-example, , problem seems cell editors. seen similar? we aware of in ag-grid , plan fix (hopefully coming days), react fiber changes how things done underneath hood, , pattern use allow react components needs tweaked.

c# - UWP Toast Notification debugging in Visual Studio - no toast displaying, "Returned with error code 0x0" -

i have background task supposed open toast message, à la: toastnotificationmanager.createtoastnotifier().show(toast); . code executes fine, no errors thrown, nothing hangs -- also, no toast message appears. i checked event viewer logs, , this: an instance of background task entry point bg.toastbackgroundtask running user [me] in session [sesh] returned error code 0x0. i have looked on see error code might mean found nothing. here's code: public sealed class toastbackgroundtask : ibackgroundtask { private backgroundtaskdeferral _deferral; public async void run(ibackgroundtaskinstance taskinstance) { var canceltoken = new system.threading.cancellationtokensource(); taskinstance.canceled += (s, e) => { canceltoken.cancel(); canceltoken.dispose(); }; taskinstance.task.completed += task_completed; _deferral = taskinstance.getdeferral(); try {

should I write header to all my html page? -

i'm new web design. wonder should have write header every page on website? example have index.html, contact.html, about.html. should copy header page ? yes, each page must contain header. because they're separated. to honest, these kind of questions (like yours) shouldn't asked here. should try read html books started.

ionic2 - Jasmine - how to unit test a TypeScript class that imports another class with static methods -

i have simple typescript class (in ionic application), implements simple "typed" dictionary... import { utils } './utils'; export class dictionary<t> { constructor(private nocase?: boolean, init?: array<{ key: string; value:t; }>) { .... } } i have written simple tests it... import { dictionary } './dictionary'; let dictionary : dictionary<string> = null; describe('dictionary', () => { beforeeach(() => { dictionary = new dictionary<string>(true, []); }); it('should have containskey find value added', () => { dictionary.add("a", "a val"); let exists = dictionary.containskey("a"); expect(exists).tobetruthy() }); }); when run test, following error... chrome 60.0.3112 (windows 10 0.0.0) error uncaught typeerror: __webpack_imported_module_3__dictionary__.a n

php - laravel default image not working -

i new laravel , im facing problem: i have code in registercontroller: protected function create(array $data) { $pic_path=""; if($data['gender'] =='male'){ $pic_path = 'http://localhost:8000/img/profile-default-male.png'; }else if($data['gender'] =='female'){ $pic_path='http://localhost:8000/img/default_women.jpg'; } return user::create([ 'name' => $data['name'], 'pic' => $pic_path, 'gender' => $data['gender'], 'slug' => str_slug($data['name'],'-'), 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); } but in register.blade.php: have this <img src="{{asset('/img/default_women.jpg')}}" width="80px" height="80px"> i know have put this: auth::user()

recursion - monitor tree with systemd path unit and pass parameter to service -

with systemd path units, possible monitor, not single directory or file, recursively monitor sub directories within directory without explicitly listing each one? tried wild cards didn't work though docs make mention of wildcard expansion. i'm finding .path units of extremely limited value. mysolution.path [unit] description="file monitor path unit" [path] directorynotempty=/var/opt/mysolution #directorynotempty=/var/opt/mysolution/* #pathchanged=/var/opt/mysolution/*/* #pathchanged=/var/opt/mysolution/subdir [install] wantedby=multi-user.target the commented out lines ones did not work @ all mysolution.service [unit] description="file monitor service unit" [service] type=oneshot execstart=/bin/chmod -fr ug+rw /var/opt/mysolution/subdir #execstart=/bin/chmod -fr ug+rw /var/opt/mysolution/* # don't want change permissions on mysolution, files , dirs under directory [install] wantedby=multi-user.target is possible this? don't want h

c++ - Export Public Key parameters from Crypto++ ELGamalKeys -

i using cryptopp , trying export steps of each encryption/decryption can learn how elgamal works. i have been trying learn elgamal encryption way of site: https://cryptographyacademy.com/elgamal/ i able find subgrouporder, subgroupgenerator, , modulus of elgamalkeys::publickey, unable find 3rd parameter of publickey computed using alice's private exponent. according site: next alice chooses secret key sk=a between 1 , p−1 , computes a=g^a mod p alice publish public key pk=(p,g,a). how access parameter publickey explicitly?

Concourse pool-resource lock pipeline -

i trying concourse pool resource, have followed online documentation ( https://github.com/concourse/pool-resource/ ) in concourse/pool-resource git hub repo. my confiugration below: resources: - name: locks type: pool source: uri: https://<git-path>/<repo>.git branch: locks username: {{github-username}} password: {{github-password}} pool: locks jobs: - name: job1 serial: true plan: - aggregate: - get: locks - put: locks params: {claim: pipeline} - name: job2 serial: true plan: - aggregate: - get: locks - put: locks params: {claim: pipeline} - name: release serial: true plan: - aggregate: - get: locks - put: locks params: {release: locks} when on locks in either job1 or job2, see in jobs , claim of lock runs long time, doesn't show me anything: sh: locks/unclaimed/.gitkeep: unknown operand i not sure doing wrong, hijacked concourse worker , tried checking /var/logs, see fine in pool

IO in python 3 not writing/reading -

this question has answer here: possible call single-parameter python function without using parentheses? 4 answers python write file returns empty file 2 answers i copying example book piece of code write , read file has been created (using utf-8). thing code have doesn't print when run it: #encoding = utf-8 import io f = io.open("abc.txt", "wt", encoding = "utf-8") texto = u"writing díférént chars" f.write(texto) f.close text = io.open("abc.txt", encoding = "utf-8").read() print(text) you missing parens in call close : f.close() adding prints me in both python2 , python3. writing buffered io (the default using io.open ) may causes writes deferred -- when writing small amounts of data (less d

Python numpy equivalent of R rep and rep_len functions -

i'd find python (numpy possible)-equivalent of r rep , rep_len functions. question 1 : regarding rep_len function, run, rep_len(paste('q',1:4,sep=""), length.out = 7) then elements of vector ['q1','q2','q3','q4'] recycled fill 7 spaces , you'll output [1] "q1" "q2" "q3" "q4" "q1" "q2" "q3" how do recycle elements of list or 1-d numpy array fit predetermined length? i've seen numpy's repeat function lets specify number of reps, doesn't repeat values fill predetermined length. question 2: regarding rep function, run, rep(2000:2004, each = 3, length.out = 14) then output [1] 2000 2000 2000 2001 2001 2001 2002 2002 2002 2003 2003 2003 2004 2004 how make (recycling elements of list or numpy array fit predetermined length , list each element consecutively predetermined number of times) happen using python? i apologize if

Using For Loop in Javascript? -

also need loop add more names when put number 2 instead of 1. having issues code appreciated. know simple loop coding, stumped. html <p>enter first name: <input type="text" id="firstname"> <span id="firstname_error"></span> </p> <p>enter last name: <input type="text" id="lastname"> <span id="lastname_error"></span> </p> <p>how many pets have? (0-3): <input type="text" id="numpets" size="1" maxlength="1"> <span id="numpets_error"></span> </p> <p>list pet's names: <input type="text" id="pet1"> <input type="text" id="pet2"> <input type="text" id="pet3"> </p> <p><input id="mybutton" type="button" value="submit information"></p&g

python - Using numpy.nditer in Hy -

in python, following code iterates numpy array (the loop), , values of numpy array changed: import numpy a08_1 = numpy.arange(8).astype(numpy.uint8) # a08_1: array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint8) x in numpy.nditer(a08_1, op_flags=['readwrite']): x[...] = 255 if x == 1 else 0 # # a08_1: array([ 0, 255, 0, 0, 0, 0, 0, 0], dtype=uint8) is possible in hy? can create iterator (numpy.nditer a08_1) not know how follow. thanks. equivalent hy looks this. (import numpy) (setv a08-1 (-> (numpy.arange 8) (.astype numpy.uint8))) (for [x (numpy.nditer a08-1 :op-flags ["readwrite"])] (assoc x ellipsis (if (= x 1) 255 0)))

python - Should Shebang lines be used in all the programs that would run through Terminal? -

my book states that: the first line of python programs should shebang line, tells computer want python execute program. shebang line osx #! /usr/bin/env python3. but program works fine without shebang line in terminal. should use in future? there fullstop(.) @ end of shebang line in osx or not? there should not full stop @ end of line. whether add shebang or not depends on how want run it. if invoke interpreter explicitly optional, i.e. $ python3 script.py does not require shebang, nor require executable permission on file. can add shebang, , code still run, in case might serve documentation. however, if want execute this: $ ./script.py or $ /path/to/script/script.py then need add shebang and set executable permission on file (see chmod ).

java - set length is not working in hibernate when table is already created -

employeedesc column on employeedetails table has default length of varchar(255). want altered. have tried giving customised length on persistent class. @entity public class employeedetails { @id private int employeeid; private string employeename; private int employeeage; @column (length = 500) private string employeedesc; // getters , setters } and hibernate configuration. <property name="hbm2ddl.auto">update</property> if tried give value more 255 field employeedesc, getting error saying caused by: com.mysql.jdbc.mysqldatatruncation: data truncation: data long column 'employeedesc' @ row 1 is there better way alter employeedesc's length without changing "hbm2ddl.auto">update property? hibernate doesn't update column length during updating/validation. can try use liquibase . not sure able use hibernate update liquibase .

r - How to easily create sequentially named vectors from the same data -

i trying generate 100 samples sets population. code currently sam1<-sample(population, 30, replace = t) sam2<-sample(population, 30, replace = t) sam3<-sample(population, 30, replace = t) since sampling repeatedly same data, there easier way create 100 vectors sequentially sam1...sam100 vectors? try replicate function population vector or list replicate(n = 100,sample(population, 30, replace = t))

Eliminate the values in the rows corresponding to a column which are zero in MATLAB -

Image
i have matrix of data trying analyse. have data , applied processing part , managed information below level in trying apply threshold it. after applied threshold data goes 0 point. wondering if there way eliminate points without leaving 0 in between. figure looks zeros in trying plot without gap x axis time, y axis amplitude. possible plot events in blue , time together? %find time n = size(prcdata(:,1),1); t=t*(0:n-1)'; figure; plot(t,u); t1=t(1:length(t)/5); x=(length(prcdata(:,4))/5); = u(1 : x); threshold=3.063; a=a>threshold; plot_vals=a.*a; figure; plot(t2,plot_vals1); %gives plot added i tried code club events without zeros gives me straight line plot @ 0. %% eliminate rows , colomns 0 b1=plot_vals1(plot_vals1 <= 0, :); figure; plot(b1); also there way take scatter of figure above? using scatter(t2,plot_vals1); work? if want display points above threshold, can use logical index , set value of unwanted points nan : threshold = 3

Python - multiplication between a variable that belong to the same class -

how set class variable return other data type (list or int)? so have 2 variable belong same class , want use operator example multiplication both of variables, cannot done because both of them have class data type. for example: class multip: def __init__(self,x,y): self.x = x self.y = y def __repr__(self): return "{} x {}".format(self.x, self.y) def __str__(self): return "{}".format(self.x*self.y) def __mul__(self, other): thisclass = self.x*self.y otherclass = other return thisclass * otherclass = multip(5,6) b = multip(7,5) c = a*b print(c) this return error: typeerror traceback (most recent call last) in () 14 = multip(5,6) 15 b = multip(7,5) ---> 16 c = a*b 17 print(c) in mul (self, other) 10 thisclass = self.x*self.y 11 otherclass = other ---> 12 return thisclass *

bash script to clone/pull bulk git repo -

i've several(22) private repositories on gitlab https protocol , want checkout repositories providing username , password once bash script. can't seem make work. here's how far got: (any edit/optimization appreciated): #!/bin/bash read -p "gitlab username: " user read -sp "gitlab password: " pass echo read -p "branch checkout: " branch echo repo[0]='.' #dir repo[1]='repo.myhost.com/project/app.git' #repo url repo[2]='plugins' repo[3]='repo.myhost.com/project/app-core.git' repo[4]='plugins' repo[5]='repo.myhost.com/project/plugin1.git' repo[6]='plugins' repo[7]='repo.myhost.com/project/plugin2.git' repo[8]='api-plugins' repo[9]='repo.myhost.com/project/api-plugin1.git' repo[10]='api-plugins' repo[11]='repo.myhost.com/project/api-plugin2.git' # add more repo total=${#repo[*]} echo "checking out repositories..." mkdir -p plugi

avfoundation - avassetwriterinput readyformoredata is NO when audio sample buffer size is changing -

i got readyformoredata no if audio sample buffer data size changing. if set sample buffer size changeless value, readyformoredata becomes yes again. does know why? and here audio recoding settings: nsdictionary *recordsettings = [nsdictionary dictionarywithobjectsandkeys: [nsnumber numberwithint: kaudioformatmpeg4aac], avformatidkey, [nsnumber numberwithfloat:44100.0], avsampleratekey, [nsnumber numberwithint: 2], avnumberofchannelskey, nil]; another possible clue if set avnumberofchannelskey 1, readyformoredata yes, appendbuffer return failed. any suggestions appreciated~ thank you~

algorithm - How do I take a python Dictionary or List of size X and assign each element with Y random index values of the dictionary itself -

i'm not sure if best use list or dictionary algorithm. assuming use dictionary, want create dictionary of size x , randomly assign each element y index values of dictionary itself. meaning take dictionary of size 5, , assign each of 5 elements 2 index values ranging between 1-5. the constraints index value can not assigned own index, 2nd index can assigned values 1,3,4,5; , y must less x, in order prevent assigning duplicate index values same index. what have far being done list rather dictionary, i'm not sure if best method. i'd keep algorithm running @ 0(n) speed well, if size of list/dictionary huge. either way, i'm at. so, make x list of size 5. set y equal 3, meaning want each of 5 elements contain 3 index values. in for-loop create list excluding index value i'm assigning values to. x = range(5)[::1] # [0, 1, 2, 3, 4] print(x) y = 3 assigned = [] k in range(0, len(x)): xexcluded = [x i,x in enumerate(x) if i!=k] # if k==3 [0, 1, 2,

codeigniter - A PHP Error was encountered Severity: Notice Message: Undefined variable: data Filename: profile/viewabout.php Line Number: 79 -

this question has answer here: php: “notice: undefined variable”, “notice: undefined index”, , “notice: undefined offset” 23 answers controller: i'm trying fetch records database, showing undefined variable $data in view section. problem don't understand. public function vabout(){ if(!$this->session->userdata('logged_in')){ redirect('register/login'); } $this->load->model('profile_model'); $data = $this->profile_model->viewprofile(); $this->load->view('templates/pheader'); $this->load->view('profile/viewabout',$data); $this->load->view('templates/pfooter'); } model: model section, there issue in model fetching record? public function viewprofile(){ $data = $this->db->get('profile'); return $data->row_arra

angular - router-outlet inside router-outlet calling independent routes dynamically -

Image
i have angular 2 project has many modules in it. load each of module using lazy loading technique follows { path: 'home', loadchildren: './dashboard/dashboard.module#dashboardmodule' }, now have situation load module called workflowmanagementmodule using { path: 'workflow', loadchildren: './workflow-management/workflow-management.module#workflowmanagementmodule' }, in workflow module have component called workflow-footer footer button label next. when click next rest call made server , field "url" received server. on receiving have navigate url. now problem is i have have footer component footer of loaded routes. i.e. new component (based on route received server) component has loaded , should have footer workflow-footer component.as shown below this situation below in code <div>some other content</div> <router-outlet></router-outlet> <work-footer></work-footer> but can't under

crc - Calculate CRC16 X25 in php -

i need in calculating crc x25 variation, have java tool , online tool give correct conversion, haven't been able reproduce myself. online tool github online tool string: 40402900033231334c323031373030313839360000000000009001ffffffff0000d656b759 input type: hex -> calc crc16 result: crc-16/x-25 0x6c49 <-- value im trying in php string above. my php code far private static $crc16_table = array (0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0

Magento API list qty_increments by product -

magento api has 2 calls stock: cataloginventorystockitemlist , cataloginventorystockitemupdate uses array cataloginventorystockitemupdateentity min_qty field can updated. need find current value of field productid before can update it. i can use standard api. (no php/sql query.)

php - How to send well show activation mail layout with mail -

in code want looking layout show user. in activation mail show <a href="link">link</a> .i didn't want want simple show link not show <a href=""> tag in email please me how that. thanks $actual_link = "http://mywebsite.com"."/activate.php?id=" . $current_id; $subject = "user registration activation email"; $content = "click link activate account. <a href='" . $actual_link . "'>" . $actual_link . "</a>"; $from="verification@mywebsite.com"; while (list($key,$val)=each($_post)) { $pstr = $pstr."$key : $val \n "; ++$pcount; } while (list($key,$val)=each($_get)) { $gstr = $gstr."$key : $val \n "; ++$gcount; } if ($pcount > $gcount) { $message_body=$content; mail($toemail, $subject,$message_body,"from:".$from);

java - how to send data to com port in android using uart wired connection? -

i can send data ttys1 using terminel of android. how can using code in application? had tried libraries not working me. can suggest solution? code using rxtxcomm.jar, showing error *'couldn't find "librxtxserial.so"'. * can provide solution? in advance.. public void open() { enumeration port_list = commportidentifier.getportidentifiers(); while (port_list.hasmoreelements()) { // list of ports commportidentifier port_id = (commportidentifier) port_list.nextelement(); if (port_id.getname().equals("/dev/ttys1")) { // attempt open try { serialport port = (serialport) port_id.open("portlistopen", 20); system.out.println("opened successfully"); try { int baudrate = 115200; // port.setserialportparams(baudrate, serialport.databits_7, serialport.stopbits_1, serialport.parity_even);

javascript - how to make onclick event when clicking the date from datepicker UI -

hi guys have try make select data function jquery onclick event have triggering date datepicker. have try make code seems not work @ all. this textboxt id's contain datepicker call function. $(#date) have try make code selecting data. code. $(document).on('click','#date',function(e) { var data = $("#form_input10").serialize(); $('#table_s tbody').empty(); $.ajax({ data: data, type: "post", url: "../php/termocouple/get_date.php", success: function(data){ var list = json.parse(data); for(var = 0; < list.length; i++){ $('#date1').val((list[i]['tanggal2'])); } } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script> the condition when datepicker running this. when textbox clicked datepicker showing. nah when use code, condition 1st click show datep

php - Yii2 form field stays blank even when filled -

i have update form works expected 1 exception - review textarea doesn't wan't pass through validation rules. when fill , try update form review field empty (or sort of this). can see var_dump($model->geterrors()) in controller. $_post['author']['review'] got value gave can't save in $model->review column. using ckeditor . tried without without success. here controller: public function actionupdate($id) { $model = $this->findmodel($id, true); $settings = new settings(); if ($model->load(yii::$app->request->post())) { var_dump($model->save()); var_dump($model->geterrors());die; $languages = lang::find()->all(); foreach ($languages $language) { if ($language->default != 1) { $names = 'names_' . $language->url; $varnames = yii::$app->outdata->sanitize($model->$names);

java - Access dataBase using Apache-Spark-SQL -

hi i'm new learner apache spark using java this correct way or not? code working,but performance wise slow don't know 1 best approach access data every loop. dataset<row> javardd = sparksession.read().jdbc(database_url, "sample", properties); javardd.todf().registertemptable("sample"); dataset<row> users = sparksession.sql("select distinct from_user sample "); list<row> members = users.collectaslist(); (row row : members) { dataset<row> userconversation = sparksession.sql("select description sample from_user ='"+ row.getdecimal(0) +"'"); userconversation.show(); } try create set users , execute query sparksession.sql("select description sample from_user in usersset); this way execute 1 query pay overhead needed db connection once. another approach if run spark on hdfs , 1 time query use tool sqoop load sql table in hadoop , use data natively in spark.

amazon web services - Is it mandatory to explicitly mention region name while creating AmazonS3Client to access a file from a bucket in china region? -

i want access public file s3 bucket in china region. mandatory mention region while creating amazons3client china region? i think know because bucket name global, there no need explicitly mention region while creating s3client.

listview - Search Bar for an ExpandableListView -

in code use custom expandablelistviewadapter use baseexpandablelistadapter. trying filter parent groups when searches specific word in search bar. trying use itextwatcher however, when use .filter expandablelistviewadapter madapter code wont build. can't use invokefilter(s) filter out parents. can please help? thank in advance! again trying filter through parents; not children. main: using android.app; using android.widget; using android.os; using system.net; using java.lang; using system; using newtonsoft.json.linq; using system.linq; using java.util; using system.threading; using org.json; using android.content; using android.views; using system.collections.generic; using system.text; using restsharp.extensions.monohttp; using android.text; namespace dictionarye { [activity(label = "dictionarye", mainlauncher = true, icon = "@drawable/logo")] public class mainactivity : activity { private expandablelistview list; private expandablelistview