Posts

arrays - Algorithm balanced K-D tree with O(kn log n) -

i tried implement balanced k-d tree o(kn log n), used presorted k arrays (sorted arrays each index) o(kn log n), , median balanced tree. the problem faced median value @ level ,for example median x axis, maybe chosen again @ subsequent level, example y axis. i tried solve dividing y sorted array 2 arrays using chosen x value pivot, way wouldn't yield balanced tree. any idea how k-d balanced tree o(kn log n)? edit quoted wiki https://en.wikipedia.org/wiki/k-d_tree alternative algorithms building balanced k-d tree presort data prior building tree. maintain order of presort during tree construction , hence eliminate costly step of finding median @ each level of subdivision. 2 such algorithms build balanced k-d tree sort triangles in order improve execution time of ray tracing three-dimensional computer graphics. these algorithms presort n triangles prior building k-d tree, build tree in o(n log n) time in best case.[5][6] algorithm builds balanced k...

javascript - display text using ajax and php -

i'm trying simple thing in ajax not work. want display text when click on input button ajax.js jquery(document).ready(function($) { $('#insertform').change(function(){ //on recupere la valeur de l'attribut value pour afficher tel ou tel resultat var req=$('#insertform').val(); //requête ajax, appel du fichier function.php $.ajax({ type: "post", url: "lib/function.php", data: "insertform="+req, datatype : "html", //affichage de l'erreur en cas de problème error: function(xmlhttprequest, textstatus, errorthrown) { alert(xmlhttprequest + '--' + textstatus + '--' + errorthrown); }, //function s'il n'y pas de probleme success:function(data){ $('.coucou').empty(); $('.coucou').prepend(data.coucou) } }); }); }); html.php <div class="coucou"></div> <button type="button" class="btn btn-succ...

html5 canvas - taking a 'snapshot' of babylonjs scene sometimes works, sometimes doesn't -

i trying take 'snapshot' of babylon3d scene ... in other words: trying clone babylon3d canvas when user presses button, , append new <canvas> <body> .. works, other times not. however, if use simple canvas (ie. using fillrect), cloning/appending works expected. i have set test on plunker demonstrate problem: plunker : press button on , on again see how sporadic behaves when there babylon scene. and note : can toggle between simple canvas , babylon canvas within _jquery(document).ready(...) handler. thanks, shannon this because version 2.3.0 of babylonjs : engine initialize webgl preservedrawingbuffer = false default. you need initialize engine passing {preservedrawingbuffer: true} object third parameter. forked plnkr but unfortunately kill canvas' performances. see more here. i'm not specialist of babylonjs, , didn't find way make call scene.render method use flag method proposed @capse. there babylon.tools.cre...

python - GRASS parser() error -

i'm trying use grass on python 2.7, i'm having problems @ setting script on idle, i'm getting error @ parser() function: here script: import os import sys gisbase = os.environ['gisbase'] = 'c:\program files (x86)\grass gis 7.0.1rc1' gisrc = 'c:\grassdata' gisdbase = 'c:\grassdata' location = 'newlocation' mapset = 'tc' ld_library_path = 'c:\program files (x86)\grass gis 7.0.1rc1\lib' path = 'c:\program files (x86)\grass gis 7.0.1rc1\etc';'c:\program files (x86)\grass gis 7.0.1rc1\etc\python';'c:\program files (x86)\grass gis 7.0.1rc1\lib';'c:\program files (x86)\grass gis 7.0.1rc1\bin';'c:\python27';'c:\program files (x86)\grass gis 7.0.1rc1\python27';'c:\program files (x86)\grass gis 7.0.1rc1\msys' pythonlib = 'c:\python27' pythonpath = 'c:\program files (x86)\grass gis 7.0.1rc1\etc\python' sys.path.append(os.path.join(os.environ['...

ruby on rails - Unique multiple key index issue in production (Heroku PostgreSQL) -

i facing issue have tried solve myself don't what's wrong. french models, controllers... have french names. i developing app association makes call in french "maraudes" every night : driving around meet people. i have maraude model : class maraude < activerecord::base default_scope -> { order(date: :desc) } validates :date, presence: true, uniqueness: { scope: :type_maraude } validates :type_maraude, presence: true end my maraudes have :date , :type_maraude attributes, , want them define every maraude, every maraude has unique [:date, :type_maraude] combination. in order this, created migration : class addindextomaraudes < activerecord::migration def change add_index :maraudes, [:date, :type_maraude], unique: true end end it working in development. in production (heroku), have created maraude dated 2016-02-02 type (maraude salariés 1) , when trying create other maraude @ same date different type followin...

Django custom manager and queryset narrowed result -

i want able in template: request.user.notifications.unseen and show user unseen notifications has. so far, based on few posts found here, able develop this: class notificationqueryset(models.queryset): def unseen(self): return self.filter(is_read=false) class notificationmanager(models.manager): use_for_related_fields = true def get_query_set(self): return notificationqueryset(self.model) def unseen(self, *args, **kwargs): return self.get_query_set().unseen(*args, **kwargs) it works fine, shows 'unseen' notifications users. what thought specifying object relation, such user.notifications , argument passed function narrowing results user requesting it. so, how narrow results 1 user , not of them? edit models.py class usernotification(models.model): user = models.foreignkey(user, related_name='notifications') advertisement = models.foreignkey(advertisement) creation_date = models.datetimefiel...

Changing the color of selected items in react-select -

Image
i want change color of selected items in react select. selected items appear blue. want change color grey towards did following steps created file called mycomponent.scss $grey: #999; .select--multi { .select-value { background-color: $grey; color: $grey; }} and imported file component import 'react-select/scss/default.scss'; import './mycomponent.scss'; my hope override default color $grey variable. but color still blue. changing color of requires juggling of .css there lot of elements have changed. remember 4th number of rgba represents translucence. here elements need changed: div.select-control>.select-value { background-color: rgba(153, 153, 153, .08); border: 1px solid rgba(153, 153, 153, 0.24); color: #999; } div.select-control>.select-value>.select-value-icon { border-right: 1px solid rgba(153, 153, 153, 0.24); } div.select-control>.select-value>.select-value-label, .select-value>a { color: #999; } ...