Posts

Showing posts from June, 2015

java - The filename, directory name or volume label syntax is incorrect - Kotlin - Maven -

Image
i error when start packaged jar. when run ide not give error , run. java.io.filenotfoundexception: file:\c:\development\kotlin\accounttool\target\accounttool-1.0-snapshot-jar-with-dependencies.jar!\accounts.json (the filename, directory name or volume label syntax incorrect) @ java.io.fileinputstream.open0(native method) @ java.io.fileinputstream.open(unknown source) @ java.io.fileinputstream.<init>(unknown source) @ java.io.fileinputstream.<init>(unknown source) @ java.io.filereader.<init>(unknown source) @ com.martacus.accounttool.toolview$handler.readdata(tool.kt:41) @ com.martacus.accounttool.toolview.<init>(tool.kt:56) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(unknown source) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(unknown source) @ java.lang.reflect.constructor.newinstance(unknown source) @ java.lan

c++ - SDL2 joystick event not triggering -

so i've got code: void engine::run() { // initialize components if (sdl_init(sdl_init_video | sdl_init_joystick)) throw exception("couldn't initialize sdl\n" + string(sdl_geterror()), 1); // other code run = true; sdl_event event; while (run) { // other code uint32 timeout = sdl_getticks() + 50; while (sdl_pollevent(&event) && timeout - sdl_getticks() > 0) handleevent(event); } } void engine::handleevent(const sdl_event& event) { switch (event.type) { case sdl_keydown: inputsys->keydownevent(event.key); break; case sdl_keyup: inputsys->keyupevent(event.key); break; case sdl_joybuttondown: cout << "button" << endl; break; case sdl_joyhatmotion: cout << "hat" << endl; break; case sdl_joyaxismotion: cout << "axis&quo

java - Play Framework 2.5.4 Async Hibernate operations -

how can use akka perform operation on db using hibernate , not block web client? update: turns out error caused dao.get() method. changed start() method take actual object , not id database , no error, nothing happening(it gets stuck on em.merge() said). public completionstage<result> start(someobject object) { executioncontext ec = akka.system().dispatchers().lookup("akka.actor.db-context"); return completablefuture.supplyasync(() -> dostuff(object), play.libs.concurrent.httpexecution.fromthread(ec)) .thenapply(i -> ok("got result: " + i)); } outdated: if try like: @transactional public completionstage<result> start(long id) { executioncontext ec = akka.system().dispatchers().lookup("akka.actor.db-context"); return completablefuture.supplyasync(() -> dostuff(dao.get(id)), play.libs.concurrent.httpexecution.fromthread(ec)) .thenapply(i -> ok("got result: " + i)); }

javascript - Cant change JS slider to Angular directive -

i have problem change slider angular. here code works: <div id="main-img" class="main-img"> <img id="img" src="image.jpg"> </div> <div id="thumb-img" class="thumb-img" > <img src='image.jpg' onclick='changeimage("image.jpg");'> <img src='image1.jpg' onclick='changeimage("image1.jpg");'> </div> <script> function changeimage(a) { document.getelementbyid("img").src=a; } </script> and when need angular change , not working: <div id="main-img" class="main-img"> <img id="img" ng-src="{{some.image1}}"> </div> <div id="thumb-img" class="thumb-img" > <img ng-src='{{some.image1}}' ng-click='changeimage("{{some.image1}}");'> <img ng-sr

android - On publish getting multiple same requests pubnubv4 rails -

i have rails app api based using pub-nub v4. same client side(ios/android) using pub-nub. here steps doing: 1) on create object subscribing 2 channel's , creating listener.here.at same time on client end subscribing 2 channel's on basis of object id. 2) publish ios end same channels creating multiple requests @ web end.so multiple db entries going create. here code sample of subscribing , unsubscribing. $pubnub.add_listener("broadcast_#{broadcast.id.to_s}") $pubnub.subscribe("broadcast_#{broadcast.id.to_s},broadcastlikes_#{broadcast.id.to_s}") $pubnub.publish("broadcast_#{self.id.to_s}", { type: "stopbroadcast", text: text }) $pubnub.remove_listener("broadcast_#{self.id.to_s}") $pubnub.unsubscribe("broadcast_#{self.id.to_s}, broadcastlikes_#{self.id.to_s}") anyone can me! a collection of answers comments: if need send messages clients server, why not post them? doing subscribing server re

git clone gets the older version of the repo -

i trying clone repo updated git clone --recursive <url> gets me non-updated version. have redmine server shows me new version, git clone not newest one. i suspect head vs. master branch conflict. tried switching nothing works. @ point quite frustrated, why happening?

asp.net - How to stream video from my server to client browser using DirectShow? -

i'm developing asp.net application that's required stream on-demand videos server client. consider using directshow kind of processing works before video transmitted on internet. following article , know can transfer video stream on network through wmasfwriter after it's processed directshow , output url client can access through windows media player . in asp.net application, want video stream played on web page of client browser such chrome . i'm not sure if output url can parsed client browser , video stream can played there directly, want ask possible? if not, steps need take achieve goal? i think can made webrtc streamer directshow filter , open stream in browser. ways wmp / vlc player require activex, that, really, dead technology now. microsoft edge not support anymore. webrtc common way today. web version of skype , lot of other apps use it.

Start PowerShell with -NoExit not working -

need launch several jobs in powershell, should in different sessions. launch one, 1 use: start-process powershell -argumentlist "-command &{get-process}","-noexit","-noprofile" but new window closes command finishes. though i'm using -noexit parameter. acording this article , this question , should work. tried block window, waiting user input, closes. while command parameters named, position still critical (see powershell.exe /?): start-process powershell -argumentlist "-noexit", "-noprofile", "-command &{get-process}"

ios - UIPinchGestureRecognizer in UIView is not working properly -

i trying zoom-in , zoom-out in uiview using uipinchgesturerecognizer . when pinch on trackpad, not recognising pinch , control not going twofingerpinch function. using following code. - (void)viewdidload { //....... uipinchgesturerecognizer *twofingerpinch = [[uipinchgesturerecognizer alloc] initwithtarget:self action:@selector(twofingerpinch:)]; [myview addgesturerecognizer:twofingerpinch]; //..... } - (void)twofingerpinch:(uipinchgesturerecognizer *)recognizer { nslog(@"pinch scale: %f", recognizer.scale); if (recognizer.scale >1.0f && recognizer.scale < 2.5f) { cgaffinetransform transform = cgaffinetransformmakescale(recognizer.scale, recognizer.scale//); myview.transform = transform; } } why not recognising pinch trackpad? there other method same? first click on option button. 2 gray spots can move using mouse or trackpad. in older versions need press shift+option

matrix - How to represent fractions in python -

i trying implement method takes matrix matrix class i've defined , returns triagonal matrix using gaussian elimination. consider following matrix: m1 = [[2, -3, -4], [-1, 4, 5], [1, -3, -4]] basically need add each row, multiple of previous row, until end matrix has 0 in places below main diagonal. following process, should have following matrix: m2 = [[2, -3, -4], [0, 5/2, 3], [0, 0, -1/5]] the problem fractions 1/3 come , wouldn't want lose precision using floats. there way represent fractions? have define special behaviour those? sake of doing myself don't want use external modules. there class want: fractions.fraction : >>> fractions import fraction >>> print(fraction(5, 6)) 5/6 fractions behave regular numbers in situations: >>> print(fraction(5, 6) + 6) 41/6 >>> print(fraction(5, 6) + fraction(1, 2)) 4/3 >>> print(fraction(5, 6) + 17.445) 18.278333333333332 the last exam

xhtml - How to properly escape quotes inside html attributes? -

i have drop down on web page breaking when value string contains quote. the value "asd in dom appears empty string. i have tried every way know escape string no avail. <option value=""asd">test</option> <option value="\"asd">test</option> <option value="&quot;asd">test</option> <option value="&#34;asd">test</option> any idea how render on page postback message contains correct value? &quot; correct way, third of tests: <option value="&quot;asd">test</option> you can see working in jsfiddle example here . alternatively, can delimit attribute value single quotes: <option value='"asd'>test</option>

ms word - how to setup an AbstractNumbering for bulleted Lists -

i want generate unordered lists in word document docx4j . can give me example of abstractnumbering bulleted lists? public void setabstractnumbering(){ try { numberingdefinitionspart ndp = new numberingdefinitionspart(); myword.addtargetpart(ndp); numbering.abstractnum abstractnum = factory.createnumberingabstractnum(); abstractnum.setabstractnumid(biginteger.valueof(1)); numbering.abstractnum.multileveltype multileveltype = new numbering.abstractnum.multileveltype(); abstractnum.setmultileveltype(multileveltype); multileveltype.setval("singlelevel"); lvl lvl = factory.createlvl(); abstractnum.getlvl().add(lvl); lvl.setilvl(biginteger.valueof(0)); lvl.start start = new lvl.start(); lvl.setstart(start); start.setval(biginteger.valueof(1)); numfmt numfmt = factory.createnumfmt(); lvl.setnumfmt(numfmt); numfmt.setval(numberformat.bullet);

animation - How to set nativeProps inside of a react array -- React Native -

what i'm trying do i'm trying create array of animated.view elements moved setting nativeprops. i've chosen speed reasons. the problem while placing components nativeprop refs directly in render method poses no problems, refs not recognized if in array. example componentwillmount: function() { this.arrayofelements = []; this.exampleview1.nativeprops = (null : ?{ setnativeprops(props: object): void }); this.exampleview2.nativeprops = (null : ?{ setnativeprops(props: object): void }); var key1 = "example view 1" var key2 = "example view 2" this.arrayofelements.push( <animated.view key={key1} ref={(nativeprops) => { this.exampleview1.nativeprops = nativeprops }} > <shape /> </animated.view> ); this.arrayofelements.push( <animated.view key={key2} ref={(nativeprops) => { this.exampleview2.nativeprops = nativeprops }} > <shape /&g

ORACLE SQL How to implement a UNION clause but maintain the order of each SELECT -

using union clause in 2 select statements how can guarantee order of execution? example: select a.poclcdde, a.poclnpol, a.poclcdcl dtpocl a.poclcdcl in (216450, 562223, 250056, 202153, 8078) , poclcdce = 0 , pocltpsg = '01' union select a.poclcdde, a.poclnpol, a.poclcdcl dtpocl a.poclcdcl in (216450, 562223, 250056, 202153, 8078) , pocltpsg = '02' poclcdde poclnpol poclcdcl ---------- ---------- ---------- 100 1000001 202153 100 5001021 216450 100 9000386 8078 100 9900633 250056 100 9900634 250056 100 9901720 562223 100 9901763 562223 200 1000001 202153 200 5001021 216450 in case, how can g

javascript - Dojo dijit/focus does not make keyboard appear in Firefox and Edge on Surface -

i want popup touch keyboard when input field focus through java scripts call. below sample code , works fine chrome browser firefox , edge doesn't. http://jsfiddle.net/bux4b/75 <input id="foo" type="text"><br><br> <button id="newactbutton">new act button</button> require(["dojo/on", "dojo/dom", "dijit/focus", "dojo/domready!"], function(on, dom, focusutil) { var newactbutton = dom.byid("newactbutton"); on(newactbutton, "click", function(){ focusutil.focus(dom.byid("foo")); }); });

Sentry installed via docker - how to set up https? -

i've set sentry in docker . run docker run -d -i -t -p 8080:9000 --restart=always --name pb-sentry -e sentry_secret_key='key' --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp sentry . works on 8080 port ok. but need make available via https. how? you may use proxy server such nginx , forward 443 (https) 8080 -if sentry not supports directly- may use own ssl certs nginx , provide higher security. if supports directly check docs.

c# - Sqlserver.exe has stopped working -

Image
since installing visual studio 2015 update 3 have been getting below error. happens when visual studio 2015 open , happens whether running local admin or not. frequent , irritating, not seem affect work doing. code, server explorer, vs work fine bat error messages popping , microsoft error reporting taking long periods of 50% usage of cpu in process. does know how fix this? don't want spend hours trying resolve it. error message: in application event log see following: fault bucket 126419871336, type 5 event name: sqlexception64 response: not available cab id: 0 problem signature: p1: sqlservr.exe p2: 0.0.0.0 p3: 0000000000000000 p4: sqlmin.dll p5: 2015.130.1601.5 p6: 000000005724ae98 p7: -1073741819 p8: 0000000000064bb2 p9: 00000001d8d946ab p10: attached files: \?\c:\users\m_f\appdata\local\microsoft\microsoft sql server local db\instances\projectsv13\sqldump0100.mdmp \?\c:\users\m_f\appdata\local\microsoft\microsoft sql server local db\in

python - Process variables from one method to another inside one class -

guys, think how process variables 1 method inside 1 class. example : class newclas: def getportalsources(self,portal): self.connection_source=self.config.get("portal_"+portal,'sources') self.portal=portal def getconnection(self,source): self.source=source self.connection_string=self.config.get('connection',self.portal+'_'+source+'_'+'connectstring') ## connection until used above. on getconnection used self.portal variable getportalsources method. still little bit unclear me. just wondering if there other better aproach ? if so, give me tips, or examples. for example : def getportalsources(self,portal): self.connection_source=self.config.get("portal_"+portal,'sources') self.portal=portal def getconnection(source): self.connection_string=self.config.get('connection',getportalsources.portal+'_'+source+'_

java - Unchecked cast warning when return generic implementation based on Class<> argument -

i have following setup: @override public <t> optional<endpointprovider<t>> getprovider(class<t> providedclass) { if(providedclass.isassignablefrom(recommendationcategory.class)){ return optional.of((endpointprovider<t>) new recommendationcategoryprovider()); } return optional.empty(); } private class recommendationcategoryprovider implements endpointprovider<recommendationcategory> { and compiler giving me unchecked cast warning. think checking providedclass.isassignablefrom(recommendationcategory.class) prevent unchecked cast warning. is there way not have warning in setup? this way come it. won't show warnings. public static <t> endpointprovider<t> getprovider(class<t> klass) { if (klass.isassignablefrom(recommendationcategory.class)) { return new endpointwrapper<t>(klass.cast(new recommendationcategory())); } return null; } private static class endpo

java - Access denied (error 403) to Tomcat 8 Manager on CentOS 7 without prompting for login/password -

i have set-up centos 7 vps tomcat 8 serve applications institute, following this guide . can access tomcat server usual page not app manager. believe configured tomcat-users.xml , have no prompt login , password , keeps telling me "403 access denied". configured tomcat 8 on ubuntu server more 1 year ago, , worked out of box. there missed .... can't see is. here copy of tomcat-users.xml : <?xml version="1.0" encoding="utf-8"?> <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <role rolename="manager-gui"/> <user username="tomcat-xxxxxxx" password="xxxxxxxxxxxxxxx" roles="manager-gui"/> </tomcat-users> thanks ! the documentation puts both man

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot

Postgresql NOT NULL AND <> '' vs NOT NULL OR <> '' -

i have read lots difference between not null vs <>'' the best explanation found in: https://www.postgresql.org/message-id/aanlktilesutieukzcx9vc14kcifiuvfbrre-yen4k_zi@mail.gmail.com states: null means question hasn't been answered yet, there no answer, there may answer once provided can't answer empty. empty mean answer has been given , answer empty. for table working on, trying filter results valid postcodes only (postcode varchar in specific table), tried following: select postcode customer_table_1 postcode not null or postcode <> ''; however gives blank postcodes in results. breaking down ... select postcode customer_table_1 postcode not null; gives blank postcodes whereas select postcode customer_table_1 postcode <>''; only gives valid postcodes in result. therefore not null part of query isn't doing thought was. as part of more complicated query, have used: select postcode customer_ta

admin - Can't hide and add category on frontend in Prestashop 1.5 -

i'm new in prestashop , ask little help. my client uses prestashop 1.5 , deleted 1 category , add 1 new category. unfortunately don't see these changes in category block on homepage , other pages. can please me how can make these changes in admin? looked solution in category settings , in modules settings, without success. deleted cache in prestashop , in browser. can please me? thank in advance. kind regards, jan pavelka picture of backend / picture of frontend what name of category module? blockcategories or different module? if different module maybe has configuration page must edit displayed content in module blocktopmenu.

Need an efficient way to perform the given SQL query in SQL Server, stored procedure -

i have problem have create tables on basis of number of parameters passed in stored procedure follows: ----when there 1 column 'create table [dbo].['+@table_name+'] ( ['+@colname1+'] [varchar](200) ) ' ----when there 2 column 'create table [dbo].['+@table_name+'] ( ['+@colname1+'] [varchar](200), ['+@colname2+'] [varchar](200) ) ;' ----when there 3 column 'create table [dbo].['+@table_name+'] ( ['+@colname1+'] [varchar](200), ['+@colname2+'] [varchar](200), ['+@colname3+'] [varchar](200) ) ' one way know of doing is: ----when there 1 column if ((@colname1 not null , len(@colname1) !=0)) begin 'create table [dbo].['+@table_name+'] ( ['+@colname1+'] [varchar](200)

java - how to ignore the exception and continue to next value -

hi trying pass list of values google api.if api throws exceptions, comes out of loop.i need coninue next value if throws error.my code below. while (iterator.hasnext()) { object element = iterator.next(); string postcode = element.tostring().trim(); string latlongs[] = getlatlongpositions(postcode); system.out.println("latitude: " + latlongs[0] + " , longitude: " + latlongs[1]); system.out.println(postcode); } public static string[] getlatlongpositions(string address) throws exception { int responsecode = 0; string api = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + urlencoder.encode(address, "utf-8") + "&sensor=true"; url url = new url(api); httpurlconnection httpconnection = (httpurlconnection) url.openconnection(); httpconnection.connect(); responsecode = httpconnection.getresponsecode(); if (responsecode == 200) {

android - Recycler view crashed while scrolling on resume of activity -

// recycleradpater code here : public static final class viewholder extends recyclerview.viewholder { imageview ivproperty; imageview iveditproperty; imageview ivdeleteproperty; imageview ivproptranshistory; imageview ivinspectreport; textview tvmaintenreqcount; textview tvpropname; textview tvpropaddr; textview tvpropstatus; view view; public viewholder(view v) { super(v); //initialize variables ivproperty = (imageview) v.findviewbyid(r.id.ivproperty); tvpropname = (textview) v.findviewbyid(r.id.tvpropname); tvpropaddr = (textview) v.findviewbyid(r.id.tvpropaddr); tvpropstatus = (textview) v.findviewbyid(r.id.tvpropstatus); tvmaintenreqcount = (textview) v.findviewbyid(r.id.tvmaintenreqcount); iveditproperty = (imageview) v.findviewbyid(r.id.iveditproperty); ivproptranshistory = (imageview) v.findviewbyid(r.id.ivproptranshistory); ivinspectreport = (ima

angular2 routing - Cannot find module '@angular/platform/browser' -

i have created angular2 app using ng new myproject , , going bootstrap app. here boot.ts file: import {bootstrap} '@angular/platform/browser'; import {appcomponent} './app.component' import {router_providers} '@angular/router' bootstrap(appcomponent,[router_providers] ); there 2 problems in file: in first line '@angular/platform/browser' complains cannot find module '@angular/platform/browser'. and in third line import {router_providers} '@angular/router' complains that: module '"c:/users/salman/desktop/courses/internship/angular2/qminder/qminder/node_modules/@angular/router/index"' has no exported member 'router_providers'. so how can fix them? there wrong command ng new ? as of angular release candidate version 4 should import bootstrap function following module: import { bootstrap } '@angular/platform-browser-dynamic'; the router module changed in latest version of

ajax - WriteHtml Can't Work Properly in mpdf send mail with attachment in php mvc? -

i tried make pdf html mpdf library , send mail pdf file attachment.but can't. writehtml can't responced. writehtml give response : headers no-store no-chach type:html/text $mpdf = $stockmodel->getpdfobj(); $mpdf->allow_charset_conversion = true; $mpdf->charset_in = 'iso-8859-2'; //$mpdf->allow_html_optional_endtags = true; //$mpdf->restoreblockpagebreaks = true; $mpdf->useonlycorefonts = true; //$mpdf->setprotection(array('print')); $mpdf->setheader('|'.$stype.'|date '.date("d-m-y").' '); $mpdf->setfooter('www.angellogistic.in'); $mpdf->defaultheaderfontsize=7; $mpdf->defaultheaderfontstyle='b'; $mpdf->defaultheaderline=0; $mpdf->defaultfooterfontsize=7; $mpdf->defaultfooterfontstyle='bi'; $mpdf->defaultfooterline=0; $mpdf->settitle("angel logistic"); $mpdf->setauthor("angel logistic"); $mpdf->setw

java ee - JSF Controller, Service and DAO -

i'm trying used how jsf works regards accessing data (coming spring background) i'm creating simple example maintains list of users, have like <h:datatable value="#{userlistcontroller.userlist}" var="u"> <h:column>#{u.userid}</h:column> <h:column>#{u.username}</h:column> </h:datatable> then "controller" has like @named(value = "userlistcontroller") @sessionscoped public class userlistcontroller { @ejb private userlistservice userlistservice; private list<user> userlist; public list<user> getuserlist() { userlist = userlistservice.getusers(); return userlist; } } and "service" (although seems more dao) has public class userlistservice { @persistencecontext private entitymanager em; public list<user> getusers() { query query = em.createquery("select u user u"); return query.get

command line interface - How to get Sonarlint CLI output in JSON/XML format -

currently using sonar-lint cli local environment code analysis , generating output in html format, want in json/xml format can parse , further procedure. please let me know if 1 having idea it. the outputs possible sonarlint cli html report , console report. more advance usages , tracking of issues in projects, it's better use scanner have results in sonarqube server.

apache - htaccess is partially working on ip server domain -

i have ip server 23.43.53.23 , cms root folder index.jsp , second.jsp there now when apply short changes in .htaccess file : rewriteengine on <ifmodule dir_module> directoryindex second.jsp </ifmodule> then's works... but when put rewrite rule like rewriteengine on rewriterule ^second/([^/]*)/?(.*)$ second.jsp?name=$1&page=$2 and pass value http://xx.xx.xx.xx:8080/cms/second.jsp?name=en&page=ro then not working.. any clue? you cant use rewrite rule in apache tomcat use mod_jk or virtual host

r - shinydashboard does not work with uiOutput -

i setup ui in server.r more control, shinydashboard not work when defined in server.r. use method navbarpage without problems. this code works library(shiny) library(shinydashboard) ui <- dashboardpage( dashboardheader( ), dashboardsidebar(), dashboardbody() ) server <- shinyserver(function(input, output) { }) runapp(list(ui= ui, server = server)) but 1 show empty page ui <- uioutput('dash') server <- shinyserver(function(input, output) { output$dash <- renderui({ dashboardpage(dashboardheader( ), dashboardsidebar(), dashboardbody() ) }) }) runapp(list(ui= ui, server = server)) this example using navbarpage, works fine ui <- uioutput('nav') server <- shinyserver(function(input, output) { output$nav <- renderui({ navbarpage("app title", tabpanel("tab 1"),

html - Force horizontal table scrollbar -

Image
i have table within modal popup. want table expand beyond container if necessary , give horizontal scrollbar. currently, doubles height of row if needs to: i want horizontal behaviour same vertical behaviour (expand , provide scrollbar). php / html generating table: <div class="row"><div class="form-group col-md-12"> <label>history:</label> <div id="table-scroll"> <table class="table table-bordered table-condensed"> <thead> <th>date</th><th>from user</th><th>to user</th> <th>from location</th><th>to location</th><th>by</th> </thead> <tbody> <?php foreach($history $h){ ;?> <tr> <td><?=$h['date'];?></td> <td><?=$h['from

python - Django model update on fetch -

my model has field should change if it's within date range. it this: class election(models.model) start_date = models.datetimefield(verbose_name = 'start date') end_date = models.datetimefield(verbose_name = 'end date') active = models.booleanfield(default=false) def updateactive(self): = timezone.now() if self.start_date < , self.end_date > now: self.active=true else: self.active=false self.save() right now, every time query model, call updateactive() views.py . so, question is: there way call updateactive() every time fetch election object? or keeping constant updated? any idea welcome. the best method not have active field @ in model. main reason when value can generated simple calculation, should not stored in database. second reason booleanfield cannot indexed , queries involving field slow. therefore not lose doing calculation instead of doing field. best

datatable - r shiny data table sometimes does not display -

i encountered weird situation made me confused , searched while seems no same issues mine data table package. i used basic default data table in shiny app, see example: server.r library(shiny) library(dt) shinyserver(function(input, output) { output$expense_table_check<-renderdatatable({ iris }) }) ui.r library(shiny) shinyui(fluidpage( mainpanel( navlistpanel( tabpanel("dt",h1("dt"), datatableoutput("expense_table_check")) ) ) ) ) sometimes above works fine not. tried replacing datatableoutput("expense_table_check") datatableoutput('expense_table_check') , works sometimes, sometime not. i tried replacing output name expense_table_check expense_table_check2 . still cannot solve issue. suggestion or comment appreciated. i solved issues after revising code following , works time; add dt:: in front of datatable: server.r library(shiny) library(dt) shinyserver(funct

Attaching custom queryset to model via django-model-utils -

i trying define custom queryset subclass, , attach model using django-model-utils. in previous django versions (i using 1.9), passthroughmanager used accomplish following code: from model_utils.managers import passthroughmanager class fooqueryset(models.query.queryset): def my_custom_query(self): return self.filter(...) class foo(models.model): # fields go here.. objects = passthroughmanager.for_queryset_class(fooqueryset) as mentioned, turns out passthroughmanager removed in django-model-utils 2.4. use django’s built-in queryset.as_manager() and/or manager.from_queryset() utilities instead. i've tried rewrite code (sorry, if looks stupid, have couple of months of experience still doing thinks blindly meet deadlines) class fooqueryset(models.query.queryset): def my_custom_query(self): return self.filter(...) class foo(models.model): # fields go here... objects = queryset.as_manager(fooqueryset) as now, ended ty

Is it possible to install a composer package without updating the composer.json -

i want install composer package, want in environment developing purposes, don't want other developers install or see have it. what equivalent of npm install pack/age without --save in composer? i don't think there exact composer equivalent npm install without --save . one way similar result use composer's global command install package globally user: composer global require some/package this npm install -g if you've configured npm put such modules in home directory instead of in shared location. binaries available in global vendor binaries directory, on machine ~/.config/composer/vendor/bin/ . another option use composer require in project directory , revert changes composer.json , composer.lock whatever version control system use. downside of newly installed packages won't included in autoloader next time gets generated.

javascript - Create a dynamic function without eval() or Function constructor -

i have function body in string. say, str "return a+b" for function takes 2 arguments a , b . how create anonymous (or named) function string? trying make application content security policy compliant , therefore using eval , function constructor not option. apparently, can done using prototypes maybe. ideas?

Can I find Instagram Stories using the Public API? -

released here: http://blog.instagram.com/post/148348940287/160802-stories no note of stories being available via api. there no public api, can story json data going instagram.com login account , paste code in console, output data in console var xhttp = new xmlhttprequest(); xhttp.onreadystatechange = function() { if (xhttp.readystate == 4 && xhttp.status == 200) { console.log(xhttp.responsetext); } }; xhttp.open("get", "https://i.instagram.com/api/v1/feed/reels_tray/", true); xhttp.send(); (you have instagram.com , user logged in)

javascript - d3 - unable to add select/option drop down to svg-g element -

i intending add circle pack, radio , drop down menu svg , toggle between these (on same svg). i wasn't able add select/option dropdown menu svg created width/height of 600/600. in element console, able see g -element , drop down select option. on screen, g#menu has 0x0 size? why so? pointers/inputs? note: here trying add dropdown menu dynamically using d3.js instead of hardcoding selectio/option or div in body element. enable toggling between different views. var svg1 = d3.select("body") .append("svg") .attr("width", 600) .attr("height", 600) .append("g") .attr("transform", "translate(0,0)")); var buttonnames = ["button 1", "button 2", "button 3", "button 4"]; var menug = svg1.append("g") .attr("id","menug") .attr("transf