Posts

javascript - How to run script in Firefox when a tab was closed? -

at our company using web application shared licenses. unfortunately if closes tab application running in wont release license lock. wondering whether possible run/trigger scipt when firefox tab closed, automatically release licenses? think greasemonkey might able this, haven't found solution yet. there both window.onbeforeunload , window.onunload , used differently depending on browser. can assing them either setting window properties functions, or using .addeventlistener : window.onbeforeunload = function(){ // } // or window.addeventlistener("beforeunload", function(e){ // }, false); usually, onbeforeunload used if need stop user leaving page (ex. user working on unsaved data, he/she should save before leaving).

python - DISTINCT ON in django -

this question has answer here: retrieving distinct records based on column on django 1 answer how following query: ordernotes.objects.filter(item=item).distinct('shared_note') basically, need ordernotes items, distinct on shared_note . when try , get: raise notimplementederror('distinct on fields not supported database backend') notimplementederror: distinct on fields not supported database backend i using mysql , cannot change db here. workaround in django? ordernotes.objects.filter(item=item).values_list('shared_note', flat=true).distinct()

android - How efficient in terms of speed is a Filterable custom ArrayAdapter? -

i need search varchar column of sqlite database word app , show results in listview. i'm using mensa library mensa github link because of speed offers very long texts. in project i've used filterable alongwith custom arrayadapter filters listitems based on text matching. wondering whether replace mensa usage filterable approach without compromising on search efficiency because mensa library increases apk size 3.37 mb i've checked jar file of mensa library, , big because include animal.keywords testing database inside jar. rename mensa-1.0.1.jar mensa-1.0.1.zip , , open archive manager. navigate com/dell/mensa/testutils/ , delete animals.keywords file. rename mensa-1.0.1.jar , , continue using it. file should 104.5 kb now.

Azure Web App Performance Test -

noticed performance test feature on azure web apps. appreciate if can clarification on below: is possible test multiple pages? possible specify page s test? possible test login state of user performance test including backend api call etc? each test test on single url. can specify url test. only http requests can made tests. if api calls depend on tokens in url only, can tested feature.

c# - Cast expression failure on Generic -

Image
apologize in advance, such trivial question confused i have class hierarchy follows namespace mynamespace { public class classa {} public class typea<a> : classa { public p1 { get; set; } } public class subtypea<a> : typea<a> : classa { public typea<a> p2 { get; set; } public void foo() { var x = new typea<classa>(); var y = (typea<classa>) p2; } } } why can't c# cast p2 typea<classa> while p2 instance of typea<a> a of type classa ? thanks you're looking covariance , isn't supported on classes, in interfaces , delegates. design interface follows: public interface itypea<out a> : classa { p1 { get; } } public class classa { } public class typea<a> : itypea<a> : classa { public p1 { get; set; } } public class subtypea<a> : type...

php - Rewrite URL by variables -

i have search form with: 1) search (all time set - it's select form selected='true') 2) input (with accept a-z,a-z,0-9) 3) , other 2 select form first you can search 3 (except point 2) , want rewrite url 3 variables. when have variables rewrite looks like: rewriterule ^servers/([a-z-]+)/([a-za-z0-9-]+)/([a-z-]+)/([a-z-]+)/?$ servers.php?query=$1&matching=$2&playing=$3&location=$4 [nc,l] i tried rewriterule ^servers/([a-z-]+)/([a-z-]+)/([a-z-]+)/?$ servers.php?query=$1&playing=$2&location=$3 [nc,l] but doesn't work. can me ? <?php if(isset($_post['searchservers'])){ $okgame = 0; $oklocation = 0; //search type filter switch($_post['searchtype']){ case 'nameorip': case 'map': $query = $_post['searchtype']; break; default: $query = "nameorip"; break; } // sentence filter if(isset($_p...

rest - Should response Content-Type always be same as Accept? -

i have resource original version of entity format , later, improved version breaking changes. the caller opts later versions using accept header. pretend moment service returns json. should response application/json or format in accept header? care if cheat? for example, or bad: client request: get /people/1; accept: application/vnd.personv2+json server response: 200 { "name": "john" }; content-type: application/json the server has presented v2 person format using json, has said "just" normal application json, opposed saying format requested. no, accept marks sort of content endpoint can handle. can endpoint deal json? xml? img? html? etc... more formally: the accept request-header field can used specify media types acceptable response. accept headers can used indicate request limited small set of desired types, in case of request in-line image. the content-type response has in payload in order request initiator kno...