Posts

Showing posts from May, 2015

c++ - Is it safe to cast away const if never call any non-const methods -

is still undefined behavior cast away const pointer object if const methods ever called after cast? i'm trying implement both iterator , const_iterator class dereferenced iterator proxy object small amount of state , pointer parent object (simplified below) although const qualified proxy calls const methods on parent still requires non-const pointer in constructor. class query { public: int (int r, int c) const; void set (int r, int c, int v); class iterator { iterator (query *q, int r) : m_qry(q), m_row(r) {} row operator* const () { return row(m_qry, m_row); } query *m_qry; int m_row; }; class const_iterator { const_iterator (const query *q, int r) : m_qry(q), m_row(r) {} const row operator* const () { // protected constructor row needs cast return row(const_cast<query *>(m_qry), m_row); } const query *m_qry; int m_row; ...

php - How to simplify an API without sacrificing Dependency Injection? -

let's have rectangle class. use i'd do: $rectangle = new rectangle( 100, 50, new color('#ff0000') ); however public api, want simplify end-users as possible. preferably accept hex string: $rectangle = new rectangle( 100, 50, '#ff0000'); the problem need instantiate color object inside rectangle class class rectangle { protected $width; protected $height; protected $fillcolor; function __construct( $width, $height, $fillcolor ){ $this->width = $width; $this->height = $height; $this->fillcolor = new color( $fillcolor ); } } having learned dependency injection considered bad. or it? what's best approach? i use factory class, accepts array (possibly) of arguments , returns ready instantiated rectangle object. there many possibilities how that, depending on design , api specification. class myapifactory { public function createrectangle($params) { // checks of para...

javascript - d3.js - how to actualize the graph data? transition? -

i trying learn d3.js (with no javascript background) created simple scatter plot . now, looking how render graph random data, each time user click on next button. in link above, there tried far. i know it's newbie question , there thousands of example looking explained solution (not code). thanks ps: please change external ressource this if graphs won't show up.

How to Convert Table Into Columns R -

how convert datatables columns, example: ab cd ef jk lm x 6 0 5 0 0 y 0 7 0 0 0 z 0 0 8 0 0 0 0 0 9 0 b 0 0 0 6 10 to v1 v2 x ab 6 x ef 5 y cd 7 z ef 8 jk 9 b lm 10 b jk 6 one option convert 'data.frame' 'matrix', melt it, , subset 'value' not '0'. library(reshape2) subset(melt(as.matrix(df1)), value!=0) or library(dplyr) library(tidyr) add_rownames(df1, 'rn') %>% gather(v1, v2, -rn) %>% filter(v2!=0)

python - Django login does nothing -

i'm using django's pre-packaged login, , reason, refreshes page, without login in, , without giving me of messages have set in view. here html: <div class="col-md-9 col-md-offset-2" style="background-color: white; margin-top:10px; border-radius: 8px;"> {% if message %} <b>{{message}}</b> {% endif %} <form id="form" method="post" action="">{% csrf_token %} <table>{{form}}</table> <div class="col-lg-9 col-lg-offset-2"> <button type="submit" class="btn btn-primary">submit</button> </div> </form> </div> here url: url(r'^login', 'users.views.login', name='login'), and here view: from django.shortcuts import render deck1.models impo...

javascript - How can I bring a circle to the front with d3? -

first of all, using d3.js display different sized circles in arrays. on mouse over, want circle being moused on become bigger, can do, have no idea how bring front. currently, once it's rendered, it's hidden behind multiple other circles. how can fix this? here's code sample: .on("mouseover", function() { d3.select(this).attr("r", function(d) { return 100; }) }) i tried using sort , order methods, didn't work. i'm pretty sure didn't correctly. thoughts? you have change order of object , make circle mouseover being last element added. can see here: https://gist.github.com/3922684 , suggested nautat , have define following before main script: d3.selection.prototype.movetofront = function() { return this.each(function(){ this.parentnode.appendchild(this); }); }; then have call movetofront function on object (say circles ) on mouseover: circles.on("mouseover",function(){ var sel = d3.select...

Difficulty creating proper RavenDB query -

i trying implement logic below in ravendb query, receive system.notsupportedexception: not understand expression related scores.any expression. understand why is, i'm having hard time coming working option. public iravenqueryable<person> apply(iravenqueryable<person> query) { var scores = new list<string>(); if (_a) scores.add("a"); if (_b) scores.add("b"); if (_c) scores.add("c"); if (_u) { scores.add(""); scores.add(" "); scores.add("\t"); scores.add(null); } return p in query scores.any(score => score == p.score) select p; } the trick ravendb linq provider isn't operating on list scores.any() makes 0 sense -- compiles can see dies @ runtime. the trick reverse field bit , ask if p.score in array of scores if recall correctly.

swift - iAd banner below tableview -

i'm creating iad programmatically in tableview application did following in appdelegate.swift wrote import iad than defined proper variable var bannerview: adbannerview! and defined properties of banner itself bannerview = adbannerview(adtype: .banner) bannerview.settranslatesautoresizingmaskintoconstraints(false) bannerview.delegate = self bannerview.hidden = true finally call in tableview controller following let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate view.addsubview(appdelegate.bannerview) with constraints let viewsdictionary = ["bannerview": appdelegate.bannerview] view.addconstraints(nslayoutconstraint.constraintswithvisualformat("h:|[bannerview]|", options: .allzeros, metrics: nil, views: viewsdictionary)) view.addconstraints(nslayoutconstraint.constraintswithvisualformat("v:|[bannerview]", options: nslayoutformatoptions.allzeros, metrics: nil, views: viewsdictionary)) however banner fixe...

xml - Java XPath Expression error -

i trying print specific node xml data file such pantone 100 example. print out attributes pantone 100 such colors , data hold unsure of how format xpath compile correctly in way pull specific pantone number i'm looking for. edit: code below outputs null xml data <inventory> <product pantone="100" blue="7.4" red="35" green="24"> </product> <product pantone="101" blue="5.4" red="3" rubine="35" purple="24"> </product> <product pantone="102" orange="5.4" purple="35" white="24"> </product> <product pantone="103" orange="5.4" purple="35" white="24"> </product> <product pantone="104" orange="5.4" purple="35" white="24"> </product> <product pantone="105" orange="5.4...

javascript - Why does ECMA script offer no integer type out of the box? -

i wondering why ecma script not support integers out of box. of course know there kind of integers (there summary in answer question: difference between floats , ints in javascript? ). still these not "real" integers. , problems floats ints pretty abundant. why not support integers , why not fixed ecma script 6? the language designed , implemented in 10 days, matter of time constraints. horses mouth : yes, there start. bignums not in cards. js had "look java" less so, java's dumb kid brother or boy-hostage sidekick. plus, had done in ten days or worse js have happened. so double default, int under hood, , bitwise ops 32-bit int (uint if use >>>). blame java. i wouldn't know why wasn't on table es2015. me seems lot of work remove boilerplate, i'd guessing. brendan eich pretty active on twitter, ask him. :)

asp.net - In Visual Studio 2015 is there a way to debug Javascript using a browser other than Internet Explorer? -

Image
the question in title: today trying new functionalities of vs2015. focused on debugging javascript direclty vs , started put breakpoints in angular code. if start debugging firefox (the same happen chrome) become empty circles , if move mouse on message symbols not loaded. way found debugging work using internet explorer. is there way bind firefox (or chrome) process allow debugging? i know can in chrome should possible in other browsers if support remote debugging. here how in chrome. in toolbar, click button dropdown of browsers debug , click "browse with...". click "add...", set program wherever chrome on machine , set arguments --remote-debugging-port=9222 . can set incognito have ignore cache not required. important! chrome cannot started before, chrome needs start fresh visual studio otherwise debugging won't work. after goto "debug" -> "attach process..." -> select chrome instance title of project or si...

python - Is there a way to automate the presentation of pandas Dataframes in an attractive manner -

Image
an important component of job presenting data tables in attractive manner. lot of work in pandas , have export excel , work on presentation in there. know of way present pandas data frames in attractive looking tables? i approach @ brandon rhodes takes in excellent pandas tutorial . uses ipython notebook, , @ beginning of notebooks, adds lines: from ipython.core.display import html css = open('style-table.css').read() + open('style-notebook.css').read() html('<style>{}</style>'.format(css)) which references files style-notebook.css , style-table.css in project directory. files (which can found on github page ) can modified like, here's like. style-notebook.css: h3 { color: white; background-color: black; padding: 0.5em; } style-table.css: body { margin: 0; font-family: helvetica; } table.dataframe { border-collapse: collapse; border: none; } table.dataframe tr { border: none; } tab...

sas - Applying cutoff to data set with IDs -

Image
i using sas , managed run proc logistic , gives me table so. classification table prob correct incorrect percentages level event non- event non- correct sensi- speci- false false event event tivity ficity pos neg j 0 33 0 328 0 9.1 100 0 90.9 . 99 0.02 33 62 266 0 26.3 100 18.9 89 0 117.9 0.04 31 162 166 2 53.5 93.9 49.4 84.3 1.2 142.3 0.06 26 209 119 7 65.1 78.8 63.7 82.1 3.2 141.5 how include ids rows of data in lib.post_201505_pred below have @ least 0.6 probability? proc logistic data=lib.post_201503 outmodel=lib.post_201503_model descending; model buyer = age tenure usage payment loyalty_card /outroc=lib.post_201503_roc; score data=lib.post_201505 out=lib.post_201505_pred outroc=lib.post_201505_roc; run; i've been readin...

php - Add attribute "on the fly" during mySQL query -

i have query looks this: select avg(round({$cohort1}/{$cohort2} * 100)) overall_average, `category`, `value`, {$cohort1},{$cohort2},`group`, `quadrant`,round({$cohort1}/{$cohort2} * 100) index_value {$table}; this doesn't quite work when include average piece. returns 1 row. need return rows. if remove average piece, returns fine, don't have average calculations. separate query in php though. however, realize need derive value of quadrant(a string) based on values of cohorts. these rules. problem have no idea how incorporate query. if (the_value > overall_average , index_value > 100) `quadrant` = "priority one" elseif (the_value < overall_average , index_value > 100) `quadrant` = "potential" elseif (the_value > overall_average , index_value < 100) `quadrant` = "basics" elseif (the_value < overall_average , index_value < 100) `quadrant` = "ignore" can me come complete query this? i'm open manipula...

install.packages - Error Installing R package 'clifro' -

i encountered following problem while installing package 'clifro'. not figure out problem here. have included tail of installation process. i have been using r studio version 0.99.441. ** r ** data ** inst ** preparing package lazy loading creating generic function ‘close’ package ‘base’ in package ‘rcurl’ ** *** installing indices ** building package indices ** testing if installed package can loaded error in dyn.load(file, dllpath = dllpath, ...) : unable load shared object '/home/sghimire/r/x86_64-pc-linux-gnu-library/3.2/rcurl/libs/rcurl.so': /usr/lib/x86_64-linux-gnu/libgssapi.so.3: symbol krb5_ntlm_init_get_challange, version heimdal_krb5_2.0 not defined in file libkrb5.so.26 link time reference error: loading failed execution halted error: loading failed * removing ‘/home/user/r/x86_64-pc-linux-gnu-library/3.2/rcurl’ warning in install.packages : installation of package ‘rcurl’ had non-zero exit status error: dependency ‘xml’ not available package ‘selec...

vba - Why does addition give type mismatch even when I cast? -

i'm performing operations between 2 blocks of data separated blank row, , need row of second block. selecting top block of data using 'selection.end(xldown)' , taking row this, , adding 2 it. since there single blank row separate blocks, should work, on line add 2 row, type mismatch despite fact i'm casting row cint before add. code in question dim col col = split(selection.address, "$")(1) dim tmp integer tmp = cint(col) + 2 the last line of causes type mismatch error. why that? what's wrong cast i'm trying? importantly, how fix it? i couldn't find encountering problem except pulling data sheet seemed different set of circumstances. the way have set, you're returning character representation of address. try this: col = selection.column which should return numeric position (in limited testing @ least)

.net - keycloack asp.net authentication -

have got keycloack idm working .net mvc. have project should make bearer token authentication on keycloack. i've been searching allover internet , there's 0 implementations on mvc. google , ms azure seems work out of box. thanks jari

javascript - Angular JS - IpCookies not working properly on localhost -

i'm using ivpusic/angular-cookie package @ moment local app. can set simple cookie one: ipcookie('force-premium', true, { expires: 1, path: '/' }); but, whenever put in domain name different null, won't work. example, wouldn't create cookie me ipcookie('force-premium', true, { expires: 1, path: '/', domain: 'localhost' }); but somehow works ipcookie('force-premium', true, { expires: 1, path: '/', domain: '' }); what problem code? need set domain name because want create domain-wide cookies have several subdomains app. hope helps: https://gitlab.isb-sib.ch/calipho/nextprot-search/commit/8d9e022f3648c5df3390389a0b2c50d53501239c?view=parallel if ($window.location.hostname === "localhost") { ipcookie('nxprofile', profile); ipcookie('nxtoken', token); } else { ipcookie('nxprofile...

android - When using toolbar and tablayout in appbarlayout, the toolbar doesnot dismiss when i scroll up -

i using view pager , fragments used in viewpager have listviews have been surrounded nested scrollviews. when scroll toolbar not dismissing. want running playstore tabs. written if recyclerview used instead of listview work fine, want use listview. this code activity: <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" andr...

java - Multiple errors while building Spring MVC project on Eclipse -

Image
problem 1 whenever seem try dynamic web applicaiton running on debugging server (apache), seem error shown below on eclipse's browser. problem 2 (this has been solved edit 2 ) in errors tab, errors shown below: edit 2 i have removed problems come in problem tab following advice on this post. apparently tomcat not support java 1.8 of yet. however, still haven't managed solve problem 1 , problem 3 , related. problem 3 and finally, console seems output this: info: @ least 1 jar scanned tlds yet contained no tlds. enable debug logging logger complete list of jars scanned no tlds found in them. skipping unneeded jars during scanning can improve startup time , jsp compilation time. aug 03, 2015 6:51:56 org.apache.catalina.core.applicationcontext log info: no spring webapplicationinitializer types detected on classpath aug 03, 2015 6:51:56 org.apache.catalina.core.standardcontext listenerstart severe: error configuring application listener of class org...

azure - No data on Application Insights -

i have application insights skd on asp.net application, can't see data on azure portal, have followed official documentation troubleshoot , connectivity dc.services.visualstudio.com seems fine can't connect f5.services.visualstudio.com, f5.services.visualstudio.com seems not used anymore, can't access inside , outside of network. account have access performance logs too, , uninstalled scom monitoring agent prevent problems, still no data! check assemblies included in project check have last sdk version of application insights installed check applicationinsights.config file exists in root of application , instrumentation key presented if resolve instrumentationkey web.config or place, debug application , ensure instrumentationkey resolved check telemetries collecting using visual studio diagnostics hub (developer mode must set true - default) try send more telemetries or change flush interval 0 first place can check telemetries azure portal - diagnostic ...

jquery - How can I get to see the full image in the background? -

i have site: link at bottom there 2 images, unfortunately these images can not seen completely. you can open original image in new tab see how looks. to me sees 90% of image code html: <div class="entry-content" style="height: 391px;"> <div class="sus"></div> <div class="jos"></div> <div class="jos2"></div> </div> code css: .sus{ width:100%; height: 60%; position:absolute; top:0; background:url("http://bagel.dg-site.com/bagel/wp-content/uploads/2015/07/banner-300x215.png") no-repeat center center #b03d3d; background-size:cover; } .jos{ width: 50%; height: 40%; position:absolute; bottom:0; background:url("http://bagel.dg-site.com/bagel/wp-content/uploads/2015/07/news2-300x246.png") no-repeat center center #b03d3d; background-size: cover; } .jos2{ width: 50%; height: 40%; position:absolute; bott...

javascript - document.createElement('img') v/s new Image()? which one to be appended to the DOM? -

so problem this(different discussed here : in mobile advertising, impression trackers, 2,3 or 4. since network bandwidth limited, want fire available trackers simultanenously, , not in waterfall manner(please don't ask me why). there code have been using: <script type="text/javascript"> var imp_1 = document.createelement("img"); imp_1.src = "tracker url 1 here"; var imp_2 = document.createelement("img"); imp_2.src = "tracker url 2 here"; var imp_3 = document.createelement("img"); imp_3.src = "tracker url 3 here"; var imp_4 = document.createelement("img"); imp_4.src = "tracker url 4 here"; </script> update of these 1x1 impression trackers pointing different servers, different attribution partners. my question : is required add above creative img vars dom? practice in scenarios? would document.body.appendchild() trick? if instead used new image() in place ...

android - When the GridView scrolls, it changes CheckBox Selections -

accualy read posts cant solution problem. , need help. i have got gridview. filling grids baseadapter. grids has got imageviews , checkboxes. longtouching grid , checking checkbox. done here. but when scroll gridview selections changing. try solution other posts can't fix problem. adapter getview method; @override public view getview(final int position, view convertview, viewgroup parent) { // todo auto-generated method stub view grid; if (convertview == null) { grid = new view(mcontext); layoutinflater inflater = (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service); grid = inflater.inflate(r.layout.mygrid, parent, false); } else { grid = (view) convertview; } imageview imageview = (imageview) grid.findviewbyid(r.id.imagepart); final checkbox ch = (checkbox)grid.findviewbyid(r.id.checkbox); ch.settag(position); hashmap<string,string> tar; tar = data.get(position)...

jquery - Add Dynamic Number Using JavaScript to CSS Map Pin -

how can add dynamic number such countdown in center of pin? codepen <div class='pin'></div> <div class='pulse'></div> @import "nib" body html height 100% body background #2f2f2f .pin width 100px height 100px border-radius 50% 50% 50% 0 background #89849b position absolute transform rotate(-45deg) left 46.4% top 42% margin -20px 0 0 -20px animation-name bounce animation-fill-mode both animation-duration 1s &:after content '' width 72px height 72px margin 14px 0 0 14px background #2f2f2f position absolute border-radius 50% .pulse background rgba(0,0,0,0.2) border-radius 50% height 14px width 14px position absolute left 50% top 50% margin 11px 0px 0px -12px transform rotatex(55deg) z-index -2 &:after content "" border-radius 50% height 40px width 40px position absolute margin -13px 0 0 -13px ani...

configuration - nginx wont restart - errors -

after trying nginx -t , service nginx restart or nginx -s reaload have found fallowing errors. idea how fix them? thank answers. nm@srv:/etc/nginx/sites-available$ nginx -s reload nginx: [alert] not open error log file: open() "/var/log/nginx/error.log" failed (13: permission denied) 2015/08/03 09:12:35 [warn] 13513#0: "user" directive makes sense if master process runs super-user privileges, ignored in /etc/nginx/nginx.conf:1 2015/08/03 09:12:35 [warn] 13513#0: conflicting server name "venusfactorfreetrial.sandbox.modpreneur.com" on 0.0.0.0:80, ignored 2015/08/03 09:12:35 [notice] 13513#0: signal process started 2015/08/03 09:12:35 [alert] 13513#0: kill(1031, 1) failed (1: operation not permitted) nm@srv:/etc/nginx/sites-available$ nginx -t nginx: [alert] not open error log file: open() "/var/log/nginx/error.log" failed (13: permission denied) 2015/08/03 09:16:02 [warn] 13565#0: "...

osx - Flexible width button not taking all available space -

Image
i'm trying make modifications layout of trackmix app shown in creating first mac app . i wanted "mute" button take 160px or less. equivalent css rule width: 100%; max-width: 160px; margin: 0 auto; . i'm not sure how achieve in interface builder or in code. here's have far while 71 pixels indeed less 160px. there way make button take available space? this working me: i have added center constraint + leading , tailing edge constraint parent container. i've set leading/tailing constraint priority 250 because need breakable.

php - Duplicate search box, not getting any search result -

i have 2 search boxes, 1 desktop , 1 mobile version. created 2 versions because of different positions on website. both has same code, mobile version not getting search results in url. desktop working version url on submit button : index.php?route=product/search&search=test mobile version url (not sending data in url) : index.php?route=product/search both of them has input : <input type="text" name="search" placeholder="<?php echo $text_search; ?>" value="<?php echo $search; ?>" /> i don't understand why mobile version not sending data. there can 2 reasons- 1st - didn't added search input inside header tag (suggested ramesh) 2nd - if 1st done, have change in common.js file responsible searching, code added $('#search input[name=\'search\']').on('keydown', function(e) { add code add class active input type, $(this).addclass('active-header-input');...

database - APEX in oracle 12c -

i've installed oracle db 12c enterprise edition. , can't find tutorial or connecting apex throught browser. should in order inside apex? need detailed answer have taken @ oracle documentation regarding installation? it's pretty straight forward , contains several scenarios: http://docs.oracle.com/database/121/htmig/overview.htm#cegegbae

javascript - PhantomJS can't use PDFJS -

i writing angular-app, uses mozilla's library pdfjs . unfortunately, when executing unit-tests of application, seems phantomjs can't find parts of pdfjs-lib. here error message: phantomjs 1.9.8 (linux 0.0.0) error typeerror: 'undefined' not function (near '...}.bind(this), rejection_ti...') @ /home/[...]/bower_components/pdfjs-dist/build/pdf.js:1222 i need use phantomjs because of ci infrastructure. your problem seems come 'bind' function. if remember correctly, phantomjs < 2.0 doesn't support bind natively, hence 'undefined not function' message. can use polyfill overcome problem, see: issue on github: https://github.com/ariya/phantomjs/issues/10522 polyfill on npm : https://www.npmjs.com/package/phantomjs-polyfill if don't want use npm, there polyfill available mdn: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/function/bind#polyfill it seems phantomjs 2.* handles corre...

ios - How to call SecItemCopyMatching in Xcode 7 beta 4? -

in previous versions of xcode 6 , 7 swift, syntax work: var secureitemvalue: unmanaged<anyobject>? let statuscode: osstatus = secitemcopymatching(keychainitemquery, &secureitemvalue) if statuscode == errsecsuccess { let opaquepointer = secureitemvalue?.toopaque() let secureitemvaluedata = unmanaged<nsdata>.fromopaque(opaquepointer!).takeunretainedvalue() // use secureitemvaluedata... } however, secitemcopymatching declaration has changed in xcode 7 beta 4: old: func secitemcopymatching(_ query: cfdictionary, _ result: unsafemutablepointer<anyobject?>) -> osstatus new: func secitemcopymatching(_ query: cfdictionary!, _ result: unsafemutablepointer<unmanaged<anyobject>?>) -> osstatus ...and secureitemvalue type not match. the mechanism confusing before extract result, , i'm hoping somehow easier new declaration, don't know how declare correct type secureitemvalue variable , ...

ios - Execute task after another -

recently started developing ios , faced problem maybe obvious couldn't figure out myself. i'm trying execute task after one, using multithreading provided gcd. this code fetching json (put in class singleton) categoriesstore - (instancetype)initprivate { self = [super init]; if (self) { [self sessionconf]; nsurlsessiondatatask *getcategories = [self.session datataskwithurl:categoriesurl completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) { if (error) { nslog(@"error - %@",error.localizeddescription); } nshttpurlresponse *httpresp = (nshttpurlresponse *) response; if (httpresp.statuscode == 200) { nserror *jsonerror; nsarray *...

Sorting standards with alphanumerical data (and special characters) with case insensivity in Java -

i have list of characters sequences. need sort them in order feels natural. i'm coding in java. initial thought use collections.sort() . think method follows ascii order separates lower case , upper case text. that's not natural flow. trying define "natural sorting" made quick search , found niso tr03-1999 standard seems address issue. so guess need way sort using algorithm defined in standard. there function in java ? or need implement myself ? is there i'm overlooking here ? did had similar issue in past ? how did deal ? here's code sample testing collections.sort(): list<string> list = new arraylist<string>(); list.add("z"); list.add("a"); list.add("z"); list.add("a"); list.add("z 1"); list.add("a 1"); list.add("z 1"); list.add("a 1"); list.add(" space"); list.add("!"); list.add("."); list.add(";"); list.add(...

html - creating divs and adding text through a javascript function -

i have set of sentences , radio buttons need display on webpage using javascript function. need create divs me visually group these sentences on webpage accordingly. have written function , can display sentences , radio buttons shown below in code below. have specified divs: var div1 = document.createelement("div"); div1.setattribute("align","left"); div1.style.border = "1px solid #ccc"; var div2 = document.createelement("div"); div2.setattribute("align","left"); div2.style.border = "1px solid #ccc"; var div3 = document.createelement("div"); div3.setattribute("align","left"); div3.style.border = "1px solid #ccc"; var div4 = document.createelement("div"); div4.setattribute("align","left"); div4.style.border = "1px solid #ccc"; var div5 = document.createelement("div"); div5.setattribute("align","...

Clear Django view cache on logout -

i'm cacheing view below: @cache_page(60 * 15) def my_view(request): # results request.user return httpresponse(json.dumps(results), content_type="application/json", status=200) how can clear cache when user logs out? you'll need define better cache key, changes on user or on user.is_authenticated. use key prefix if use redis redis allows removing keys stating prefix. key = "result_{}".format(request.user.pk) results = cache.get(key) if not results: results = ... cache.set(key, results) ...

fortran - Copying arrays: loops vs. array operations -

i work fortran quite long time have question can't find satisfying answer. if have 2 arrays , want copy 1 other: real,dimension(0:100,0:100) :: array1,array2 ... i=0,100 j=0,100 array1(i,j) = array2(i,j) enddo enddo but noticed works if that: real,dimension(0:100,0:100) :: array1,array2 ... array1 = array2 and there huge difference in computational time! (the second 1 faster!) if without loop can there problem because don't know maybe i'm not coping content memory reference? change if mathematical step like: array1 = array2*5 is there problem on different architecture (cluster server) or on different compiler (gfortran, ifort)? i have perform various computational steps on huge amounts of data computational time issue. everything @alexander_vogt said, also: do i=0,100 j=0,100 array1(i,j) = array2(i,j) enddo enddo will slower than do j=0,100 i=0,100 array1(i,j) = array2(i,j) enddo enddo (unless co...

html - Dynamically arrange colums in a table -

what trying is, have table made of divs. total 8 colums . first 8 colums in div shows heading, , rest columns shows content <div id="student-table"> <div id="student-table-header"> <div class="student-table-col-header">{label.header1}</div> <div class="student-table-col-header">{label.header2}</div> <div class="student-table-col-header">{label.header3}</div> <div class="student-table-col-header">{label.header4}</div> </div> <div id="student-table-body"> <div rv-each-studentlist="studentlist"> <div class="student-table-col-body">{studentlist.name}</div> <div class="student-table-col-body">{studentlist.age}</div> <div class="student-table-col-body">{studentlist.subject}</div> <div class="student-table-col-body">{studentlist.mark}</div> <...

javascript - Ember DRY pattern for reusing "Ember.computed.alias" -

i have form transitions through several views. each controller.js file has long list of these ember.computed.alias . how can break out 1 file , import each controller? currently in each controller.js entityemail: ember.computed.alias('controllers.checkout.entityemail'), entitydob: ember.computed.alias('controllers.checkout.entitydob'), entityphone: ember.computed.alias('controllers.checkout.entityphone'), entityaddress1: ember.computed.alias('controllers.checkout.entityaddress1'), entityaddress2: ember.computed.alias('controllers.checkout.entityaddress2'), entitycity: ember.computed.alias('controllers.checkout.entitycity'), i pull out file can import 1 liner in each controller.js this classic use-case ember.mixin . can extract these computed props single mixin , extend every controller (that needs have these props) it. add following mixin app // app/mixins/entity-form.js import ember 'ember'; const { m...

telephonymanager - Android signal strength -

is there method signal strength on both sim cards. search lot couldn't find solution. maybe there method register receiver on second sim card ? i'm working on android 5.0 , know on version android officially not support dual sim solutions. found fits me: check whether phone dual sim android dual sim signal strength second link presents way cannot use because method telephonymanager.listengemini not available any ? please note : following specific android 5.0 devices. uses hidden interface in android 5.0, , not work in earlier and later versions. in particular, subscription id changed long int when api exposed in api 22 (for should use official api anyway). for android 5.0 on htc m8, may try following signal strength of both sim cards: overriding phonestatelistener , protected internal variable long msubid . since protected variable hidden need use reflection. public class multisimlistener extends phonestatelistener { private field subidfield...

Android: how to use FragmentTransaction.add in a fragment -

so trying add fragment within fragment, told change fragment transaction variable go from: fragmenttransaction ft = fm.begintransaction(); to fragmenttransaction ft = getchildfragmentmanager().begintransaction(); however, not sure id use when call ft.add(); previously using android.r.id.content. there similar id can use fragment, or id should use able add new fragment within fragment. edit: activity_mainfrag: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#eeeeee" android:orientation="vertical"> ... </linearlayout> use add fragment: fragmenttransaction ft = getchildfragmentmanager().begint...

setting database: postgresql in django 1.8 in heroku -

i have been struggling issue whole days while no solutions @ all. post here. i trying set blog website in heroku via django 1.8 uses python 3.4.3. follows instructions heroku website here . i use "foreman start" run django project in mac , installed dependence. part of setting.py file involving database looks like: import dj_database_url databases = {} databases['default'] = dj_database_url.config() then got error: improperlyconfigured @ /settings.databases improperly configured. please supply engine value. then modify files adding 1 line supplying engine value: import dj_database_url databases = {} databases['default'] = dj_database_url.config() databases['default']['engine'] = 'django.db.backends.postgresql_psycopg2' based on this post answered or arbel, should work. got error: improperlyconfigured @ /settings.databases improperly configured. please supply name value. what should next? django project simple , n...

Better documentation for arcgisimage, basemap python -

Image
i using arcgisimage api have map layers scatterplot. however, documentation api, found here http://basemaptutorial.readthedocs.org/en/latest/backgrounds.html not good, concerning sizing of images: xpixels sets zoom of image. bigger number ask bigger image, image have more detail. when zoom bigger, xsize must bigger maintain resolution dpi image resolution @ output device. changing value change number of pixels, not zoom level the xsize mentioned not defined anywhere, , doubling dpi between 300 , 600 doesn't affect size of image. anyone have better documentation/tutorial? i learning similar things...and new it. can offer simple ideas in mind. wish you.(although seems not so. ^_^ ) following code given example of tutorial adding adjustments. (la centered) mpl_toolkits.basemap import basemap import matplotlib.pyplot plt map = basemap(llcrnrlon=-118.5,llcrnrlat=33.15,urcrnrlon=-117.15,urcrnrlat=34.5, epsg=4269) #http://server.ar...

php - SQL request error because of an integer -

Image
i have problem sql request (insert). i'm using handsontable save data in database. here grid user enters data. row "numéro pe" numeric field in database it's not required field, can empty !! as have lot of grid one, made generic function insert data. create string data : foreach($ligne $key => $elt) { $values .= '\''.$elt.'\','; if ($key == ($cptidessai-1)) { $values .= '\''.$id_essai.'\','; } } and call function string in parameters , works perfectly. but problem : row "numéro pe" numeric, request doesn't work. here warning on firebug : query failed: erreur: invalid syntax integer : « » line 2: ... essai2','test essai2_trait1','test essai2_bloc1','','',''); pb request: insert public.parcelle_elementaire(id_traitement,bloc,id_pe,id_essai,code_traitement,id_bloc,numero_pe,taille_pe,commentaires) valu...

html - Clone element when input is filled jQuery -

so, have input asking number of moviments <label for="nmoviments">&nbsp; number of moviments: &nbsp; </label> <input type="text" name="nmoviments" id="nmoviments" value="" size="1" required></td> and have div toggle form of new moviments <div id="darktheme" class="newmov" onclick="toggle4();"> + new moviment</div> it opens table form full of input fields. what i'm trying function clones new moviment div it's new respective toggle form table, according number of moviments user has entered. exemple, if user types 3, should open 3 new moviments divs. so far, have following jquery code: $(document).ready(function(){ $("#nmoviments").change(function(){ var max= $("#nmoviments").val(); for(var i=1; i<= max; i++) { $('.newmov').clone().insertafter('newmov'); ...

html - Bootstrap input group not grouping properly -

Image
i want use input group i've modified bootstrap site. this have this want this code <div class="input-group"> <input type="text" aria-label="text input segmented button dropdown" class="form-control"> <div class="input-group-btn"> <button aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button"> <span class="caret"></span> <span class="sr-only">toggle dropdown</span> </button> <ul class="dropdown-menu"> <li><a href="#">action</a></li> <li><a href="#">another action</a></li> <li><a href="#">something else here</a></li> ...

shell - Getopts with curl bash -

i have got question how connect getopts curl method in 1 function ? newbie in bash scripting. add function below: addproject() { addproject_usage() { echo "addproject: [-p <arg>]" 1>&2; exit; } read optarg local optind o p local optarg while getopts ":p:" o; case "${o}" in p) p="${optarg}" ;; *) addproject_usage ;; esac done shift $((optind-1)) curl -h "content-type:application/json" http://adress.com/api/v3/projects?private_token=$token -d "{ \"name\": \"$p\" }" } addproject -p addproject thank advice , ! dont know if right don't think . m. i think script simplified few: #!/bin/bash # addproject_usage() { echo "addproject: [-p <arg>]" 1>&2; exit; } ad...

user interface - JavaFX switching scenes with different sizes -

i testing jewelsea 's work small javafx framework , wondering how possible adapt change view between scene of different sizes ? because far know, every changed scene fits main vbox size. edit : here things i've tried sizetoscene() on main.java @override public void start(stage stage) throws exception{ stage.settitle("vista viewer"); stage.setscene( createscene( loadmainpane() ) ); stage.sizetoscene(); stage.show(); } or on maincontroller.java public void setvista(node node) { stage stage = (stage) vistaholder.getscene().getwindow(); vistaholder.getchildren().setall(node); stage.sizetoscene(); } i understand how first example isn't right since it's happening once, second ?

c++ - c# How to use the new Version Helper API -

since osversion not reliable since windows 10 has been released (this function reports windows 8 windows 10), i'm attempting use new version helper api functions in c# application. here are. i apologize if issue dll import, here attempt pull in these new methods detect os correctly. [dllimport("kernel32.dll", charset = charset.auto)] public static extern bool iswindows7orgreater(); [dllimport("kernel32.dll", charset = charset.auto)] public static extern bool iswindows8orgreater(); [dllimport("kernel32.dll", charset = charset.auto)] public static extern bool iswindows8point1orgreater(); [dllimport("kernel32.dll", charset = charset.auto)] public static extern bool iswindows10orgreater(); whenever i'm calling these methods, i'm getting: exception is: entrypointnotfoundexception - unable find entry point named 'iswindows7orgreater' in dll 'kernel32.dll'. am doing wrong? have ideas? help! edit: please ...

php - Add Image with Strip Tags or Into Form to Email Response -

i don't know strip tags may not possible. i have survey users fill out online. part of survey has question required vote on star rating. @ moment, once completed, emails through star rating number (i.e. 1 - 5). like, insert image instead of numbers, can visually show star rating selection. i'm not sure insert image strip tag? or perhaps should going in "value" on frontend? afterall, what's being called in email. any insight appreciated! front-end html side: <div class="question-sub"><p>ease of making reservation</p> </div> <span class="rating"> <input type="radio" class="rating-input" id="rating-input-1-1" name="res-ease5" value="5"> <label for="rating-input-1-1" class="rating-star"></label> <input type="radio" class="rating-input" id=...

ruby on rails - Extracting all records from a model and getting them to add them up -

i have app order , part models (an order has_many parts). i'm trying put list of outstanding parts different orders can have same parts need remove duplicates while increasing totals. i've tried few ways can't head around @ moment it seems want make has_many :through association. the idea have 3 tables ex: order part outstandingpart (example name) outstandingpart, table holds connection between orders , parts while having additional details outstanding_date etc have @ rails docs on 2.4 has_many :through association some more links here , here

php - MySQL - able to access database after deleting .frm and .ibd files -

i have mysql server running out error. accidentally removed .ibd , .frm files. server not throwing error. continue data insert , operations using command line. i found using ibdata files temporarily stored , access records. if try access records show no records found. , show no tables available 'show tables' doesn't throw error message if access using particular table name how on come scenario. if .ibd or .frm file deleted should throw error if access table. try check table my_table extended; edit: repair table tbl_name extended should bring corrupted data. please make backup of table , whole database first.

php - Code readed by Symfony differently in Controller and Command -

i'm working on symfony2 project put google analytics in database. user fills form date , checks datas want collect. when clicks on "submit", call gacontroller call command. protected function configure() { $this->setname ( 'ga2' ) ->addargument ( 'startdate', inputargument::required, 'start date (format: yyyy-mm-dd)' ) ->addargument ( 'enddate', inputargument::required, 'end date (format: yyyy-mm-dd)' ) ->addargument ( 'metrics', inputargument::required, 'metrics (format: metric,metric2,...,metricn') ->addargument ( 'dimensions', inputargument::optional, 'dimensions (format: dimension1,dimension2,...,dimensionn'); } the problem is, metrics , dimensions read controller array, , command-line string ! exemple : controller read : array (size=4) 0 => string 'ga:users' (length=8) 1 => string 'ga:newusers' (length=11) 2 => string '...