Posts

Showing posts from July, 2013

java - How to correctly store the connection settings to the database? -

i have database , connection settings it. settings (username , password) stored in .properties . file stored on the local computer software installed. please tell me how ensure data confidentiality? how correctly store connection settings? options? thanks!

node.js - npm: Where do the children dependencies come from? -

i read on github that : grunt-mocha-test uses npm's peer dependencies functionality i unsure "peer dependencies" checked npm docs , found: npm awesome package manager. in particular, handles sub-dependencies well: if package depends on request version 2 , some-other-library which take mean: having 'peer dependencies' mean dependency need other dependencies in order function correctly. npm creates tree structure, dependency root, , root dependency has children dependencies the questions left are: where children dependencies come from? copies? or references other dependencies present in package.json? each of them have copy of package. example, if have project dependencies: "dependencies": { "node-handlebars": "*", "less-file": "*", "async-ls": "*", "promise": "4.0.0" } and run npm install , have 4 copies of promise ...

javascript - Why is my SVG image blurry when using a fill pattern? -

Image
i have repeated image on page. if add manually (via d3.js), image clear, if use image fill pattern blurry. issue consistent on latest ie, ff, , chrome. is there way make fill pattern same when manually add images? js fiddle here , , code included below. svg code: <svg> <defs> <symbol id="rack"> <rect height="50" width="50" rx="5" ry="5" fill="#c9cfd6" stroke="#505356" stroke-width="3" /> <line x1="8" y1="8" x2="36" y2="40" stroke="#505356" /> <line x1="36" y1="8" x2="8" y2="40" stroke="#505356" /> </symbol> <!-- using pattern looks blurry!!! --> <pattern id="rack_pattern" patternunits="userspaceonuse" x="0" y="0...

ios - Detecting playing video inside of a WKWebView component -

with wkwebview component , ios 8, possible know if user has clicked in embedded video , has started play? you can try this solution paulo fierro.

c++ - I don't understand the object mismatch in a multithreading game -

i working on multithread game. has 3 classes : carte , map of composed of several case batiment , ship, ships fighting each others. case , basic cell of map, , may linked batiment . each thread control object of batiment, seems work great, when try output game, showing id numbers of differents threads representing batiment in map, doesn't work. instead of printing every thread, prints last batiment created in main.cpp . i stagging 3 days on it... here files : main.cpp: std::vector<batiment> batiments; for(int = 0; < nbrbatiments; i++){ //ajout des batiments sur le vecteur //batiment temp = new batiment(&carte, i); batiment temp(&carte, i); batiments.push_back(temp); } for(int = 0; < nbrbatiments; i++){ if ((rc = pthread_create(&thread[i], null, batiment::launcher, (void *)&batiments[i]))) { fprintf(stderr, "error: pthread_create, rc: %d\n", rc); return exit_failure; ...

javascript - Regex to generate currency-like formats -

i need generate currency numbers: examples: 123 -> 123 123.0 -> 123 1234 -> 1,234 1234.00 -> 1,234 12345 -> 12,345 12345.0012 -> 12,345 123456 -> 123,456 123456.02 -> 123,456 , on.. basically should trim after . including . , format rest of number. i have far restrict user enter digits. num.replace(/[^0-9]/, '') any ideas/suggestions appreciated just use number.prototype.tolocalestring() : > new number(1234.00).tolocalestring() 1,234 to limit number of decimal places 0, can use number.prototype.tofixed() well: > new number((12345.0012).tofixed(0)).tolocalestring() 12,345 0 default argument .tofixed() , can omitted if prefer. here's snippet working example: function convert() { var num = new number(document.getelementbyid("number").value); var fixed = new number(num.tofixed()); var locale = fixed.tolocalestring(); alert(locale); } <input placeholder="enter number" i...

c# - Retrieve data from SQL Server stored procedure into an array -

i'm trying data database , put array. i tried code : dataclassesdatacontext ds = new dataclassesdatacontext(); protected void page_load(object sender, eventargs e) { list<string> _news = new list<string>(); (int = 0; <= 4; i++) { _news.add(ds.select_top_five_news().elementat(i).tostring()); } } but returns nothing of want , gives me error : specified argument out of range of valid values. parameter name: index and stored procedure use: create procedure select_top_five_news return select top 5 * news order newsid desc the problem stored procedure's result returned single result , need loop into each individual record any please! or way same goal? since procedure filtering data you, should have following. procedure return 5 results, whatever you've received you're getting. if need default entities, you'll have loop on , add missing items, not pull exis...

html - Saving a specific row using PHP and a search option -

i have following program, searchs text placed in previous php file, , displays results, adding radiobox check item purchased. not able make page save item checked items found new table, don't know how that, because items found placed fetched items, therefore don't know how select 1 save entire row selected. please help!. <!doctype html> <html> <head> <meta charset="utf-8"> <title>search option</title> </head> <body> <?php echo "<form action='slips.php' method='post'>"; if(isset($_post['name_prod2'])){ $word=$_post['name_prod2']; $conn = oci_pconnect('dbname', 'password', 'localhost/xe'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['error'], ent_quotes), e_user_error); } $stid = oci_parse($conn, "select * product lower(name) '%" . $word . "%'"); oci_execute($stid); echo ...

ruby on rails - Iterate over has_many through relationship and include data from joining table -

i have simple rails app 3 models: recipes, ingredients, , joining table quantities stores amount of each ingredient in recipe. 1 recipe, want list associate ingredients , amount found in joining table. how iterate on ingredients, include data quantities table? class recipe < activerecord::base has_many :quantities has_many :ingredients, through: :quantities accepts_nested_attributes_for :quantities, :reject_if => :all_blank, :allow_destroy => true end and: class ingredient < activerecord::base has_many :quantities has_many :recipes, through: :quantities end and joining table: class quantity < activerecord::base belongs_to :recipe belongs_to :ingredient accepts_nested_attributes_for :ingredient, allow_destroy: true end it seems should easy iteration not sure how. show.html.erb: <% @recipe.ingredients.each |ingredient| %> <% #i know line below wrong, not sure how # iterate on ingredients recipe , #...

Why are my entities only partially populated when loading them using Spring Data JPA? -

i'm using spring data jpa , datanucleus jpa persistence provider , have interface bookrepository extends crudrepository<book, long> { book findbyauthorid(long id); } if call bookrepository.findbyauthorid() , access book.publishinghouse.manager.name null . opposed calling bookrepository.findall() when fields populated correctly way. set datanucleus.detachalloncommit=true , datanucleus.maxfetchdepth=-1 (i tried 10). any idea why? if don't have additional transaction boundaries defined, entitymanager closed when leaving query method. means detached entities , kind of load state determined defaults persistence provider uses. you have 2 options: have client (service or controller class) using @transactional keep entitymanager open , loaded instances eligible lazy-loading pull data out of store while use instance. if controller or service not enough, might wanna openentitymanagerinviewfilter / -interceptor keeps entitymanager open until vie...

c++ - Using iterators on maps -

map<double, latlon> closestpoi; map<double, latlon> ::iterator iterpoi = closestpoi.begin(); i made tree keyed distance between 2 points. need find 3 points in tree smallest (3 smallest distances). declared iterator , initialized point @ root (i'm not sure if necessary didn't solve problem). tried using advance(iterpoi, 1) increment iterator didn't work either. how can find these 3 points , access values? note: yes know 3 nodes want root , kids (since have smallest distances) usually use for() loop iterate map: for(map<double, latlon> ::iterator iterpoi = closestpoi.begin(); iterpoi != closestpoi.end(); ++iterpoi) { // access iterator's key: iterpoi->first ... // access iterator's value: iterpoi->second ... }

How to transfer Nifti file into .mat Matlab file? -

i have nifti file, size of 62*62*38. how can transfer nifti file .mat matlab file? this can read nifti many other medical image file types matlab arrays, can save .mat files.

r - Trouble coloring histogram -

Image
i'm trying color range of values on histogram using 'ggplot2'. example i’ll use ‘diamonds’ dataset. when execute follow comand: qplot(carat, data=diamonds,geom="histogram", binwidth=0.01, fill=..count..) + scale_fill_continuous(low="#f79420", high="#f79420", limits=c(1000,3000)) i thw following , correct plot: but when use syntax equivalent code, cannot same result. code: ggplot(diamonds, aes(x = carat)) + geom_histogram( binwidth = 0.01, fill=aes(y = ..count..) ) + scale_fill_continuous(low="#f79420", high="#f79420", limits=c(1000,3000)) result: can please tell me i’m doing wrong? thanks. try this: ggplot(diamonds, aes(x = carat)) + geom_histogram( binwidth = 0.01, aes(fill = ..count..) ) + scale_fill_continuous(low="#f79420", high="#f79420", limits=c(1000,3000)) this give same picture first 1 above.

Renaming files based on content of txt files -

i have read similar questions , tried use make batch script, unsuccessfully. i have hundreds of txt files start this: (without space between lines) sgco master calibration input data, , , , , , , , , , , , , , , , , , , , , , , , date,09-sep-2014, ,eng:,tom, , , , , , , , serial number,201659, ,dwt. no.,2177 cal date 04.10.2013,,,,,,,, gauge pressure range, 10k, ,dwt. correctio factor,1.00128,,,,,,,, number of temperatures,5, ,,,,,,,,,, number of pressures,11, ,,,,,,,,,, calibration temperature unit, degc , ,,,,,,,,,, calibration pressure unit, psig , ,,,,,,,,,, (there aren't same amount of commas) want use following variables in file name: 10k (after range, ) 201659 (after serial number,) 09-sep-2014 (after date,) in case file name " sg10k - 201659 - 09-sep-2014.txt " setlocal enabledelayedexpansion rem files do: %%f in (*.txt) ( rem desired lines , set variables: /f "tokens=1,2 delims=," %%i in (' findstr "^date ^ser...

javascript - Highcharts Column Graph with background color? -

i'm trying make column graph in highcharts , it's not working out hot. i'm trying give column background color data point can overlay. want effect of stacking without stacking if makes sense. thoughts on can do? want progress bar... there should distinct coloring between top of bar , top of graph itself. i've tried stacking: percentage, no avail. thoughts? there 3 options come mind: 1) achieve 'effect' of stacking, stack it: use dummy series color set background color want, , set values fill gap actual data. example : http://jsfiddle.net/jlbriggs/zf8c7/5/ [[edit questions the order of series not matter work, , neither legendindex. what matter, if using multiple series, stack property each series - http://api.highcharts.com/highcharts#series.stack each group need own stack, , dummy series , real series within each group need assigned same stack. in addition, need have 1 overall max value. updated example: http://jsfiddle.net/j...

xml - Make Php string without break lines -

i need generate random sentences dictionary. in dictionary every word @ 1 line, firstly load dictionary array , after have cycle , randomly pickup data, if wrote it, @ 1 line in browser, in source code every word @ line. need create set of xml files search engine , new lines indexed /n/r , in xml source code has got symbol &#xd; question how can make sentence @ 1 line in source code too. thanks. here piece of code don´t have here randomly loading data, made illustration in cycle. $file = fopen("test.txt", "r"); $data = array(); while (($buffer = fgets($file)) !== false) { $data[] = $buffer; } $sentence = ''; ($i=0;$i<10;$i++){ $sentence = $sentence . $data[$i]; } use trim function filter new line characters. in code use: $data[] = trim($buffer);

javascript - Creating a line graph from array of data objects -

i'm trying learn d3 , having problems creating simple line graph array of data objects. i have array of data objects this... [ {date: "03/04/15", rain: "1.2"}, {date: "03/05/15", rain: "2.3"}, {date: "03/06/15", rain: "0.0"}, {date: "03/07/15", rain: "4.2"}, {date: "03/08/15", rain: "0.3"}, {date: "03/09/15", rain: "0.0"} ] i've tried following simple tutorial creates line graph, when plug in data, neither x axes or line display. have date formatting? i have example on js bin . i don't understand problem is, please help! the x axis should d3.time.scale , since date property strings have convert proper date objects doing new date();

php - How to run a controller from a helper. Zend Framework 1.12 -

i understand isn't true way! tell me, how can run other module->controller action helper? or give me other way! i have api module, , need run api module helper prepared request params. have thoughts this? into action_helper try apply code: require_once "../../modules/somemodule/controllers/somecontroller.php"; $ctrl = new somemodule_somecontroller($request, $response); $ctrl->run(); but error: fatal error: require_once(): failed opening required '../../modules/somemodule/controllers/somecontroller.php' (include_path='..') in /path/to/helper/action solution if ask question on another how run controller controller? we've got answer =) action helper $that = $this->getactioncontroller(); $that->forward("someaction", "somecontroller", "somemodule", $params); if ask question on another how run controller controller? we've got answer =) action helper $that = $this-...

android - How to force call to OnGlobalLayoutListener in inflated view -

i inflating view using call final view view = mactivity.getlayoutinflater().inflate(r.layout.photo_view, null, false); the view being inflated sole purpose of turning bitmap. the following call not working. if make call inside dialogfragment's oncreateview works -- know code snippet works. if inflating view bitmap conversion method public void ongloballayout() never called. viewtreeobserver viewtreeobserver = view.getviewtreeobserver(); if (viewtreeobserver.isalive()) { log.i(tag, "waiting right time"); view.getviewtreeobserver().addongloballayoutlistener(new viewtreeobserver.ongloballayoutlistener() { @suppresslint("newapi") @override public void ongloballayout() { if (view.getlayoutparams().width <= 0 || view.getlayoutparams().height <= 0) { int height = getdeviceheight(mactivity); int width = ...

symfony - Using a bundles class to extend a CoreBundle -

Image
i need or rather advice. i have core bundle general functionality , several additional bundles more specific functionality. for example core bundle responsible rendering main menu application want other bundles able add menu items registering bundle. (in end menu items available menu items not active ones.) i have solution not sure if one. my corebundle contains corebundleinterface: namespace corebundle; use corebundle\menu\menubuilder; interface corebundleinterface { public function getmenuitems(menubuilder $menuitem); } so other bundle can implement interface: namespace addressbundle; use corebundle\corebundleinterface; use corebundle\menu\menubuilder; use symfony\component\httpkernel\bundle\bundle; class addressbundle extends bundle implements corebundleinterface { public function getmenuitems(menubuilder $menubuilder) { $menubuilder->additem(['name' => 'addresses', 'label' => 'addresses']); } } ...

java - JFrame won't show - Not an error in code -

recently every single 1 of apps extends jframe fails show frame. program run , terminate after 8 seconds without ever showing , without error message. happens programs i've made in past new programs. for testing purposes using basic example oracle documentations. import java.awt.borderlayout; import javax.swing.jframe; import javax.swing.jlabel; public class test extends jframe{ public static void main(string[] args){ //1. create frame. jframe frame = new jframe("framedemo"); //2. optional: happens when frame closes? frame.setdefaultcloseoperation(jframe.exit_on_close); //3. create components , put them in frame. jlabel emptylabel = new jlabel(); frame.getcontentpane().add(emptylabel, borderlayout.center); //4. size frame. frame.pack(); //5. show it. frame.setvisible(true); } } i using eclipse , i've tried switching workplaces. i've looked @ existin...

c++ - How to find silent parts in audio track -

i have following code stores raw audio data wav file in byte buffer: byte header[74]; fread(&header, sizeof(byte), 74, inputfile); byte * sound_buffer; dword data_size; fread(&data_size, sizeof(dword), 1, inputfile); sound_buffer = (byte *)malloc(sizeof(byte) * data_size); fread(sound_buffer, sizeof(byte), data_size, inputfile); is there algorithm determine when audio track silent (literally no sound) , when there sound level? well, "sound" array of values, whether integer or real - depends on format. for file silent or "have no sound" values in array have zero, or close zero, or worst case scenario - if audio has bias - value stay same instead of fluctuating around produce sound waves. you can write simple function returns delta range, in other words difference between largest , smallest value, lower delta lower sound volume. or alternatively, can write function returns ranges in delta lower given threshold. for sake of toying, wro...

oop - Efficiency of java static method calling -

my professor said when ever use static method class whole class gets loaded memory , method executed. my question is: if class contains 100 methods , 50 different variables , if called 1 static method class.the complete class(100 methods , 50 variable ) gets loaded in memory inefficient in terms of memory , performance. how java deals kind of issue ? true, class byte-code loaded when call static method (but once , not every time ).. same happens when call non-static method. in later case instance must created. thus, in sense of question, false dichotomy. because java dynamic language , platform (with jit) runtime efficiency can increase between method invocations. thus, best write clear , concise code (that write dumb code ). if clearest way implement solution static methods use them.

Add class (odd and even) in html via javascript? -

i have code example: <section class="timeline"> <article class="post "> <article class="post "> <article class="post "> <article class="post "> </section> now want know how add class via javascript article element. example: 1st article add class "left" 2nd article add class "right" 3rd article add class "left" 4th article add class "right" i'm not sure want don't need have javascript can write styles odd , childrens. .post:nth-child(odd) { color: green; } .post:nth-child(even) { color: red; } <section class="timeline"> <article class="post ">article</article> <article class="post ">article</article> <article class="post ">article</article> <article class="post ">article</article> </s...

java - StringIndexOutOfBoundsException on replaceAll using lookahead and backslash? -

i'd escape quotes (single , double) , backslashes of string. i'm trying single call of mystring.replaceall. regex match , replace (?=['\"\\\\]) (escaped java syntax), or more readable: (?=['!\]) (unescaped syntax). i'm doing lookahead, because want keep quotes , backslashes, , insert escape character before each of them. if use + escape character, works charm (all strings below in escaped java syntax): "abc'def\"ghi\\jkl".replaceall("(?=['\"\\\\])", "+") results in "abc+'def+\"ghi+\\jkl" . yay! however, if use backslash escape character, i'm getting stringindexoutofboundsexception instead: string index out of range: 1 . the call looks this: "abc'def\"ghi\\jkl".replaceall("(?=['\"\\\\])", "\\\\") that's odd... inserted backslash interfere somehow backslash within lookahead regex? if so, how can avoid behavior? here ful...

javascript - What is the most efficient way to update an array with objects without re-rendering the entire DOM in RactiveJS? -

if have array objects in them. var tableary = [ { id:0, name:"bob"}, { id:1, name:"tim"}, { id:2, name:"pete"}, ]; and want update tim "tim smith". tableary[1] = { id:1, name:"tim smith"}; how do without having reset whole array? ractive.set("table",tableary); wouldn't force whole table re-rendered? target set specific keypath possible: // single property ractive.set("table.1.name", "tim smith"); // multiple properties in 1 go: ractive.set({ "table.1.name": "tim smith", "table.1.age": 12, }); // can update object var item = ractive.get('table.1'); item.name = 'tim smith'; item.age = 22; ractive.set("table.1", item); that being said, ractive has smarts not re-rendering things of same value. though still has more comparisons.

playframework - What are Play Framework best practices for exclusive locking and programatic timers? -

i come javaee background running on single server. i'm studying play framework build high performance scalable , elastic systems. realize play stateless , share-nothing , understand thing. also, read cap theorem , 12 factor apps. situations feel i'm still thinking javaee developer, ask how best design solution problems below. imagine have system "requester user" creates offer . offer sent mobile devices of 10 other users. 10 users can respond offer, first 1 respond "get" offer (the others receive message saying "other user has accepted offer"). requester user receive e-mail saying offer done user x (the first accept). the offer lasts 30 seconds. if no user responds offer within time, offer automatically closed , hence not accept more replies. e-mail shall sent requester user saying offer not accepted user. everyday @ 20:00 system have fire e-mail admins reporting every offer, tried accepted them , "got it". so here main 3 que...

javascript - Expected expression, got end of script -

so have below code in header of webpage: <script type="text/javascript"> var counter = 2; function addnewitemfield(divname) { var newdiv = document.createelement("div"); newdiv.id = "item_listing_" + counter; newdiv.innerhtml = "<label for=\"item_" + counter + "\">item: </label><br />"; newdiv.innerhtml += "<input type=\"text\" id=\"item_" + counter + "_category\" list=\"list_categories\" name=\"items[]\">"; newdiv.innerhtml += "<input type=\"number\" id=\"item_" + counter + "_amount\" mine=\"0.00\" step=\"0.01\" value=\"0.00\" name=\"amounts[]\"><br />"; document.getelementbyid(divname).appendchild(newdiv); counter++; } </script> i try calling using button, syntax error stating "expected expression, got end of scr...

Hockeyapp configuration with jenkin build -

i working on hybrid app , having 2 branch ios , android. how configure jenkins build hockeyapp? first need install hockeyapp plugin on jenkins after installation, default hockeyapp configuration option in http://jenkins-server:port/configure default hockeyapp configuration default api token <*provide api token*> **you hockey account http client timeout <leave empty> enable global debug mode <keep unchech> on job configuration page there add post-build action option in select upload hockeyapp api token <leave blank if have done previous step > upload method = upload app / upload version (select per requirement) app file = location of app file symbols (.dsym.zip or mapping.txt) = optional path, relative build's workspace, generated dsym.zip (ios , macos) or mapping.txt (android) file. packed libraries (.zip) = optional path release notes = no release notes/use change log/load release notes file/input release notes (...

javascript - Clear or Select the kendo grid cell on click -

i have kendo grid - hours column multiple weeks (i using clienttemplate display it) have editor template edit columns. have given edit mode incell requirement select cell on click of cell. have tried : function edit(e) { var input = e.container.find("input"); input.select(); } and var currentdataitem = e.sender.dataitem(this.select()); but no use. please help. you can like: $("#grid").kendogrid({ datasource: { type: "json", pagesize: 10, serverpaging: true, transport: { read: "http://whatever" } }, selectable: "cell", pageable: true, columns: ["productid", "productname"], change: function() { var dataitem = this.datasource.view()[this.select().closest("tr").index()]; alert(dataitem.unitprice); } }

html - CSS text transition reverting to font size after finished -

i'm having issues transitioning text properly. have list 5 hyperlink texts: <div id="listcontainer"> <ul id="wordlist"> <li class="wordlistitem"><a class="wordlistlink" href="somewhere1.jsp">word1</a></li> <li class="wordlistitem"><a class="wordlistlink" href="somewhere2.jsp">word2</a></li> <li class="wordlistitem"><a class="wordlistlink" href="somewhere3.jsp">word3</a></li> <li class="wordlistitem"><a class="wordlistlink" href="somewhere4.jsp">word4</a></li> <li class="wordlistitem"><a class="wordlistlink" href="somewhere5.jsp">word5</a></li> </ul> </div> i use #wordlist remove bullets, #wordlistitem display words inline, , #wordlistlink text tr...

objective c - How to determine size of a specific slice of a static library in iOS -

i have static library in ios project contains slices 4 architectures. able determine architecture slice components of static library command: $ file mystaticlib.a mystaticlib.a: mach-o universal binary 4 architectures mystaticlib.a (for architecture armv7): current ar archive random library mystaticlib.a (for architecture i386): current ar archive random library mystaticlib.a (for architecture x86_64): current ar archive random library mystaticlib.a (for architecture arm64): current ar archive random library i wish determine size of specific slice (arm64, e.g). how this? using lipo command -detailed_info flag able determine size of specific slice (amongst other details). usage follows: $ lipo -detailed_info mystaticlibrary.a fat header in: mystaticlib.a fat_magic 0xcafebabe nfat_arch 4 architecture armv7 cputype cpu_type_arm cpusubtype cpu_subtype_arm_v7 offset ....... size ....... align 2^2 (4) architecture i386 cputype cpu_type_i3...

javascript - How to upload file using Protractor to the ng-file-upload element -

the html follows: <input type="file" style="display: none" ng-file-select="" ng-file-change="upload($files)" ng-multiple="multiple" accept=".jpg,.png"> i need upload file element uses ng-file-upload uploading image file using protractor: var uploadfile = element(by.css('input[type="file"]')); uploadfile.sendkeys('c:\\temp\\test.png'); uploadfile.evaluate("openmetadatadialog({file:imgfile})"); the above not working. not able understand how upload file! per understanding, sendkeys input element, upload function should called itself! however, not seem happening! regards, sakshi it seems ng-file-upload doesn't react .sendkeys(...) , file-change doesn't invoked. can use standard onchange event invoke custom upload logic: <input type="file" style="display: none" onchange="angular.element(this).scope().upload(t...

winforms - Calculator windows forms c# -

this question has answer here: capture keyboard inputs without textbox 1 answer i'm working on university project of windows forms calculator c#. is functional, question is. can insert numbers in main textbox without focusing on it. want work windows calculator , insert numbers without having click textbox. i've try lot of methods using event key_press directly on form nothing works. ps. windows calculator. set form.keypreview property true , handle form_keypress event.

Annualised Revenue - SUM of revenue for last 12 complete months SSAS mdx calculation -

i'm new mdx world , enhancing ssas cube. i’m trying create calculated member in ssas cube annualised revenue(sum of revenue last 12 complete months) each of device(product). start created below mdx query, showing device names, annualised revenue shows (null). any correction needed mdx query? or appreciate, if can give me example based on adventureworks cube. here mdx query: with member [measures].[annualised revenue] sum ( closingperiod ( [invoice date].[calendar month].[invoice calendar month] ,[invoice date].[calendar month].[all periods] ).lag(12) : closingperiod ( [invoice date].[calendar month].[invoice calendar month] ,[invoice date].[calendar month].[all periods] ) ,[measures].[amount] ) select [measures].[annualised revenue] on 0 ,[terminal].[terminal id].members on 1 [cube_txn]; do need add cluase “where ( [invoice date].[calendar month].[inv...

excel - How to store cell positions(row,column) in Java? -

i've store cell positions in excel file compared later. ex. (1,6) (1,17) (2,6) (2,17). 1 -> row, 6 -> column i can't figure out collection use in java this. there must mapping present between 2 values. can't use map because key values not unique. don't want use multidimensional arrays complicated. any suggestions welcome. if need map single row value multiple column values, use map<integer, list<integer>> or map<integer, set<integer>> , , create kind of adjacency list . then, having row value, able retrieve corresponding column values. make easier use, wrap custom class this: class positions { private map<integer, set<integer>> positions = new hashmap<>(); void add(int row, int column) { set<integer> columns = this.columnsfromrow(row); columns.add(column); this.positions.put(row, columns); } set<integer> columnsfromrow(int row) { set<int...

How to pass a query parameter along with a redirect in JavaScript -

right redirection made saying window.location = "/relative_path/"; what want add query parameter along redirection, destination page can @ that, , after action taken redirect further page. example use login system. when user's token expires, redirected login page. @ time of redirection want pass along exact url (including query parameters in url) login page, after successful login user redirected point he/she was. i tried pass path url parameter, doesn't work because of escaping issues: redirect url uses same characters (?, =, ...), confuses system, , parameters truncated. so that, doesn't work: window.location = "/login?redirect=/original_location?p1=vl1&p2=v2 any suggestion appreciated. you can use encodeuricomponent() the encodeuricomponent() method encodes uniform resource identifier (uri) component replacing each instance of characters one, two, three, or 4 escape sequences representing utf-8 encoding of character (wil...

Python: doubling variable in a function -

def lb(a): while != 0: = - 1 print('\n') print('1 line break') lb(1) print('2 line breaks') lb(2) print('3 line breaks') lb(3) print('done') when run code doubles amount of lines needs break, outputs: 1 line break 2 line breaks 3 line breaks how make print right amount of line breaks? in python print automatically adds line break @ end unless explicitly told not to. means function print twice number of line breaks asked because print('\n') prints 2 line breaks, 1 in string , added automatically @ end. a simple solution use print() instead.

javascript - Show AJAX success JSON values in html selection -

i have html form few drop down selections, used same form editing data, now edit data in row of table, had created ajax request, once row selected , user click on edit, ajax values of specific row id. my html form have input elements , select element, can show value in input element below code, in html element id - user_name input type, can see data value in box, but element id - user_status selection type, have options enable , disable, success:function(data){ var objdata = jquery.parsejson(data); $("#user_name").val(objdata.user_name); $("#user_status").val(objdata.user_status); } this html select code, <select name="is_manager" id="user_status"> <option style="width:auto">--select status--?</option> <option style="width:auto">enable</option> <option style="width:auto">disable</option...

javascript - If the Option Value is having value="0" alert true -

demo html: <select> <option value="0">this 0 </option> <option value="1">this 1 </option> <option value="2">this 2 </option> <option value="3">this 3 </option> </select> js : $(function () { if ( $("select option[value='0']") == option[value='0'] ) { alert('asd') } }) <select id='myselect'> js: var selectedvalue=document.getelementbyid('myselect').value; if(selectedvalue=='0') alert('asd');

php - Server-side Content Filters / Facets -

i'm trying build site that'll have few hundred posts in grid. how implement filter mechanism (color, size etc) such mixitup.kunkalabs.com 1 fetches data ajax event rather loading posts , filtering them? i'm using codeigniter php framework

jsp - Top link now working in Firefox -

we have 1 "top" link @ bottom of each of page in our application. clicking on "top" link navigates page top (scroll bar goes up). for this, maintaining common piece of code in common jsp <a id="pagetop"></a> while in other jsp pages, code looks like <a href="#pagetop">top</a> the problem top link working fine ie , chrome same not working in firefox. clicking on top link in firefox not navigating page up. please fix issue? this working, <html> <body> <a id="pagetop">i top</a> <!-- pages of content goes here --> <a href="#pagetop">top</a> </body> </html> check fiddle , might have tagging mismatch.

Don't validate nested attributes in rails -

i don't want validate & save nested attributes model while saving parent model. class car has_many :models nested_attributes_for :models end class model belongs_to :car end car = car.create(name: "tata") car.model_attributes({name: "nano"},{name: "vista"}) car.save! you can try setting :autosave false, prevent saving nested attributes class car has_many :models, autosave: false end

sql server - Parse fixed length data from text into database -

i have text file data need read database. data inside file follows: 00000a0011nike running shoes00000a0012nike store mo city12345b0001emc truck 12345b0002bh78545789785 12345b0003nh170323032015060012345c0011steve jones shoe's 12345c0012company, tel17545812345c001312,fax:66234544-4812345d0001mrs. mary wilson, off 19 45781b0001emc truck 45781b0002bh78545789785 45781b0003nh1703230320150600 45781c0011steve jones shoe's45781c0012company, tel17545845781c001312,fax:66234544-48 45781d0001mrs. mary wilson, off 19 each line same length 3 sections in it. each section has different kind of data, here interpretation of data: transactionid char(5) record char(2) record counter number(3) - a0 data fields 011 sender information char(18) 012 sender location char(18) - b0 data fields 001 vehicle type char(18) 002 destination char(05) 002 package weight number(05) 002 package data ...

java ee - Spring Example using STS 3.6.4 -

from spring tool suite 3.6.4 trying develop spring project have done every thing adding jars present in sts lib folder , apache common-logging 1.1.3 , 1.2. sts showing error in main class @ new classpathxmlapplicationcontext("beans.xml"); while trying solve it, sts showing configure buildpath have added jars watching tutorials in youtube. i using java 1.6 version, os ubuntu, sts 3.6.4 below listed jars have added buildpath /home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.release/lib/aws-java-sdk-1.7.5.jar /home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.release/lib/com.springsource.org.apache.commons.beanutils-1.8.3.jar /home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.release/lib/com.springsource.org.apache.commons.cli-1.2.0.jar /home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.release/lib/com.springsource.org.apache.commons.codec-1.5.0.jar /home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.release/lib/com.springsource.or...

swift - CoreData: Not null property should be optional? -

i'm not sure best practice of swift , coredata. think not null property should optional basically? for example import foundation import coredata class item: nsmanagedobject { @nsmanaged var itemid: string // not null property @nsmanaged var itemprice: string? // null possible } i wonder should notify other programmers property not-null or not. i know do usually. question sound opinion-based i'm sure how dealing optional helpful others. fyi found similar question coredata - setting property of entity not null - should attribute set optional or mandatory from https://developer.apple.com/library/mac/documentation/cocoa/conceptual/coredata/articles/cdmom.html#//apple_ref/doc/uid/tp40002328-sw6 .. mentioned - can specify attribute optional—that is, not required have value. in general, however, discouraged doing so—especially numeric values (typically can better results using mandatory attribute default value—in model—of 0)

android - Error:(31, 5) uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library -

i m trying use gabriele mariotti card library , github using https://github.com/gabrielemariotti/cardslib . currently i'm using android studio, have added dependencies build gradle file mentioned in documentation. this gradle file looks like apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "21.0.1" defaultconfig { applicationid "com.vt" minsdkversion 9 targetsdkversion 21 } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { compile project(':facebooksdk') compile project(':addslidepanel30') compile 'com.android.support:support-v4:21.0.1' compile 'com.google.android.gms:play-services:+' compile 'com.android.support:appcompat-v7:21.0.3' compile...

php - Multiple nested array from MySQL query -

i'm using foreach loops access records in nested array: while ($row = mysql_fetch_assoc($result)){ $test_groups[$row['group_name']][] = $row['lab_test']; } foreach($test_groups $group_name => $tests){ echo "<tr><td><span class='test_group_name'>" . $group_name . "</span></td></tr>"; foreach($tests $test){ echo "<tr><td>" . $test . "</td></tr>"; } echo "<tr><td>&nbsp;</td></tr>"; } echo '</table>'; this works ok. need add level nested array, like: $departments[$row['department_name']][$row['group_name']][] = $row['lab_test']; would work , how should adjust each loops above cater this? assign array should [] @ end $departments[$row['department_name']][$row['group_name']][] = $row['lab_test']; foreach...

is it atomic for writing a struct to same global memory location in CUDA? -

for example: struct point { int x, int y; }; if threads write own point same location in global memory in same time, possible final result point in location has x value of thread , y value of thread b? this question closely related concurrent writes in same global memory location , is global memory write considered atomic in cuda? [this answer copied comment should have been answer.] is possible final result point in location has x value of thread , y value of thread b? yes. avoid such scenario need write point single atomic value (ie, reinterpret point double or int64 , use atomic set).

android - How to get the id resource id of a view in a List view -

i have listview showing different images of animals,birds,reptiles. list view working fine. want when user click picture should appear in imageview .the imageview below listview . when ever user click image in listview should appear in imageview . also there button. want achieve when user select image , press ok button paticular image should show on image view of other activity also. know can send id through intent.putextra() , problem first place how id of particular picture. source code public class mainactivity2 extends actionbaractivity { private typedarray listicons; private horizontallistview listview; private arraylist<animalslistitems> suititems; private animalslistadapter adapter1 = null; /** array of strings populate dropdown list */ string[] actions = new string[] { "bookmark", "subscribe", "share" }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate...

Python tkinter, do something before subprocess starts -

i'm having problem python tkinter program. want press button start subprocess , indicate subprocess running changing label's value. subprocess takes time , problem label waits subprocess finished change, don't understand, because used variable first change label , go on subprocess. here code: def program_final(): start = false while true: if start == false: v.set("scanning...") label.pack() start = true else: # p = subprocess.popen('sudo nfc-poll', shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout) # opens subporocess starts nfc-polling in background p = subprocess.popen('ping 8.8.8.8', shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout) counter = 0 output = "" lines = [] while true: line = p.stdout.readline() # while loop iterates through output lines of ...

database - Using Neo4j Core Java API and terminal console together -

i writing application collects huge amount of data , store in neo4j. i'm using java code. in order analyze data want use terminal neo4j server connect same database , use neo4j console query on using cypher. this seems lot of hassle. have changed, neo4j-server.properties connect directory java code collecting data. , changed flag allow_store_upgrade=true in neo4j.properties. however, still facing issues because of locks. is there standard way achieve this? you need have neo4j-shell-<version>.jar on classpath , set remote_shell_enabled='true' config option while initializing embedded instance. i've written blog post on time ago: http://blog.armbruster-it.de/2014/01/using-remote-shell-combined-with-neo4j-embedded/

Android samples comments BEGIN_INCLUDE END_INCLUDE -

while reading android samples see comments // begin_include (something) // end_include (something) however, current ide — android studio 1.1 — can not recognise them (or maybe wrong). guess, serve kind of code region marks (like //<editor-fold desc="region name"> // code //</editor-fold> in androidstudio/intellijidea), such syntax c++ preprocessor directives. question: should know important these comments (besides obvious commenting function) improve code in way? it's documentation purposes, used identifying snippets include in target documentation. it's not useful when editing code; it's useful avoiding repetition generating documentation actual code. {@sample} , {@include} these tags copy sample text arbitrary file output javadoc html. the @include tag copies text verbatim given file. the @sample tag copies text given file , strips leading , trailing whitespace reduces indent level of text ind...

algorithm - having a difficulty with making a palindrome program c++ -

this question has answer here: std::cin input spaces? 8 answers hi code palindrome program: void palindrome() { string input; bool checkinput, palindrome; palindrome = true; { checkinput = false; cout << "enter word, phrase or sentence :\n"; getline(cin, input); (unsigned int = 0; < input.size(); i++) { if (input[i] < 65 || input[i] > 90 && input[i] < 97 || input[i] > 122) { checkinput = true; } } } while (checkinput); (unsigned int = 0, j = input.size() - 1; < input.size(); i++, j--) { if (input[i] != input[j] && input[i] + 32 != input[j] && input[i] - 32 != input[j]) { palindrome = false; break; } } if (palindrome) ...