Posts

Javascript loop when calling focus event -

i trying validate form, , testing event handlers new them. wondering why code loop, in sense moment click on input field messages keeps on showing. have thought of adding boolean stop it, there better way? $(document).ready(function(){ function test() { alert("this keeps showing up!"); } document.formulario_reserva.dni.addeventlistener("focus", test, false); });

Enforcing user quota in Firebase -

what best way enforce per-user quota on data stored in firebase? my users able create documents unique id on following path: /documents/id/contents the id uniquely generated using transaction. id reserved using verification rule ( contents.id == auth.id ) however how prevent user spamming db (by randomly allocating ids themselves)? can have rule counts number of ids allocated user , rejects them if count high? there's no way this. in cases enumerate children allowed exist (child1, child2, etc), , grant read / write each one. won't work large numbers though or ids don't know beforehand. we have plans built features restrict number of allowed children , provide other features enforce quotas on users.

doctrine2 - Doctrine - QueryBuilder, select query with where parameters: entities or ids? -

i have product entity , shop entity. a shop can have 0 n products , product can in 1 shop. the product entity table refering shop entity through shop_id table field. when querying products of given shop using doctrine query builder, can this: $products = $this->getdoctrine()->getrepository('mybundle:product') ->createquerybuilder('p') ->where('p.shop = :shop') ->setparameter('shop', $shop) // here pass shop object ->getquery()->getresult(); or this: $products = $this->getdoctrine()->getrepository('mybundle:product') ->createquerybuilder('p') ->where('p.shop = :shopid') ->setparameter('shopid', $shopid) // pass directly shop id ->getquery()->getresult(); and both seem work... i'm wondering: can pass directly entity ids instea...

c# - EF - How to edit the below model using linq? -

i'm sending view model data client , update model. know how calling stored procedure, know how using linq queries. appreciated. thanks [httppost] public jsonresult editemployee(models.employee employee) { try { if (modelstate.isvalid) { using (emsctx) { var employeeresults = (from q in emsctx.employees q.id == employee.id //code update model. ); employeedata.employees = employeeresults; } return json(); } if want update data in db correspoding employee check below edited code: [httppost] public jsonresult editemployee(models.employee employee) { ...

mysql - How to make an exe or a setup to distribute my Java(+DB) project made in NetBeans -

hello made project using netbeans , netbeans database jdbc, tried make own exe file using "exe4j wizard" , successful project still using database computer, when try on computer throws error (cant find it). im wondering if can problem. im guessing, maybe if find way use relative path database can put inside folder exe, or that. ps: give details, im kinda new , first time this, thank you!

Mapping a stream of tokens to a stream of n-grams in Java 8 -

i think basic question concerning java 8 streams, have difficult time thinking of right search terms. asking here. getting java 8, bear me. i wondering how map stream of tokens stream of n-grams (represented arrays of tokens of size n). suppose n = 3, convert following stream {1, 2, 3, 4, 5, 6, 7} to {[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]} how accomplish java 8 streams? should possible compute concurrently, why interested in accomplishing streams (it doesn't matter in order n-arrays processed). sure, old-fashioned for-loops, prefer make use of stream api. such operation not suited stream api. in functional jargon, you're trying called sliding window of size n . scala has built-in sliding() method, there nothing built-in in java stream api. you have rely on using stream on indexes of input list make happen. public static void main(string[] args) { list<integer> list = arrays.aslist(1, 2, 3, 4, 5, 6, 7); list<list<...

javascript - How work with $(target) inside directive? -

i build directive time selection 2 blocks. problem catch target event on blocks inside directive template. directive template: <div class='time-picker-container'> <div class='block1' ng-click='show()'>1</div> <div class='block2' ng-show='selectvisible'>2</div> </div> js: scope.selectvisible = false; scope.show = function() { scope.selectvisible = scope.selectvisible ? false : true; } $rootscope.$on('documentclicked', function(inner, target) { //try hide div.block2 if user make click outside block. }); basic idea: when user make click on document, outside div.block2, block disappear. when user click somewere inside div.block2 block stay visible. on run function: angular.element(document).on('click', function(e) { $rootscope.$broadcast('documentclicked', angular.element(e.target)); }); in template, add $event argument ng-click handler ...