Posts

c# - Web Api Redirect Incoming Events To Correct Controller -

i have basic restful web api project receive events third-party. there on 10 possible events third-party allows 2 subscriptions (a subscription contains callback url web api). rather limit myself 2 events, want create "master" controller can determine type of event being sent, , redirect json/post correct controller. here example controller have 1 of events [httppost] public async task<ihttpactionresult> create(createdobject createdobj) { await _classtohandleobj.methodtohandle(createobj); return ok(); } in json being sent, there field contains name of event. try read json , use conditional statements send it, wanted know if there best practice way of doing web api.

android - Mediaplayer unable to play audio file in Cordova -

i using media plugin in cordova , trying download , play audio file using below code: $http.get(url, {responsetype: 'arraybuffer'}).then(function(response) { requestfilesystem(filename, {create: true}, function gotfileentry(fileentry) { fileentry.createwriter(function gotfilewriter(writer) { writer.onwriteend = function() { var successcallback = onsuccess.bind(undefined, fileentry); var media = new media(filename, successcallback, successcallback); media.play(); }; writer.write(response.data); }, onerror); }, onerror) }, onerr somehow 1 audio file(412553300.acc) working fine when play second 1 after downloading server not playing code have given error on console this: e/mediaplayer: error (1, -2147483648) i not getting either code have problem or file(394127925) not enough ...

java - Dagger2 where inject @Named @Provides in dependent module? -

Image
i use dagger2 demo https://guides.codepath.com/android/dependency-injection-with-dagger-2 . want use cached , non_cached retrofit call. create in netmodule.java @provides @named("cached") @singleton okhttpclient provideokhttpclient(cache cache) { okhttpclient okhttpclient = new okhttpclient.builder() .cache(cache) .build(); return okhttpclient; } @provides @named("non_cached") @singleton okhttpclient provideokhttpclientnoncached() { okhttpclient okhttpclient = new okhttpclient.builder() .build(); return okhttpclient; } githubmodule.java dependent on netmodule.java. githubcomponent.java @userscope @component(dependencies = netcomponent.class, modules = githubmodule.class) public interface githubcomponent { void inject(demodaggeractivity activity); } my netcomponent.java @singleton @component(modules={applicationmodule.class, netmodule.class}) public interface netcomponent { // downstream components n...

openpyxl - XLRD intermittently reads Bloomberg excel formulas -

i using xlrd gather data excel sheet, performing calculations , writing same sheet (writing using openpyxl preserve .xlsx file type). part of data gathering uses bloomberg formulas automatically gather data in excel. xlrd can read few times, if run script more 3-4 times fails. data gathering strings, , when fails, reads in empty strings. formulas still preserved on sheet , data still there, data being read in doesn't work. does have insight issue, or way ensure compatibility in reading in info? thanks!

bash - File Lock on Linux -

so there 2 scripts: , b, both want write same file. it's possible both scripts want write file @ same time. how can lock file? while script writing file, script b has wait till file unlocked. i tried this: while [ -f $lock ] sleep 0.1 done touch $lock #action rm $lock problem script above it's possible, both of , b looking $lock @ same time, , cant find't start writing. help? try this: script open file set attribute chattr +i test.txt , after script done use chattr -i test.txt . for example: script a chattr +i test.txt tail -n 50 /var/log/maillog > test.txt chattr -i test.txt script b chattr +i test.txt tail -n 50 /var/log/messages > test.txt chattr -i test.txt

c++ - WrapPerspective doesn't dewrap corectly -

after procedure std::vector<std::pair<cv::point, cv::point>> tempendpoints , i'll following first , second parameter: first: [139, 113][201, 310][223, 339][297, 437][323, 472][381, 465][408, 413][484, 291][505, 151] second: [139, 210][201, 692][223, 664][297, 550][323, 523][381, 544][408, 580][484, 699][505, 254] now i'm stuck @ wrapperspective . each of "corner" points creats small image, has individual size (it earlier created textureimage ). stored , fine. want dewrap "small images" inside points, mentioned before. for (int = 0; < tempendpoints.size() - 1; i++) { //do stuff... cv::vec3b zero(0, 0, 0); cv::mat_<cv::vec3b> dewrapped(textureimage.rows, textureimage.cols, zero); cv::point2f srcpts[] = { point2f(tempendpoints[i].first), point2f(tempendpoints[i + 1].first), point2f(tempendpoints[i + 1].second), point2f(tempendpoints[i].second) }; std::cout ...

What is $sel in a Template Haskell Name? -

i'm calling th function, called createrecordsplice in following manner: data user = user {userfoo :: string, userbar :: text} deriving (eq, show, generic) createrecordsplice "user" ''user ['userbar] "newuser" "nuser" notice record selector userbar passed single-quote. now, in th function want check field names of user against userbar , i'm encountering strange field name contains $sel , due which, main logic failing work. (common.testrecordsplices.userfoo,[common.testrecordsplices.$sel:userbar:user]) (common.testrecordsplices.userbar,[common.testrecordsplices.$sel:userbar:user]) what $sel:userbar:user , how 1 convert userbar $sel:userbar:user , or vice versa, without resorting string manipulation? my th function: createrecordsplice :: string -> name -> [name] -> string -> string -> q [dec] createrecordsplice sourceprefix record requiredfields newrectype targetprefix = reify record >>= \case ...