Posts

jquery - How do I structure data for POST from form in ReactJS? -

i have basic react component contact form issues post api endpoint (using django rest framework). endpoint handles actual sending, , such. i'm using jquery handle ajax business -- know overkill; removed later -- can't seem grok how structure values form in component submission endpoint. here's component: var contactform = react.createclass({ getinitialstate: function() { return { name: '', email: '', message: '', url: '', }; }, handlenamechange: function (e) { this.setstate({name: e.target.value}) }, handleemailchange: function (e) { this.setstate({email: e.target.value}) }, handlemessagechange: function (e) { this.setstate({message: e.target.value}) }, handleurlchange: function (e) { this.setstate({url: e.target.value}) }, handleformsubmit: function (e) { e.preventdefault(); var name = this.state.name.trim(); var email = this.state.email.trim(); v...

javascript - Rename file with NPM -

is there way rename single file in npm scripts? want prepare files distribution, need built files named differently in source... i have tried orn, seems work on command line, not npm script. i'm looking add cross-platform dependency project, rather writing own javascript script copy files over. my ideal solution can include in package.json , 1 line command, e.g. rename old-file-name new-file-name sure. npm script can run node js file want. for example: require('fs').rename(oldpath,newpath) more info: https://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback https://docs.npmjs.com/misc/scripts

c# - Get Parent of custom TextBox control -

when creating custom control extends textbox, inside oncreatecontrol() override, parent null. when extending other controls such button, isn't null. checking following code , adding form , various container controls: protected override void oncreatecontrol() { base.oncreatecontrol(); messagebox.show((parent == null).tostring()); //true when extending textbox, false when extending button } what can retrieve parent of control when added control, ensuring same code work regardless of control extend?

Scala : Compiler emits no warning when pattern matching against a sealed trait -

here snippet. when pattern matching, compiler emits no warning. know workaround ? i compiler emit warning when forget case when pattern matching against simpleexpr.expr , otherexpr.expr . construct allows me factor nodes common both expression trees (like if ) trait hierarchy { sealed trait expr } trait if { this: hierarchy => case class if(cond: expr, yes: expr, no: expr) extends expr } trait word { this: hierarchy => case class word(name: string) extends expr } object simpleexpr extends hierarchy if word //object otherexpr extends hierarchy if integer object demo extends app { import simpleexpr._ def func(expr: expr) = expr match { case if(cond, yes, no) => cond // compiler should emit warning } } because sealed isn't transitive, it's not clear me whether lack of compile error bug or not. i noticed adding case match expression causes compiler issue "unreachable code" warning. here's modified version of co...

image - The opposite effect of scratch card for Android. (Anti erase effect of picture) -

i make application, have 2 pictures(layers) , can erase part of foreground image(using tapping , finger painting). make this, had used scratchview library android. android-wscratchview this give opportunity erase parts of images. next step - "anti erase". must use finger draw, , restore parts of image have been erased. dont understand how it. may possible change method of library class , have opportunity "anti erase". may should create special handler this. had tried done long time, , hope can me in this. thanks! i guess article should this: http://www.41post.com/4794/programming/android-rendering-a-path-with-a-bitmap-fill there can see how draw path filled bitmap. rest pretty straightforward: assign bitmap (top layer image) paint in above article. in "motionevent.action_down" add path not mpathlist, other, say, npathlist. in "ondraw" go through npathlist , draw paint article above.

python - Cities with a larger number of acquirers than startups -

my query below produces no output. i'm trying group city, city names of groups satisfy "having" condition. wrong here? create view que select acquirer_city acquisitions group acquirer_city having count(distinct company_name) < count(distinct acquirer_name) your sql creating view, not running query. if run select * que you see content of view. however, if not wanting create view (to used later), remove first line. run query , return results.

ruby - Error using Carrierwave in rails -

i have website contains many users , each user have own profile want let them upload there image through carrierwave gem loop following errors first time work carrierwave gem :( : actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' web-console (2.2.1) lib/web_console/middleware.rb:39:in `call' actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app' railties (4.2.4) lib/rails/rack/logger.rb:22:in `call' quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets' request_store (1.2.0) lib/request_store/middleware.rb:8:in `call' actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.6.4) lib/rack/methodoverride.rb:22:in `call' rack (1.6.4) lib/rack/runtime.rb:18:in `call' rack-timeout (0.3.2) lib/rack/timeout/core.rb:125:in `block in call' rack-timeout (0.3.2) li...