Posts

Showing posts from April, 2011

javascript - Multiple file upload and zip them on the fly failed -

i have created multiple file uploader using html & php. uploader functionality works fine while try create zip on fly in order add uploaded file zip file. in case, failed create zip , add uploaded file zip. don't know why it's not working. please check scripts below , let me know if missed in advance: html scripts: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>file upload progress bar</title> <script type="text/javascript"> // select file function styling input[type="file"] function select_file(){ document.getelementbyid('image').click(); return false; } </script> </head> <body> <div class="container"> <!--status message appear here--> <div class="status"></div> <!--image upload form--> <form class="pure-form" action="upload.php" enctype="multipart/f

swift - How to apply audio effect to a file and write to filesystem - iOS -

i'm building app should allow user apply audio filters recorded audio, such reverb, boost. i unable find viable source of information on how apply filters file itself, because it's needed upload processed file server later. i'm using audiokit visualization, , i'm aware it's capable of doing audio processing, playback. please give suggestions further research. you can use newly-introduced "manual rendering" features audio unit plugins (see example below). if need support older macos/ios version, surprised if can't achieve same audiokit (even though haven't tried myself). instance, using aksampleplayer first node (which read audio file), building , connecting effects , using aknoderecorder last node. example of manual rendering using new audio unit features import avfoundation //: ## source file //: open audio file process let sourcefile: avaudiofile let format: avaudioformat { let sourcefileurl = bundle.main.url(forres

wifi - Reading debug messages without USB serial connection on ESP8266 Arduino -

i have setup nodemcu work ota (over air) updates in arduino ide. great no longer need plugged in via usb upload new sketches. however, cannot read of debugging information on serial. how see debugging information without usb cable? wiki

c# - Regex for numbers after a certain string part -

i'm trying extract numbers inside url regex. example input: http://localhost:23089/generic-url-segment-c?p=5 expected output : 5 example input: http://localhost:23089/generic-url-segment-c?p=12&sort=5 expected output: 12 first tried numbers mixture of string.replace , string.indexof , substring thought regex easier. so far tried using ((p=)?=.) can't 5 only. and shown in second example, value might 2 digit value or there might other parameters after it. maybe search between p= , & necessary don't know how regex behaves in absence of parameters. try below pattern. plus matches 1 or more can 1 or more digits - p=(\d+) the brackets group value of match within group use match.groups[0].value wiki

scala - Importing generic implicits from class instances -

i'm trying make generic implicit provider can create implicit value given type, in lines of: trait evidence[t] class implicitprovider[t] { class implementation extends evidence[t] implicit val evidence: evidence[t] = new implementation } to use implicit, create val provider = new implicitprovider[t] instance necessary , import import provider._ . works fine long there 1 instance. implicits several types needed in 1 place case class a() case class b() class test extends app { val aprovider = new implicitprovider[a] val bprovider = new implicitprovider[b] import aprovider._ import bprovider._ val = implicitly[evidence[a]] val b = implicitly[evidence[b]] } and fails compile could not find implicit value parameter , not enough arguments method implicitly errors. if use implicit vals providers directly, starts work again. implicit val aevidence = aprovider.evidence implicit val bevidence = bprovider.evidence however i'm trying avoid importing

Xamarin android: How to create slider between layouts -

i need create slider not images need layouts below image when click layout1 slide left , active or if click layout3 slide right , active , other layouts behind it. image create layout slider wiki

haskell - When does GHCI not deduce the required context? -

why ghci add constraint required context here: > let f = fmap show > :t f f :: (functor f, show a) => f -> f string but not here? > :t on over :: lens s t b -> (a -> b) -> s -> t > :t _all' _all' :: (applicative f, eq a) => -> (a -> f a) -> [a] -> f [a] > :t on (_all' 2) <interactive>:1:7: error: • not deduce (applicative f) arising use of ‘_all'’ is there major difference between these 2 cases? note isn't type of over defined lens library. being said, version doesn't work because lens is type lens = forall f. functor f => (a -> f b) -> s -> f t and _all' 2 :: forall f. applicative f => .. in other words, over demanding function works functor , you've provided 1 works applicative (which stronger constraint, in functor doesn't imply applicative ). comment @user2407038. as alluded in comment, can fix problem fixing type signatu

java - How to Register Custom Converters in Spring 3? -

i have 2 custom converters implement twowayconverter , propertyeditor . try use them following exception : caused by: org.springframework.binding.convert.conversionexecutornotfoundexception: no custom conversionexecutor found id 'customconverter1' converting sourceclass [java.lang.string] targetclass [java.util.arraylist] my configuration file looks : .... <!-- creates xmlflowregistryfactory bean --> <flow:flow-registry id="flowregistry" flow-builder-services="flowbuilderservices"> <flow:flow-location-pattern value="classpath:/com/example/web/flow/**/*.xml"/> </flow:flow-registry> <bean id="conversionservice" class="com.example.web.converter.myconvertionservice"/> <alias name="conversionservice" alias="integrationconversionservice"/> <flow:flow-builder-services id="flowbuilderservices" view-factory-creator="viewfactoryc

ajax - MVC return PartialView slow first time after edit -

Image
i imagine answer cache related, better understand reason thought i'd @ least ask. in mvc project i'm doing ajax request controller return html page partial view, inject html page with. reason model view changes depending on what's clicked. here ajax: (please note code has been modified simplicity) $.ajax({ type: 'get', url: "../../home/newmembershipalloc/", contenttype: 'application/json', datatype: 'html', success: function (data) { $('#partial_div').html(data); } }); here controller method: public async task<actionresult> newmembershipalloc() { return partialview("~/views/popup/genericpopup.cshtml", new membership()); } now, clear, works intended. everytime run code takes maybe 20ms, shown below: however , if edit html page in way, if remove 1 character , add in. next time perform request take 2 seconds (ish). so happening within development environment sho

How to display fields in a row - Drupal - Views - Node view -

i have requirement display feedback fields in table fashion sample layout here the first column label of radio button field , second column value of radio button. third column different field called review , how can achieved using views? have tried views flipped table , doesn't meets requirement wiki

android - How to use Thread.setDefaultUncaughtExceptionHandler? -

Image
my app has multiple tabs , each tab has recyclerview. clicking on recyclerview item, readrecentnewsactivity opens up. have set shared view transition on onclick . the problem arising on onclick itself, while of time readrecentnewsactivity launching correctly, on news items it's showing error. i think error due shared transition instead of removing it, want catch exception , open particular news item without shared transition... wiki

linux - Check which script create a file in /tmp -

i got malware or hack in debian. see process in top took 300% of processor load. how can check script or user creating file on , on again, can kill process in next 30 min process renew. this process is: /tmp/phpmne0ib_jhikt717dscrcw6b -c 2 -m stratum+tcp://4ae9fi43498hg 938hg....3o4ijf3ioei0:x@monerohash.com:3333/xmr and user of process apache (www-data). there no sure or easy way find causing this. worse still, if find keeps running script, , rid of immediate problem, still can't sure 1) "hole" got in through has been plugged , 2) haven't installed rootkit or backdoor can in @ later date. the best advice is: shutdown compromised system snapshot / preserve file system. use known secure system forensically examine compromised file system. should looking evidence identify vulnerability (or bad security practice!!) lead compromise. once have positively cause of problem: build new version of system known clean base image (e.g. installation d

php - Struggling to sort a muldimensional associative array -

i have spent long time looking through forums, cannot work. i have multidimensional, assoctaive array (in class). declared as: protected $issnlookup = array(); in function, (to populate array data source): foreach($this->keys $k) { $issn = $this->getissn($k); if($issn != '') { // publication has issn if(array_key_exists($issn, $this->issnlookup)) { $this->issnlookup[$issn]['number']++; } else { $additem = array( 'journal' => $this->getjournal($k), 'number' => 1); $this->issnlookup[$issn] = $additem; } // else, key not on $issnlookup } // if $issn != '' } // foreach if display array contents, using: foreach($this->issnlookup $key => $value) { echo $key . ' (' . $value['journal'] . '): ' . $value['number'] . '</br>'; } ... looks good. (this sample): 0924-669x (applied intelligence

android - Codename One - Cross-platform BrowserComponent page loading indicator -

i'm developing app browsercomponent. screen remains "all white" (too much) seconds, because page loading slow: app user can figure out app blocked, it's not so. guess (well done) "page loading indicator" can useful. in developer guide of codename one, it's written so: on android native indicator might show when web page loading. can disabled using display.getinstance().setproperty("webloadinghidden", "true"); call. need invoke once. ok, indicator on android , it's not nice. need better page loading indicator that: it's cross-platform (al least android , ios); it's not obtrusive; it gives user idea of percentuage of loading. for example, @ screenshot: https://scdn.androidcommunity.com/wp-content/uploads/2011/12/screenshot_2011-12-23-18-55-56-303x540.png in screenshot, between address bar , page body, there thin, blue , good-looking progressbar, page loading indicator. how can implement of similar work

How to install Oracle Developer Studio 12.6 in Solaris 11.3 (Intel x86)? -

i have installed solaris 11.3 (intel x86) live dvd in vm. upgraded fresh installation, no updates pending. added oracle developer studio publisher certificates explained here . made sure sunpro-incorporation meta-package up-to-date explained relevant oracle docs . yes, @ version 0.5.11-0.175.3.20.0.2.0 . yes, have installed developer-studio-utilities package. despite these efforts, cannot install developer studio 12.6 (or 12.5, matter). trying "dry run" installation command pkg install -nv developerstudio-126 fails following output: creating plan (running solver): / pkg install: no solution found satisfy constraints maintained incorporations: pkg://solaris/consolidation/sunvts/sunvts-incorporation@7.19.2-0.175.3.0.0.26.3 pkg://solaris/consolidation/x/x-incorporation@0.5.11-0.175.3.1.0.2.1489 pkg://solaris/consolidation/admin/admin-incorporation@0.5.11-0.175.1.0.0.5.0 pkg://solaris/consolidation/cacao/cacao-incorporation@0.5.11-0.175.3.0.0.24.0 pkg://solaris/con

c++ - Does the compiler optimize in this case? -

i using visual studio , creating game engine in c++, it's in 2d. purpose learn modern game engine architecture , component based systems in general. means have performance oriented mindset (even though performance isn't of issue when developing 2d on modern hardware). would compiler optimze this? template<class t> inline t & scene::accesscomponent(unsigned int id) { if (dynamic_cast(t*) < transform > ) { ... } else if (dynamic_cast(t*) < collidable > ) { ... } else if (dynamic_cast(t*) < anothercomponenttype > ) { ... } etc ... } i heard if function enters same logic gate on sequential calls compiler can optimize future calls. work templated functions aswell? compiler optimize if t of same type on sequential calls? i cant profile because code mess, different parts of engine allow accesscomponent call not implemented yet. kind of in planning phase. this code should not done in

json - Inconsistent printing of nested dict using pprint in Python -

i used pprint pretty print large nested dict : import pprint import json open('config.json', 'r') fp: conf = fp.read() pprint.pprint(json.loads(conf)) {u'cust1': {u'videotron': {u'temperature': u'3000k', u'image_file': u'bloup.raw', u'light_intensity': u'20', u'size': [1920, 1080], u'patches': [[94, 19, 247, 77], [227, 77, 293, 232], [77, 217, 230, 279], [30, 66, 93, 211]]}}, u'cust2': {u'rogers': {u'accuracy': true, u'bleed': true, u'patches': [[192, 126, 10,

java - How can I get my Android app with use Branch.io Deeplinking AND support minimize/resume the app? -

i using branch.io deeplinking in android app, , part, works under scenarios. however, have scenario register user (to service); , in flow, user requests sms verification code, , has leave app (minimize) read it, re-enter app (restore) validate code. i had behavior working before implementing branch.io, , reason has branch.io requiring android:launchmode="singletask" in androidmanifest.xml file (see here ). <activity android:name="com.yourapp.splashactivity" android:label="@string/app_name" android:launchmode="singletask" ... when android:launchmode="singletask" removed, user can leave/enter app as want , returned same activity on when minimized app. yet, branch.io deeplinking no longer respected. however , seems minimize/restore behaivor not (?) possible branch.io implemented. it? how can retain minimize/restore functionality of app, implementing branch.io deeplinking? in addition amruta's c

rx java2 - Auto-complete a Single created from another Observable -

i have long-running operation returns value in code don't control. need value published things ask it. purpose using behaviorsubject : var subject: subject<value>? = null fun retrievevalue(): single<value> { if (subject == null) { subject = behaviorsubject.create<value>() someotherthing.retrievevalueasync { value -> subject.onnext(value) } } return subject.singleorerror() } this lets me perform operation once , send result single future interested parties. however, not work. single not emit value until call: subject.oncomplete() but problem because once subject completed future things can no longer subscribe it. what appropriate way cache value observable , pass single? if there way have subject automatically complete once source observable emitted value work. single.cache() looks promising, i'm unsure how handle fact value comes in asynchronously in case. it feels i'm missing silly.

c# - How to read the firstSheet records from excel file -

i doing task, read data excel file using open xml sdk. i can open excel sheet , read data. m struggling in reading first sheet fist time.. code starts reading data final sheet in excel file. for example, excel file(records.xlsx) having 3 sheets(sheet1,sheet2 , sheet3). these 3 sheets having records.!st sheet having 10 records , 2nd sheet having 10 records , 3rd sheet having 10 records. my code,at starting stage read data 3rd sheet records. want read records 1st sheet , go 2nsd , 3rs... that.. this code: list<string> materialdefinitionscolumnnames = new list<string>(); //used save each column values in single row. spreadsheetdocument document = spreadsheetdocument.open(myfile, true); sharedstringtable sharedstringtable = document.workbookpart.sharedstringtablepart.sharedstringtable; string cellvalue = null; foreach (worksheetpart worksheetpart in document.workbookpart.worksheetparts) {

excel - Can't retrieve SharePoint groups and IDs using VBA -

i trying sharepoint groups of given site in excel using vba. not vba expert , litteraly leaning how use developper tool , language try this. i found script retrieves lists , guid sharepoint site on expert-exchange, follows. sub doit2() dim surl string dim senv string dim xmlhtp new msxml2.xmlhttp dim xmldoc new domdocument surl = "https://xxx/_vti_bin/lists.asmx" senv = "<?xml version=""1.0"" encoding=""utf-8""?>" senv = senv & "<soap:envelope xmlns:xsi=""http://www.w3.org/2001/xmlschema-instance"" xmlns:xsd=""http://www.w3.org/2001/xmlschema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" senv = senv & " <soap:body>" senv = senv & " <getlistcollectionresponse xmlns=""http://schemas.microsoft.com/sharepoint/soap/"">" senv = senv & " <getlistc

javascript - After refreshing page not all images are loaded -

im doing fullstack project java spring rest , angular/js giving me serious problems. have main page display 9 random products (games). make http call product info , path image (which saved on server). after getting imagepath make http call image. on backend works fine - both getting game info , getting image. however after refreshing page not images shown - shows 1 out of 9, 5 , none. if dont refresh page , make same call again (by pressing button), images displayed. im pretty sure dont understand asynchronous calls. i'm trying figure out several days no success... page: <div ng-repeat="x in games track $index"> <div class="col-sm-3 col-md-4" style="padding-bottom: 15px"> <div class="thumbnail"> <div class="caption"> <h3>{{ x.gamename }}</h3> <img hei

cookies - Asp.net core 2.0 services.AddCookieAuthentication event OnValidatePrincipal -

recently stumble upon problem seems hard solve. trying mangage new mvc6 core in windows environment. 2.0 preview2 release. problem want subscribe onvalidateprincipal in services.addcookieauthentication( o => { ... o.events = new cookieauthenticationevents { onvalidateprincipal = principalvalidator.validateasync }; }); created class suggested in doc here in same file without namespace like: public static class principalvalidator { public override async task validateasync(cookievalidateprincipalcontext context) { string usersessiontoken = context.principal.claims.firstordefault(x => x.type == claimtypes.name)?.value; if (usersessiontoken == null) { context.rejectprincipal(); await context.httpcontext.authentication.signoutasync(cookieauthenticationdefaults.authenticationscheme); } } } so .. problem when try compile receive 2 errors : relative line onvalidateprincipal = principalvalidator.v

json - Marklogic search inside array or objects and return only matching array items (javascript) -

is possible search across documents search using specific properties inside array elements? furthermore possible results contain matching array elements , not whole document (as other array elements in same document may not match). example: given json marklogic document { "name": "aname", "children": [{ "name": "a", "target": { "min": 2, "max": 10 } },{ "name": "b", "target": { "min": 22, "max": 32 } },{ "name": "c", "target": { "min": 4, "max": 7 } }] } want match children target.min < 5 , target.max > 5. in case children[0] , children[2] match. how specify query return only: [ { "name": "a",

Can a C# named Tuple be used as an MVC page model type? -

in c# 7 can have named tuples: var foo = (name: "joe", age: 42); if pass mvc model using: return view(foo); then syntax should used in cshtml file declare model? although doesn't work, like... @model (string name, int age); as current time can't , need use @model tuple<string, int> //or @model valuetuple<string, int> for difference between 2 options: what's difference between system.valuetuple , system.tuple? you can follow on github: razor throws compilationfailedexception when iterating on named tuple (i know closed dup name more indicative current case) wiki

Python - asynchronous logging -

i need log plenty of data while running system code. logging packages can use have efficient, asynchronous logging? standard python logging package ( https://docs.python.org/2/library/logging.html ) asynchronous default? you can execute logging.info() message using pool of n worker, uing concurrent.futures.threadpoolexecutor , n should equals 1 : import concurrent.futures import logging executor = concurrent.futures.threadpoolexecutor(max_workers=1) def info(self, msg, *args): executor.submit(logging.info, msg, *args) wiki

apache - .htaccess rewrite to php preprocessor causing delay -

all images, css , js requests site need forced through pre-processor php scripts. the following partial rule subset in parent .htaccess works css requests: rewriteengine on rewritebase / ... # if request css file send css preprocessor - block direct access rewriterule ^(.+)\.css$ %{env:ps}%{http_host}/inc/css/css.php?f=$1.css [qsa] ... however, process slowed client's browser being given 302 , 301 prior receiving 200 remapped request. this both time consuming on net (some 50-400ms - worse slow client connections) severely holding page display or causing reflow in case of css requests, and, potential security risk exposing workings of site (existence of pre-processors) i no apache/.htaccess expert - far it, feel there should way force pre-processing totally on server , not exposed client. have looked @ using other flags [f] , [e] , these seem fail causing 400 response. wish avoid use of mod_proxy pretty hosting company blocks that, , have read somewhere using proxy [pt

sql server - different number of rows for a few different fields in one column -

can help? have existing query below(sql server) running , pulls thousands of rows.however, need select specific number of rows few different field values in 1 of column in 'vw_client_uli_member_type' table. , how pit condition? thank you. select ind_int_code 'individual type', ind_first_name 'first name', ind_last_name 'last name', cst_recno 'member id', cst_eml_address_dn 'email address', adr_city 'city', adr_state 'state' , adr_country 'country', cst_org_name_dn 'company', cst_ixo_title_dn 'job title', mem_member_type 'member type' co_individual (nolock) join co_individual_ext (nolock) on ind_cst_key_ext=ind_cst_key join co_customer (nolock) on cst_key=ind_cst_key , ind_delete_flag=0 , ind_deceased_flag=0 left join co_customer_x_address (nolock) on cst_cxa_key=cxa_key left join co_address (nolock) on adr_key=cxa_adr_key left join vw_client_uli_member_type (nolock) on

Nativescript: RadListView, how to switch listViewLayout programatically -

i have common scenario when user can switch list layout between list , grid view tapping icon. before had 2 lists - listview standard list layout , radlistview grid view. hided , showed them depending on required "mode". since radlistview has required layouts theoretically can have 1 list , reuse switching layouts. haven't found how directly in xml (that best approach if any), i'm thinking of doing programatically in code behind. here try: function _switchlistviewlayout() { const list = modal.getviewbyid( 'list' ) let layout if ( list.listviewlayout instanceof listviewlinearlayout ) { // switch grid layout = new listviewgridlayout() layout.scrolldirection = 'vertical' layout.itemheight = 150 layout.spancount = 2 } else if ( list.listviewlayout instanceof listviewgridlayout ) { // switch list layout = new listviewline

python - Reverse for 'detail' with keyword arguments '{'id': 5}' not found. 1 pattern(s) tried: ['posts/(?P<slug>[\\w-]+)/$'] -

i'm super stuck noreversematch @ /posts/ error. maybe overlooking small or maybe issue bigger digging. http://imgur.com/nlymi9v error message when models.py this: def get_absolute_url(self): #return reverse("detail", kwargs={ "slug": self.slug }) return reverse("posts:detail", kwargs={ "slug": self.slug }) http://imgur.com/a/rilrb error message when models.py this: def get_absolute_url(self): return reverse("detail", kwargs={ "slug": self.slug }) #return reverse("posts:detail", kwargs={ "slug": self.slug }) models.py #from _future_ import __unicode__literals django.db import models django.core.urlresolvers import reverse django.db.models.signals import pre_save django.utils.text import slugify # create models here. # mvc models views controller def upload_location(instance, filename): # filebase, extension = filename.spilt(".") # r

reporting services - Change SSAS server name in data source of a pbix report programmatically -

using this solution, able upload pbix report on reporting server without issues. tried updating data source information doing following: var dsinfo = rs.getitemdatasources(report.output + "/" + report.name); //gets data source of report var dsreference = (datasourcedefinition) dsinfo[0].item; //references data source dsreference.connectstring = newconnectionstring; //updates connection string of reference dsreference.credentialretrieval = credentialretrievalenum.store; //sets credential retrieval value store dsreference.windowscredentials = true; //sets windowscredential property true dsreference.username = username; //sets user name through report accessed dsreference.password = password; //sets password through report accessed datasource df = new datasource(); //creates new datasource df.item = dsreference; //assigns reference datasource new datasource df.name = dsinfo[0].name; //assigns reference datasource name new datasource name rs.setitemdatasources(report.outp

linux - gethostbyname() sometimes could not dns forever -

in 1 of our product(embeded platform using rtl8196e chips), program fails dns forever before program restarted. more investigation found if program starts before network ready(e.g.: before dhcped udhcpc), following calling gethostbyname() failed ever, @ time ping working when network ok. some tests have done illustrate:(in simplest form, e.g.: omit print result of gethostbyname) the programs started before network ready(e.g.: before eth0 has ip dhcp) program 1: not ip ever after network ok(ping ok) while (1) { res_init(); gethostbyname(...); //not work sleep(5); } program 2: execution of gethostbyname() in forked process works while (1) { pid = fork(); ... if (pid == 0) res_init(); gethostbyname(...); //works else waitpid(pid1,...); sleep(5); } program 3: execution of gethostbyname() both failed in child/parent process while (1) { pid = fork(); ... if (pid == 0) res_init(); gethostbyname(...); //not work else r

android - How to get key values from json object in retrofit 2.3 -

i trying parse json object dynamic keys , values , set them recyclerview in application. , want key or value when user clicks recyclerview child. { "status": 200, "message_type": "info", "car_types": { "sports_car": "bmw", "sports_car": "lamborghini", "classic_car": "benz", "luxary_car": "bently cooper", "suv": "range rover", "other": "other" } } try following,to key , value jsonobject . try { jsonobject jsonobject = new jsonobject("your result"); jsonobject jsonobject1_message = jsonobject.getjsonobject("message_type"); map<string,string> map = new hashmap<string,string>(); iterator iter = jsonobject1_message.keys(); while(iter.hasnext

php - Exporting MySQL DB to excel (Connection probleme) -

i have table in mysql db , want export excel. i've tried lot of source-codes seems nothing work me; looks i'm having connection problem , should between .php code , db. first, i'm using xmpp host db(phpmyadmin) can access typing localhost/phpmyadmin or localhost:80/phpmyadmin i've created db 1 called "test" , second "gfdepot".well m interested in second one. in "gfdepot" db i've 6 tables, , i'm interested in table named "zone." well, i'm using eclipse ide(with .php extension installed) script website. want have clickable button export "zone" table excel file. clickable button works well, ".php" page doesn't work! whatever try connection error. currently, m trying code below. <?php /*******edit lines 3-8*******/ $db_server = "localhost"; //mysql server $db_username = "root"; //mysql username $db_password = ""; //mysql passwo

R session abort during data.matrix transformation -

i have big binary data.table: > str(mat) classes 'data.table' , 'data.frame': 262561 obs. of 10615 variables: $ 1001682: num 0 0 0 0 0 0 0 0 0 0 ... $ 1001990: num 0 0 0 0 0 0 0 0 0 0 ... $ 1002541: num 0 0 0 0 0 0 0 0 0 0 ... $ 1002790: num 0 0 0 0 0 0 0 0 0 0 ... $ 1003312: num 0 0 0 0 0 0 0 0 0 0 ... $ 1004403: num 0 0 0 0 0 0 0 0 0 0 ... there somewhere 1 (it's not full of zeros). , i'm trying convert data.matrix writing mat <- data.matrix(mat) r session abort. problem computer? should try high performance computer? or there other way this? need in data.matrix . i'm using macbook pro 2015 2.7 ghz intel core i5 , 8gm ddr3. i not sure if more efficient roland's method, produces same matrix , not require reshape of data. require same lapply in my previous answer op, described slow. using data.table constructed in roland's answer. library(matrix) # positions of non-zero values in data.table myrows <-

python - pandas-how to apply different function to df.series while the function depending on another series? -

simply speaking, want this: df.s1.map["a":df.s2+1, "b":df.s2-1] however,it won't work because df.s2 not constant. how can map s1 on df.s2+1 while s1='a' ,and map s1 on df.s2-1 while s1='b' ? you can use apply using lambda axis = 1 i.e if have dataframe df = pd.dataframe({'s1':['a','b','a','a','b'],'s2':[1,3,5,2,4]}) df['s3'] = df.apply(lambda x : x['s2']+1 if x['s1'] == 'a' else x['s2']-1 ,axis=1 ) or take d['s2'] common dictionary , add @ end after mapping. df['s3'] = df.s1.map({'a':1,'b':-1})+df['s2'] output: s1 s2 s3 0 1 2 1 b 3 2 2 5 6 3 2 3 4 b 4 3 in [364]: output : wiki

android - Recyceler View on device rotation replication -

Image
in application, there recycler view in fragment when follow following steps got duplicated in nexus 6 5.1.1 device 1)change device orientation landscape 2)lock device 3)change device orientation portrait 4) unlock device 1 sec there replication of view i have setretaininstance = true in fragment and getsupportfragmentmanager().begintransaction() .add(getcontentframe(),fragment,fragment.getclass().getname()) .addtobackstack(fragment.getclass().getname()) .commit(); for adding fragment you need use 2 things: onsaveinstancestate onrestoreinstancestate check documentation wiki

Android Notification does not appear in BroadcastReceiver -

i'm trying create notification after amount of seconds entered user. seems me, alarmmanager , broadcastreceiver works fine (the toast in onreceive() appears after correct amount of time) notification not work (it not appear). so wrong notification? this code: mainactivity: package com.example.user.alarm; import android.app.alarmmanager; import android.app.pendingintent; import android.content.intent; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.view.view; import android.widget.button; import android.widget.edittext; public class mainactivity extends appcompatactivity { button btn_set; edittext et_time; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); btn_set = (button) findviewbyid(r.id.setalarmbutton); et_time = (edittext) findviewbyid(r.id.edittext); btn_set.setonclicklistener(new view.onclicklistener() {

android - Getting error linker command failed with exit code in NDK -

here android.mk file local_path := $(call my-dir) include $(clear_vars) local_module := prebuild_usb1.0 local_src_files :=$(target_arch_abi)/libusb-1.0.so include $(prebuilt_shared_library) include $(clear_vars) local_module := prebuild_ftrscanapi local_src_files := $(target_arch_abi)/libftrscanapi.so include $(prebuilt_shared_library) include $(clear_vars) local_module := prebuild_ftransisdk local_src_files := $(target_arch_abi)/libftransisdk.so include $(prebuilt_shared_library) include $(clear_vars) local_module := ftransisdkandroidjni local_cflags := -d__android_api__ local_src_files := ftransisdkandroidjni.cpp local_shared_libraries := prebuild_usb1.0 prebuild_ftrscanapi prebuild_ftransisdk include $(build_shared_library) and application.mk looks like app_abi=armeabi armeabi-v7a i getting error when build apk error:error: linker command failed exit code 1 (use -v see invocation) and sometime studio throws warning: '__android_api__'

python - using an if statement over two columns in pandas -

i trying calculate distance between shotpoints in seismic navigation file multiple lines. current code follows: def delimiter(filename, a, b, c, d, e, f): data = pd.read_fwf(filename, names=[a, b ,c ,d ,e ,f ], header=none) data['lineshift'] = data['line'].shift(-1) data['bool'] = data['lineshift'] == data['line'] _, row in data.iterrows(): data['spdif'] = np.abs(data['sp'].astype(float) - data['sp'].astype(float).shift(-1)) data['xdiff'] = data['x'] - data['x'].shift(-1) data['ydiff'] = data['y'] - data['y'].shift(-1) data['xydiff'] = np.sqrt(data['xdiff']**2 + data['ydiff']**2) data['spdist'] = data['xydiff']/data['spdif'] if row['line'] != row['lineshift']: data['spdif'] = data['spdif'].replace({0: np.nan})

php - Displaying current system date and time -

how show current system (pc) time on form right i'm using datetimepicker, wanna try when i'm going create in form "time_start" automatically time being used on pc. <?= $form->field($model, 'time_start')->widget( datetimepicker::classname(), [ 'options' => [ 'placeholder' => 'render time' ], 'pluginoptions' => [ 'autoclose' => true, ] ] ); ?> you can assign value $model->time_start directly in controller before call render .. so problem can managed in controlleraction using php functin assign value need eg in actioncreate public function actioncreate() { $model = new mymodel(); if ($model->load(yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { // assign the date , time of server code runs on. $mod

python - ImportError: No module named 'nets' -

i trying convert trained_checkpoint final frozen model export_inference_graph.py script provided in tensorflow/models,but following error results. , yes,i have setup $pythonpath "models/slim" still error,can me out? $ echo $pythonpath :/home/ishara/tensorflow_models/models:/home/ishara/tensorflow_models/models/slim *****************************problem**************************************************************************** $sudo python3 object_detection/export_inference_graph.py --input_type image_tensor --pipeline_config_path = "ssd_inception_v2_pets.config" --trained_checkpoint_prefix="output/model.ckpt-78543" --output_directory="birds_inference_graph.pb" traceback (most recent call last): file "object_detection/export_inference_graph.py", line 74, in <module> object_detection import exporter file "/usr/local/lib/python3.5/dist-packages/object_detection-0.1-py3.5.egg/object_detection/exporter.py&q

iterating through two numpy arrays applying a function in Python -

i have import numpy np = np.array([np.nan,2,3]) b = np.array([1,np.nan,2]) i want apply function a,b, there fast way of doing this. (like in pandas, can apply) specifically interesting in averaging , b, take average 1 of numbers when other number missing. i.e. want return np.array([1,2,2.5]) for example above. however, know answer in more general setting (where want apply operation element-wise number of numpy arrays) you can use numpy.nanmean , ignores nan s: np.nanmean([a, b], axis=0) # array([ 1. , 2. , 2.5]) wiki

javascript - ReactJs Form Submit on Enter Key press -

i want submit form when enter key pressed if use onsubmit={() => this.onsearchclick(this)} function need run put form url dont want happen need make run function api call. my code this <form> <h1>search</h1> <hr /> <textfield floatinglabeltext="case id" name="caseid" onchange={this.handlechange} /> <br /> <textfield floatinglabeltext="title" name="title" value={this.state.title} onchange={this.handlechange} /> <br /> <textfield floatinglabeltext="forename" name="forename" value={this.state.forename} onchange={this.handlechange} /> <br /> <textfield floatinglabeltext="surname" name="surname" value={this.state.surname} onchange={this.handlechange} /> <br /> <textfield floatinglabeltext="postcode" name="postcode" value={this.state.postcode}