Posts

javascript - Node.js FileSystem access returns ENOENT despite the file existing -

Image
i have node.js function uses fs.access check if file exists, readable , writable: function stackoverflowfunction() { try { fs.accesssync(`file://${__dirname}/config/config.ini`, fs.constants.f_ok | fs.constants.r_ok | fs.constants.w_ok); } catch (err) { console.log(err); } despite file existing, { error: enoent: no such file or directory, access 'file:///home/callcenter1/bookgenerator/config/config.ini' @ error (native) @ object.fs.accesssync (fs.js:248:11) @ object.fs.accesssync (electron_asar.js:420:27) @ getconfig (/home/callcenter1/bookgenerator/main.js:12:12) @ object.<anonymous> (/home/callcenter1/bookgenerator/main.js:18:10) @ module._compile (module.js:541:32) @ object.module._extensions..js (module.js:550:10) @ module.load (module.js:458:32) @ trymoduleload (module.js:417:12) @ function.module._load (module.js:409:3) errno: -2, code: 'enoent', syscall: 'access', path: 'file:///home/callcenter1/bookgenerator/config/confi...

Get object from array of objects in Javascript -

i have array: var arrayexample = [ {productid: 1, quantity: 2, name: example, description: example}, {productid: 1, quantity: 2, name: example, description: example}, {productid: 1, quantity: 2, name: example, description: example}, {productid: 1, quantity: 2, name: example, description: example}]; my question how items of array taking in every object productid , quantity ? having array contains objects 2 values? number of objects of array variable result: var arrayexamplenew = [ {productid: 1, quantity: 2}, {productid: 1, quantity: 2}, {productid: 1, quantity: 2}, {productid: 1, quantity: 2}]; sorry english you map var arrayexample = [{ productid: 1, quantity: 2, name: 'example', description: 'example' }, { productid: 1, quantity: 2, name: 'example', description: 'example' }, { productid: 1, quantity: 2, name: 'example', description: 'example' }, { productid...

android - adb Key event for Keyboard next key -

please click image link hi all, i have login page shown in attached image. native app login page. when try log in, keyboard hides password textbox/ sign in button, need click on next key have marked black circle. the clicking of button wanted using automation. can precisely tell me key event key. need adb command send key event device. adb shell input keyevent <keycode> events can passed 0 keycode_unknown 1 keycode_menu 2 keycode_soft_right 3 keycode_home 4 keycode_back 5 keycode_call 6 keycode_endcall 7 keycode_0 8 keycode_1 9 keycode_2 10 keycode_3 11 keycode_4 12 keycode_5 13 keycode_6 14 keycode_7 15 keycode_8 16 keycode_9 17 keycode_star 18 keycode_pound 19 keycode_dpad_up 20 keycode_dpad_down 21 keycode_dpad_left 22 keycode_dpad_right 23 keycode_dpad_center 24 keycode_volume_up 25 keycode_volume_down 26 keycode_power 27 keycode_camera 28 keycode_clear 29 keycode_a 30 keycode_b 31 keycode_c 32 keycode_d 33 keycode_e 34 keycode_f 35 keycode_g 36 keyco...

bash - How to use unix command 'cat' in android to concatenate two video files from sd card? -

i have split video file 2 files 'part1' , 'part2' via git bash. both these files individually unreadable. need concatenate these 2 files , play video. works fine via git bash since new android, can't seem programmatically. did come across answer here said : string[] command = {"ls","-al"}; processbuilder builder = new processbuilder(command); builder.directory(new file(/ngs/app/abc)); p = builder.start(); however, don't know how write command 'cat part1 part2 > new.mp4' using technique. great! thanks! you have invoke shell , pass command line script parameter. example bash shell run following bash -c 'cat part1 part2 > new.mp4' given template work out following string[] command = {"bash", "-c", "cat part1 part2 > new.mp4"}; processbuilder builder = new processbuilder(command); builder.directory(new file(/ngs/app/abc)); p = builder.start(); of course cat con cat ...

python - Using regex, extract quoted strings that may contain nested quotes -

Image
i have following string: 'well, i've tried "how doth little busy bee," came different!' alice replied in melancholy voice. continued, 'i'll try again.' now, wish extract following quotes: 1. well, i've tried "how doth little busy bee," came different! 2. how doth little busy bee, 3. i'll try again. i tried following code i'm not getting want. [^\1]* not working expected. or problem elsewhere? import re s = "'well, i've tried \"how doth little busy bee,\" came different!' alice replied in melancholy voice. continued, 'i'll try again.'" i, m in enumerate(re.finditer(r'([\'"])(?!(?:ve|m|re|s|t|d|ll))(?=([^\1]*)\1)', s)): print("\ngroup {:d}: ".format(i+1)) g in m.groups(): print(' '+g) if really need return results single regular expression applied once, necessary use lookahead ( (?=findme) ) finding position goe...

extjs5 - How to Abstract a base container with some default items in Sencha Extjs 6? -

i trying develop base container extending ext.container, have default items in it. subclass should add items child component of base class , not directly container instead. how this? may override setitems / applyitems method add items navigationview.add(items); ?? i'm unsure how works. since i'm new extjs, unable identify way generically won't affect subclass add n number of items either using inline or add(item) method. abstractclass ext.define('myapp.container.abstractmaincontainer', { extend: 'ext.container', xtype: 'abstractmaincontainer', requires: [ 'myapp.container.navigationview', 'myapp.control.navigationbar' ], config: { layout: { type: 'vbox', pack: 'start', align: 'stretch' }, flex: 1, height: '100%', width: '100%' }, controller: 'maincontroller...

Difference- ApplicationContext() VS. Activity Context in ANDROID..? -

possible duplicate: difference between activity context , application context i want know actual difference between application context , activity context in android ..? these 2 confusing me time. please find me difference two.?? to have gist on application context , activity context read below: the application context live long application alive , not depend on activities life cycle. if plan on keeping long-lived objects need context, remember application object. can obtain calling context.getapplicationcontext() or activity.getapplication(). in summary, avoid context-related memory leaks, remember following: 1.do not keep long-lived references context-activity (a reference activity should have same life cycle activity itself) 2.try using context-application instead of context-activity reference & more info