Posts

Showing posts from February, 2015

javascript - Why is my browser freezing while doing a counting for child elements inside a container div using jQuery? -

i using jquery ganttview library generate gantt chart - https://github.com/thegrubbsian/jquery.ganttview after gantt has been generated, executing following jquery code count child elements inside ganttchart generated html: $('.ganttview-grid').children().length but freezing browser 40 seconds , there aren't child elements inside container (about 460 child elements exist inside div recognized $('.ganttview-grid') . can tell me, how data jquery handling or reading, or there faster way compute without browser freeze? i've tried sample page: http://thegrubbsian.github.io/jquery.ganttview/example/index.html and script posted doesn't showed problem (these 17 childs). i've used jquery retrieve list of thousand or ten thousands elements without problem. sure it's line freeze browser ? try placing return in line below sure problem not place after call. generally working dom slow not slow can feel operation retrieving 500 elements. ...

Asterisk multiple IP registration -

i have linux box several ip addresses running asterisk. is there way force asterisk make trunk registrations specific (not default) ip addresses? need connect 2 users same asterisk box same provider via different ips. thanks lot in advance help. you have use 3 trunks , source-based routing. asterisk select interface packet have send based on source-routing.

Suppress Subreport in crystal reports -

i want suppress subreport, if 1 of field, used in subreport empty, need formula it, actually, can able suppress subreport based on fields used in main report only, please provide solution it, in advance. solution 1: 1) create formula in subreport. condition hide/show subreport. on following lines whileprintingrecords; shared stringvar formulaname:= if (condition) '1' else '0'; // can use true /false 2) on main report create formula shared stringvar formulaname; formulaname 3) use formula hide subreport or section on main report. note: important have subreport higher in hierarchy formula in main report calls variable. suggest have "whilereadingrecords;" in both, way ensure evaluate @ same time. also, little debugging help, put "formulaname" @ end of first formula, way can see value is/should be. solution 2: if not work, create duplicate copy of subreport , place on section above existing subreport , suppress it. use solut...

android - How to randomly populate a fragment with database data -

i have fragment displays data gotten database(sqlite) row. want achieve pic different row database , populate fragment on button click. if possible, row picked randomly. hope asked question right. in advance one possible way query rows @ once random order , keep cursor around. every time button clicked, advance cursor position , use data. when run out of rows, can query again randomized cursor , repeat. i'm not sure query code looks like, want essentially select [columns] [table] order random(); the important part order random() . note strategy not allow same row data appear second time unless exhaust entire cursor once. if that's not acceptable, next possibility query every time button clicked , this: select [columns] [table] _id != [current_item_id] order random() limit 1; whatever primary key column (my example uses _id ), make query exclude row value same current item. order random() again , limit 1 return 1 row.

ios - After converting to ARC I am getting "message sent to deallocated instance" -

i creatinng instance of view this... - (ibaction)findpatienttapped:(id)sender { requestdialogviewcontroller *findpatientviewcontroller = [[requestdialogviewcontroller alloc] initwithnibname:@"requestdialogviewcontroller" bundle:nil]; findpatientviewcontroller.delegate = self; findpatientviewcontroller.autocorrectoff = yes; findpatientviewcontroller.defaultresponse = @""; findpatientviewcontroller.keyboardtype = @"ascii"; findpatientviewcontroller.returnkeytype = @"go"; findpatientviewcontroller.tag = findrequesttag; findpatientviewcontroller.editset = yes; findpatientviewcontroller.titletext = @"find patient"; findpatientviewcontroller.messagetext =@"enter or portion of patient's name..."; findpatientviewcontroller.messagetext2 = @"last name..."; findpatientviewcontroller.messagetext3 = @"first name..."; findpatientviewcontroller.showrespon...

c# - Exception when attempting to modify Dictionary -

i creating dictionary manage threads , ran exception when attempt clear dead threads after adding threads dictionary. using system; using system.collections.generic; using system.threading; namespace syscat { public class threadmanager { public static readonly threadmanager globalthreadmanager = new threadmanager( ); /// <summary> /// initializes new instance of <see cref="syscat.threadmanager"/> class. /// </summary> public threadmanager( ) { } /// <summary> /// create new threadmanager threads within basetm , deinitializes basetm /// </summary> public threadmanager( threadmanager basetm ) { this.threads = basetm.threads; basetm.threads.clear( ); } private dictionary<guid,thread> threads = new dictionary<guid, thread>( ); /// <summary> /// attempts obtain unused threadid within ...

angularjs - Authentication/ CSRF protection on a Django web app using Tastypie -

i start building web , cordova based mobile app use django / tastypie api server. the app not served django, served independent server/ domain django being there provide api. tastypie has options api key, basic http authentication, session based authentication. trying decide approach take. opinions out there? app provide unauthenticated login / signup rest behind login. i have built web apps based on angular before served django , them able csrf token posting data. app hybrid mobile app (cordova based) , web app served domain or other. how best handle csrf given not able csrf token add ajax requests? i have looked how other services such parse.io solve have not found helps. thanks rich

Renderscript Documentation and Advice - Android -

i have been following guide on how use render-script on android. http://www.jayway.com/2014/02/11/renderscript-on-android-basics/ my code (i got wrapper class script): public class pixelcalcscriptwrapper { private allocation inallocation; private allocation outallocation; renderscript rs; scriptc_pixelscalc script; public pixelcalcscriptwrapper(context context){ rs = renderscript.create(context); script = new scriptc_pixelscalc(rs, context.getresources(), r.raw.pixelscalc); }; public void setinallocation(bitmap bmp){ inallocation = allocation.createfrombitmap(rs,bmp); }; public void setoutallocation(bitmap bmp){ outallocation = allocation.createfrombitmap(rs,bmp); }; public void foreach_root(){ script.foreach_root(inallocation, outallocation); } } this methods calls script: public bitmap processbmp(bitmap bmp, bitmap bmpcopy) { pixelcalcscriptwrapper.setinallocation(bmp); ...

Switch in Navigation drawer item with Design Support Library on Android -

Image
i need put switch inside item in navigation drawer. i'm using new design support library, cannot find if posibble @ all. when using android:checkable item full selected , not wish. this screenshot of want. possible achieve that? your menu item navigation drawer: <item android:id="@+id/nav_item1" android:icon="@drawable/ic_item1" android:title="item1" app:actionlayout="@layout/layout_switch" /> and layout item: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.switchcompat android:id="@+id/drawer_switch" android:layout_width="fill_parent" android:layout_height="mat...

java - Hazelcast Eviction on Update -

the eviction policy set lfu, updating each element after time. update element reset eviction counter? if update entry (outside map), not affect eviction counter. if entry map or put map, updates eviction counter.

java - Add Images using Spinner in Android Studio -

i'm trying load image in mainactivity based on selected spinner element. so if spinner consist 2 channel names in layout, , these names stored in array channels = ["skysports", "premierlive"] i have defined imageview: imageview logo = (imageview) findviewbyid(r.id.logo); while creating spinner i'm using channels array , there i'm calling getlogo(channels[i]); where channels[i] current selected spinner element. finally, i'm trying implement image switch switch-case inside getlogo: public void getlogo(string channel){ switch(channel){ case ("skysports"): logo.setimageresource(r.drawable.skysports); break; case ("premierlive"): logo.setimageresource(r.drawable.premierlive); break; } } all gives me java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.imageview.setim...

watchkit - animateWithDuration lacks completion block, WatchOS 2 -

watchos 2 not have kind of completion block in animatewithduration function. i'm working on game requires running code after animation completed. there work arounds? perhaps using key-value observation? alternative use timer matches length of animation that's non-ideal obvious reasons. nsoperation didn't work me too. using following solution until apple officially adds completion block. not ideal works. have opened radar. maybe apple add completion block in future seed of watchos 2. this extension adds animatewithduration method takes completion block. , completion block called after duration of animation block. extension wkinterfacecontroller { func animatewithduration(duration: nstimeinterval, animations: () -> void, completion: (() -> void)?) { animatewithduration(duration, animations: animations) let completiondelay = dispatch_time(dispatch_time_now, int64(duration * double(nsec_per_sec))) dispatch_after(completiondelay...

node.js - Why isn't my Hubot script running? -

my coffeescript , npm experience pretty limited, still can't life of me figure out i'm doing wrong. i've forked github's hubot , configured it, , launched on heroku tied in our slack account. works great, no problems. forked existing script, hubot-pugme different script modified , installed, , works great. but i'm running problem on next script; it's intended take standard command, xml feed, parse through , return of results. works fine command line, , when run on local machine, when publish heroku don't errors, trigger doesn't anything. my best guess wrong i'm somehow indicating 1 dependency, xml2jx incorrectly, heroku isn't building in. if familiar building scripts hubot has minute @ have here, appreciate it. full code script @ https://github.com/amsoell/hubot-nowplaying

matlab - How do I save an image generated by imshow(image) into a variable? -

this code. want save image displayed on imshow(img) variable use later. thanks! img=imread('image1.bmp'); figure(1), imshow(img); [r c]=ginput(4); bw=roipoly(img,r,c); % figure,imshow(bw) [r c]=size(bw); i=1:r j=1:c if bw(i,j)==1 img(i,j)=img(i,j); else img(i,j)=0; end end end figure, imshow(img); title ('output image'); you can use classic getframe / cdata idiom. figure window open, this: figure; imshow(img); title('output image'); h = getframe; im = h.cdata; h handle current frame open, , cdata field contains image data frame. above code stores frame image data variable called im use later. minor comment that for loop code set output bit inefficient. can vectorized , you'll notice significant speedups. this code: for i=1:r j=1:c if bw(i,j)==1 img(i,j)=img(i,j); else img(i,j)=0; end end end ... can replac...

ruby - How does Chef recipe get/retrieve parameters from databag? -

i have been trying learn chef , trying test small chef cookbook dcpromo of windows 2008 r2 server. i don't remember got 2 files originally, able working. the original dcpromo_unattend.txt.erb file was: [dcinstall] safemodeadminpassword=<%= @admin_password %> rebootoncompletion=yes replicaornewdomain=domain newdomain=forest newdomaindnsname=<%= @domain_name %> forestlevel=3 domainlevel=3 installdns=yes and default.rb had part in it: template dcpromo_file source "dcpromo_unattend.txt.erb" variables({ :admin_password => '', :domain_name => '' }) end i wasn't quite sure how pass in admin_password , domain_name parameters, hard-coded both in dcpromo_unattend.txt.erb file, and, after tweaking, able make cookbook work. now, i'd able put admin_password , domain_name values databag, tried adding: begin dcpromote = chef::databagitem.load(:dcpromote, :main) rescue chef::log.fatal("could not find ...

ios - Recording App Video Previews with QuickTime -

i have osx 10.9.5 , i'll use quicktime , imovie video preview app. when new screen recordings quicktime simulator recorded mouse arrow clicks. how remove mouse arrow recording? also, connected ios device , in quicktime clicked on new movie recording states on apple documents facetime camera appears never option play ios device. gives? click ios device? i have osx 10.9.5 that's problem ios device recording. os x 10.10 feature only. moreover, current xcode available os x 10.10. step 1 is: upgrade system. how remove mouse arrow recording i recommend using screenflow make recordings of computer screen. lets , much, more.

How can I install ruby 2.2.1 if I am on 2.2.2? -

how can install ruby 2.2.1 if i'm on 2.2.2 ... need rewind version because ruby 2.2.2 seems have having issues loading projects in terminal. rvm version management system this. https://rvm.io/ once install see faqs https://rvm.io/rvm/basics

javascript - Connection Timeout after several successful requests jQuery.ajax -

i new jquery.ajax, , don't know what's wrong code. title states, i'm having problems accessing site created after several successful requests. can't seem find the solution here. hope can me. here's js code: $(document).ready(function(){ async(); fetch(); }); function fetch(){ settimeout(function(){ fetch(); async(); }, 5000); } function async(){ $.ajax({ type: 'get', url: 'message.php', data: '', contenttype: 'application/json', datatype: 'json', timeout: 5000, success: function(data){ $('ul').children().remove(); $.each(data, function(index, item){ $('#lstip').append('<li>'+item.ip+'</li>'); $('#lstmsg').append('<li>'+item.message+'</li>'); $('#lstlike').append('<li><a href="message.php?like='+item.line+'...

unity3d - Unity2D C# - Can't destroy an Instantiated object -

public class playerattack : monobehaviour { public bool attacking = false; public transform player; public transform swordobject_prefab; animator anim; gameobject clone = null; // use initialization void start () { anim = getcomponent<animator> (); } // update called once per frame void update () { if (!attacking && !anim.getbool ("isswimming")) attackcode (); if (attacking) cooldown (); } void attackcode(){ if (input.getbuttondown ("attacka")) { debug.log ("attack_a"); anim.setbool ("isattackinga", true); attacking = true; clone = (gameobject)instantiate(swordobject_prefab, player.position, quaternion.identity); destroy(clone); } if (input.getbuttondown ("attackb")) { anim.setbool ("isattackingb", true); } } void cooldown(){ if (!anim.getcurrentanimatorstateinfo(0).isname ("swordswing")) {...

r - Data Preparation for Metaanalysis - using Metafor -

in order calculate effect sizes , run meta-analysis dichotomous predictor of continuous outcome ( d or g ), dataframe consisting of mean's, sd's, , sample size each study required. i trying write code create required dataframe raw data. mean process not have completed manually each study. example raw dataset study <- c("andrew", "andrew", "andrew", "andrew", "peters", "peters", "peters", "jess", "jess", "jess") score = c(100, 308, 584, 241, 241, 111, 431, 123, 321, 411) sex = c(1, 1, 1, 2, 2, 1, 2, 2, 1, 1) data = cbind(score, sex, study) data > score sex study > [1,] "100" "1" "andrew" > [2,] "308" "1" "andrew" > [3,] "584" "1" "andrew" > [4,] "241" "2" "andrew" > [5,] "241" "2" "peters...

arrays - Nil errors in creating a hash in Ruby on Rails -

i'm running several syntax , nil issues when trying create hash idea_benefit_count . @idea = @domain.ideas @idea_evaluations = array.new() @idea.each |idea| @idea_evaluations << idea.evaluations end @idea_benefit = [] if !@idea_evaluations.nil? @idea_evaluations.each |eval| @idea_benefit << eval.benefit end @idea_benefit_count = hash.new(0) @idea_benefit.flatten.each { |idea_benefit| @idea_benefit_count[idea_benefit] += 1 } end an idea has_many domains , @idea should of ideas has given @domain . @idea_evaluations array of evaluations belong_to specific idea . @idea_benefit array of arrays holds of each evaluation's benefit entries. example output: [["happier_customers"], ["happier_employees"], ["happier_employees", "decreased_costs"], ["happier_employees"]] idea_benefit_count reads idea_benefit , counts how many of each type of benefit idea has. output of idea_benefit_count bas...

javascript - text of input field is not printing while print using window.print() -

i have following html layout: please fill form carefully: <input type="button" onclick="printdiv('print'); return false;" value="print" /> <div id="print"> <form action="" method="post"> <input type="text" name="user_name" value="" /> <input type="text" name="address" value="" /> <input type="text" name="date" value="14-06-2015" /> <input type="submit" value="submit" /> </form> </div> and printdiv('print') function in head section of html page: function printdiv(divname) { var printcontents = document.getelementbyid(divname).innerhtml; var originalcontents = document.body.innerhtml; document.body.innerhtml = printcontents; window.print(); document.body.innerhtml = originalcontents; } but while printing fo...

multiline input in a terminal Go application -

i need let user input multiline text console. here code: package main import ( "bufio" "fmt" "os" ) func main() { { fmt.println("how read lines here?") in := bufio.newreader(os.stdin) result, err := in.readstring('\n') if err != nil { fmt.println(err) } fmt.println("\nresult") fmt.println(result) } } i pasted in console: hello world it outputs: how read lines here? hello world result how read lines here? result hello how read lines here? result world how read lines here? result how read lines here? but expect be: how read lines here? hello world result how read lines here? result hello world how read lines here? i guess need use eof instead of '\n...

java - SimpleDateFormat shows wrong value for day of the extracted date -

i trying separately extract date , time datetime string code shows wrong date. code string datetime= "2015-12-10t14:00:00"; simpledateformat frm1 = new simpledateformat("yyyy-mm-dd't'hh:mm:ss"); date date = frm1.parse(datetime); simpledateformat frm2 = new simpledateformat("dd/mm/yyyy"); string date1 = frm2.format(date); system.err.println(date1); simpledateformat frm3 = new simpledateformat("hh:mm"); string time = frm3.format(date); system.err.println(time); output 28/12/2015 14:00 try code refer here string datetime= "2015-12-10t14:00:00"; simpledateformat frm1 = new simpledateformat("yyyy-mm-dd't'hh:mm:ss"); date date = frm1.parse(datetime); simpledateformat frm2 = new simpledateformat("dd/mm/yyyy"); string date1 = frm2.format(date); system.err.println(date1); simpledateformat frm3 = new simpl...

Xml in python with unbalanced/uneven elements/tags -

i have xml file uneven/unbalanced elements/fields, means there </> not <> . example (for simplicity, copied part of xml file): <mytag> text1 text2 <no_open/> text3 text4 </mytag> now, want have python programs reads xml file , print tag values follow: text1 text2 text3 text4 however, because of uneven element <no_open/> it prints following , ignore rests: text1 text2 now, should solution if want python ignore no_open , prints desired output. appreciated. update: here code: open('test.xml', "r") fp: tree = elementtree.parse(fp) root = tree.getroot() release_data = root[0].text tag in root.iter('tag0'): c in tag: print c.text and test.xml is: <tag0> <mytag> text1 text2 <no_open/> text3 text4 </mytag> </tag0> you can try way : tree = elementtree....

PHP - mysqli :Count if database returned any record -

i trying query database on basis of given username. if username matches want return true , following code <?php function user_exists($username){ $username= sanetize($username); $query= mysqli_query($connect, "select count('user_id') users username= '$username'"); if(mysqli_num_rows($query)>0){ return true; } } problem when try not show result , alex dummy entry in db should not echo user exists ? if(user_exists('alex')){ echo 'exists'; } this may work after removing single quotes column name ‛user_id‛ $query= mysqli_query($connect, "select count(user_id) users username= '$username'"); further more http://www.w3schools.com/php/func_mysqli_num_rows.asp edit: first of make sure $connect available function scope before anything $query = mysqli_query($connect, "select count(*) `users` username='".$username."'");...

javascript - Bootstrap table in div horizontal scroll not work -

Image
in content, put div table inside. need scroll horizontally. i've spent hours researching , trying solutions. <div style="width:100%; overflow: scroll;"> <table style="width:2000px;"> <tr> <td>very large width table scroll horizontal</td> <td>x</td> <td>x</td> <td>x</td> </tr> </table> </div> since using bootstrap,instead of using styles use inbuilt classes. <div class="table table-responsive"> <table > //give width styling want. <tr> <td>very large width table scroll horizontal</td> <td>x</td> <td>x</td> <td>x</td> </tr> </table> </div> this give horizontal scrollbar.

java - Is this a correct JSON format {"coord":{"lat":37.4056,"lon":-122.0775}} -

this question has answer here: how check whether given string valid json in java 10 answers i understand correct json format like: {"coord":[{"lat":37.4056,"lon":-122.0775}]} but have data coming me in format {"coord":{"lat":37.4056,"lon":-122.0775}} if correct json format, how parse in java? in json {} brackets indicates object, while [] ones indicates array. your first example contains array 1 object containing lat , lon properties, object accessed data.coord[0].lat . second example object containing object lat , lon properties. is, no array, object. object accessed data.coord.lat . both correct json. you pretty parse them same way, different types (the object or array under coord ). // parse: jsonobject obj = new jsonobject(jsondatastring); // fetching object: jsonobj...

java - JavaScript error in Parameterized query -

here trying (for on day :( user clicks on link of book name , read name of book. take book name , make ajax request jersey resource. within jersey resource, call method in pojo class 1 method interacts database , gets data sent jersey resource. have got many errors have been able fix them 1 @ time. error stuck @ is: you have error in sql syntax; check manual corresponds mysql server version right syntax use near '?' @ line 1 here javascript code: function dealwithdata(nameofbook){ var bookname = encodeuri(nameofbook); console.log("http://localhost:8080/library/rest/books/allbooks/"+bookname); var requestdata = { "contenttype": "application/json", "datatype": "text", "type": "get", "url": "http://localhost:8080/library/rest/books/allbooks/"+bookname **//beforesend has been added edit original co...

scala - scalacache memoization asynchronous refresh -

i'd ttl based memoization active refresh asynchronously in scala. scalacache example in documentation allows ttl based memoization follows: import scalacache._ import memoization._ implicit val scalacache = scalacache(new mycache()) def getuser(id: int): user = memoize(60 seconds) { // db lookup here... user(id, s"user${id}") } curious whether db lookup gets triggered after ttl expires existing value, synchronously , lazily during next getuser invocation, or if refresh happens aggressively , asynchronously - before next getuser call. if scalacache implementation synchronous, there alternate library provides ability refresh cache actively , asynchronously ? expiration , refresh closely related different mechanisms. expired entry considered stale , cannot used, must discarded , refetched. entry eligible being refreshed means content still valid use, data should refetched may out of date. guava provides these ttl policies under names expireafterwri...

Laravel 5 : [Call to a member function getAction() on a non-object -

in controller, have route::getcurrentroute()->getaction()['as'] everything works in browser type php artisan route:list in terminal have exception [symfony\component\debug\exception\fatalerrorexception] call member function getaction() on non-object if comment line works well. seems obvious doesn't it? get current route in browser return visited route. in terminal not have such request. laravel return null when asking route visited. have check return value before calling getaction.

How to read complex data in array/JSON with PHP? -

i've been facing hard times read bunch of data in json using json_decode() function in php. need read basic data display flights dates origins , destinations. this how should be: 20 solutions found. solution# 1 sale price: brl2919.54 slice 0 ta 916 gru 2015-06-16t06:15-03:00 lim 2015-06-16t09:20-05:00 av 962 lim 2015-06-16t10:04-05:00 mia 2015-06-16t16:48-04:00 and json code: http://pastebin.com/dh16rrit when try transform , read comes null data. $data = json_decode($results, true); // $results variable json content url above echo $data['tripoption']['saletotal']; // example yes , should use print_r($a['trips']['tripoption'][0]['saletotal']) if want read data inside array,you can follows: $data = json_decode($s,true); foreach ($data['trips']['tripoption'] $item){ print_r($item['saletotal'] . "\n"); };

asp.net mvc 3 - How to redirect to view from shared folder -

httpcontext.response.redirect("~/shared/views/error.cshtml", true); this not working me and how exclude controllers , actions as can see in documentation , method trying use require arguments public void redirect(string url, bool endresponse) and first argument url of page user should redirected, while passing view file path. in asp. mvc path *cshtml file not equal url. i suggest use redirecttoroute method instead redirecttoroute(new routevaluedictionary { controller = "error", action = "index" }) where desired view returned errorcontroller.index() action.

c# - How a variable can be recognized from button to method? -

i'm trying count number of words , characters in specific text. works fine want tidy code don't have include the see under newsummarymethod() every button, hence why have placed in it's own method. when this, doesn't count words , characters. know reason string copytext = ""; in method, that's because if don't declare string variable, syntax errors in button copytext not declared. my question how can newsummarymethod know needs communication copytext in first vowels button? have button copytext may behave bit differently think need button communicate method. private void newsummarymethod() { string copytext = ""; /*count number of lines in processed text, line counted -1 brings correct number*/ int numlines = copytext.split('\n').length - 1; //seperate characters in order find words char[] seperator = (" " + nl).tochararray(); //number of words, characters , include line breaks...

javascript - Chrome extension messaging with XMLhttprequest object fires more then once -

im developing chrome extension (developer tool) , injection code directly in website: (function (send) { xmlhttprequest.prototype.send = function (method, url, async) { send.call(this, method, url, false); document.dispatchevent(new customevent('data', { detail: { data_1: 'hello world' } })); }; })(xmlhttprequest.prototype.send); this code listens requests websites , sends message (through content script) message script. problem messages pile up. on first request 1 message, on second 2 messages resulting in 3 messages total, 6 , on. why pile way? the message goes through "content" script: document.addeventlistener('data_2', function(e) { sendobjecttodevtools({data_3: e.detail.data_1 }); }); and received "message" script: port.onmessage.addlistener(function(message) { ... if (message.data_3) { //do stuff ... ps. not iframe problem or scri...

javascript - jquery navigation scroll up on slide, not working -

any 1 have solution me why not working? websites let navigation disappear on slide down , show whe toggle up, in case tried insert script, , tried not effect html code , use have, nothing works. script- <script> var previousscroll = 0, headerorgoffset = $('#header').offset().top; $('target').height($('#header').height()); $(window).scroll(function() { var currentscroll = $(this).scrolltop(); console.log(currentscroll + " , " + previousscroll + " , " + headerorgoffset); if(currentscroll > headerorgoffset) { if (currentscroll > previousscroll) { $('#header').fadeout(); } else { $('#header').fadein(); $('#header').addclass('fixed'); } } else { $('#header').removeclass('fixed'); } previousscroll = currentscroll; }); </script> the html- <nav class="navi" id="...

spring - How to have WRO answer with a http 304 not modified? -

we serving javascript resources (and others) via wro in our webapp. on prod environment, browser gets (for example) app.js angular webapp's content 'expires' headers 1 year in future. meaning subsequent requests browser takes cache without request server. if deploy new version of webapp, browser not new version, takes local cache. the goal configure wro or/and spring headers correctly set have browser perform request each time, , server return 304 not modified. have clients automatically "updated" uppon new deployment. did achieve this? we use spring's java configuration: @configuration public class wro4jconfiguration { @value("${app.webapp.web.minimize}") private string minimize; @value("${app.webapp.web.disablecache}") private string disablecache; @autowired private environment env; @bean(name = "wrofilter") public wrofilter wrofilter() { configurablewrofilter filter = new configurablewrofilter(); filt...

sip - How Kamailio transformations work? -

why kamailio isn't set all headers properly? kamailio route excerpt: route[pstn] { ... # set user $fu = "+34687xxxxxx"; # set info headers append_hf("remote-party-id: <$fu>\r\n"); append_hf("p-preferred-identity: <$fu>\r\n"); ... } ngrep result of invite: u xxx.xxx.xxx.xxx:5060 -> xxx.xxx.xxx.xxx:5060 invite sip:+34951xxxxxx@xxx.xxx.xxx.xxx;transport=udp sip/2.0. record-route: <sip:xxx.xxx.xxx.xxx;lr>. via: sip/2.0/udp xxx.xxx.xxx.xxx;branch=z9hg4bke235.4728a380ee70fc55cc0cecbb7919bee5.0. via: sip/2.0/udp xxx.xxx.xxx.xxx:38293;rport=38293;branch=z9hg4bk-d8754z-34c6ee584c5f95cd-1---d8754z-. max-forwards: 69. contact: <sip:javier.valencia@xxx.xxx.xxx.xxx:38293;transport=udp>. to: <sip:951xxxxxx@xxx.xxx.xxx.xxx;transport=udp>. from: <sip:+34687xxxxxx@xxx.xxx.xxx.xxx;transport=udp>;tag=666b4350. call-id: mgy2odbkzjq4owi3zwfmn2zinwqwyzhizwi5zmrkyzk.. cseq: 2 invite. allow: invi...

statistics - Calculate how a value differs from the average of values using the Gaussian Kernel Density (Python) -

Image
i use code calculate gaussian kernel density on values from random import randint x_grid=[] in range(1000): x_grid.append(randint(0,4)) print (x_grid) this code calculate gaussian kernel density from statsmodels.nonparametric.kde import kdeunivariate import matplotlib.pyplot plt def kde_statsmodels_u(x, x_grid, bandwidth=0.2, **kwargs): """univariate kernel density estimation statsmodels""" kde = kdeunivariate(x) kde.fit(bw=bandwidth, **kwargs) return kde.evaluate(x_grid) import numpy np scipy.stats.distributions import norm # grid we'll use plotting random import randint x_grid=[] in range(1000): x_grid.append(randint(0,4)) print (x_grid) # draw points bimodal distribution in 1d np.random.seed(0) x = np.concatenate([norm(-1, 1.).rvs(400), norm(1, 0.3).rvs(100)]) pdf_true = (0.8 * norm(-1, 1).pdf(x_grid) + 0.2 * norm(1, 0.3).pdf(x_grid)) # plot 3 kernel density estimates fig, ax = ...