Posts

algorithm - copy one object's state to another one via java reflection (linear complexity) -

imagine have 2 objects ("from" , "to"). need scan object "from" getters. if object "to" contains correspondent setter, invoke set property value "to" equals property of "from". type in setter should compatible value returned getter (if not, no invocation performed). compatible means parameter type in setter should same or superclass of return type of getter. i'm sure know approach solve task. need write method "assign", example: public static void assign(object to, object from) { class<?> classto = to.getclass(); class<?> classfrom = from.getclass(); method[] methodsto = classto.getmethods(); method[] methodsfrom = classfrom.getmethods(); (method methodfrom : methodsfrom) { if... } } and each get-method need go through list of set-methods , result of invoking get-method pass parameter correspondent set-method. in case complexity of algorithm n*m (where n - ...

javascript - removeChild() deletes subelements? -

i got challenge trying better understand how things work in world. there 2 html pages: one.html <html> <script> var ifrm = document.createelement("iframe"); var c = document.head; ifrm.src = 'two.html'; (c = document.head || document.body) && c.appendchild(ifrm); //ifrm.parentnode && ifrm.parentnode.removechild(ifrm) </script> </html> two.html <html> <script> var newl = parent.document.createelement("img"); newl.src = 'http://qwerty.com'; parent.document.body.appendchild(newl); </script> </html> i can control contents of two.html , i'm trying create in parent, persist after uncommenting last line in js one.html. of now, tag created once uncomment line removechild(), it's gone. can 1 explain me why, , if there way complete task under specified circumstances? in advance!

Redis PUB/SUB and high availability -

currently i'm working on distributed test execution , reporting system. i'm planning use redis pub/sub message queue , message distribution system. i'm new redis, i'm trying read many docs can , play around it. 1 of important topics high availability. said, i'm not expert, i'm aware of possible options - using sentinel, replication, clustering, etc. what's not clear me how pub/sub feature , ha options related each other. what's best practice build reliable messaging system redis? reliable mean if redis message broker down there should kind of backup node (a slave?) should able take on role. is there purely server-side solution? or need create smart wrapper around redis client handle this? sentinel-driven setup me? doing pub sub in redis failover means thinking additional factors in client side. key piece understand subscriptions per-connection. if subscribed channel on node , fails, need handle reconnect , resubscribe. because subscrip...

How to record audio file using MediaRecorder and save to sdcard in android -

i working on 1 module record voice , upload php server using multipartentity. i able record voice , saving file in sdcard whenever trying uplaod file php server (using mpe), not uploading , server getting blank file content. while in device able play voice , working fine in device. issue uploading. using same code upload other media images , video , other files. working fine. issue recorded file. this code record voice. mediarecorder recorder = new mediarecorder(); recorder.reset(); recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(mediarecorder.outputformat.mpeg_4); recorder.setaudioencoder(mediarecorder.audioencoder.default); string filepath = environment.getexternalstoragedirectory() + "/" + environment.directory_dcim + "/abc.mp4"; recorder.setoutputfile(filepath); // file path store data recorder.prepare(); recorder.start(); and using multipart upload voice recording on server. ...

params does not contain POST Body in Elixir / Phoenix -

i try build simple rest api. not include database or models. here's router: defmodule zentonies.router use zentonies.web, :router pipeline :browser plug :accepts, ["html"] plug :fetch_session plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers end pipeline :api plug :accepts, ["json"] end scope "/v1/events/", zentonies pipe_through :api post "/call", pagecontroller, :call end end here controller: defmodule zentonies.pagecontroller require logger import joken use zentonies.web, :controller def index(conn, _params) render conn, "index.html" end def call(conn, params) logger.debug inspect(params) conn |> put_status(200) |> text("response.") end end now, if http post endpoint, inspect(params) not return json body of post request. instead returns :call . any appreciated! a call/2 funct...

ruby on rails - Rails5 - Adding Foreign Keys to Existing Models in postgres -

i have 2 models. events model , eventoption . events have_many :event_options . my issue when try migration add_foreign key :event_options, :events can link them up, following error: activerecord::statementinvalid: pg::undefinedcolumn: error: column "event_id" referenced in foreign key constraint not exist : alter table "event_options" add constraint "fk_rails_3995702fad" foreign key ("event_id") references "events" ("id") here's schema.rb: activerecord::schema.define(version: 20160806001743) # these extensions must enabled in order support database enable_extension "plpgsql" create_table "event_options", force: :cascade |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.float "price" t.text "description" t.string "name" end create_table "events", force:...

vba - How can I get a digital trust certificate for an Access executable file in Windows 10? -

in previous posts, mentioned split access database project (access 2016) in front-end (access) , back-end (ms-sql). recommended save front-end executable file, did. however, since has macros , vba code, security warning. i need digital trust certificate, right? problem that, since have windows 10, can't use office 2010/2013 tutorials making self-certificate vba. can buy one? confused, , resolve because intend install front-end exe file onto several computers @ work. thank time , help!