Posts

Showing posts from May, 2014

windows - Execute a batch script in Maven aggregator once per module -

i using exec-maven-plugin execute batch command specific modules. the entire product build consists of several of these modules , using aggregator build necessary modules @ once. trying simplify process of executing batch scripts once per module, because execution script identical every plugin , requires current plugin path. is somehow possible execute batch script within aggregator, once every module? let's aggregator looks this: <project xmlns= ...> .... <modules> <module>../modulea</module> <module>../moduleb</module> ... <module>../modulez</module> </modules> </project> would possible execute batch command such mybatch.bat -i ..\modulex from within aggregator , modulex denotes built module? it important execution of batch script "post-build" step executed after module built. executed script external tool used obfuscate .jar files. i thankful sma

Matplotlib - set bars different color depending on where they are located on the x axis -

Image
i made bar plot in matplotlib , change color of bars either green or yellow depending on located on x-axis. example, bars represent data x values in [5, 6, 8, 9] should colored in yellow, while other bars should green. how do that? thank you! first, nice if posted code.i suggest read information provided on matplotlib.org see possible options of function using. here code example: import numpy np import matplotlib.pyplot plt x = np.arange(10) xx = x**2 cr = ['g','g','g','g','y','y','y','y','g','g'] fig,ax = plt.subplots() ax.bar(x,xx,color=cr) plt.show() this produces:

java - 2D array with user input -

i want create 5 row 2 column int array , have user input each value in array. want use stdin input. why won't work? please help! thanks. this effort: int [][] = new int [5][2]; int i; int j; for( = 0; < 4; i++ ); { for( j = 0; j < 2; j++ ); { system.out.println( "month number (e.g. august = 8)" ); int month = stdin.readint(); a[i][0] = month; system.out.println( "year number (e.g. 2007)" ); int year = stdin.readint(); a[i][1] = year; } } you're asking both values user, no need nested loop: int [][] = new int [5][2]; for(int = 0; < 5; i++ ) { system.out.println( "month number (e.g. august = 8)" ); int month = stdin.readint(); a[i][0] = month; system.out.println( "year number (e.g. 2007)" ); int year = stdin.readint(); a[i][1] = year; } i've removed semicolon ; had after first loop making useless, , fixed iterat

javascript - How to keep React component state between mount/unmount? -

i have simple component <statefulview> maintains internal state. have component <app> toggles whether or not <statefulview> rendered. however, want keep <statefulview> 's internal state between mounting/unmouting. i figured instantiate component in <app> , control whether rendered/mounted. var statefulview = react.createclass({ getinitialstate: function() { return { count: 0 } }, inc: function() { this.setstate({count: this.state.count+1}) }, render: function() { return ( <div> <button onclick={this.inc}>inc</button> <div>count:{this.state.count}</div> </div> ) } }); var app = react.createclass({ getinitialstate: function() { return { show: true, component: <statefulview/> } }, toggle: function() { this.setstate({show: !this.state.show}) }, render: function() { var content = this.state.

markdown - Doxygen: multiple use of section label bug? -

i use doxygen document code , encounter problem when use markdown syntax. for example, have 2 .dox files: fileabc.dox: /** @page abcpage header {#abcheader} ====== abc text. */ filedef.dox /** @page defpage header {#defheader} ====== def text. */ which raise warning: warning: multiple use of section label 'header' and abcheader section not generated. there 2 workaround, none of them ok me: rename section abc header , def header or go doxygen syntax @section abcheader header so, there way use same section name in several pages, markdown syntax ? edit this bug has been introduced in version 1.8.7 : view commit it seems more bug new feature or improvement since setext-syntax (using # instead of ==) not give warning when same section name used several times. bug introduced in version 1.8.7 , resolved in version 1.8.8 bug description -- fix

How to use MKSnapshotter in Swift (iOS) -

i trying implement mksnapshotter mapkit. want create snapshot of location finding in mapview (streetview) using apple maps. here code have far: var options: mkmapsnapshotoptions = mkmapsnapshotoptions(); options.region = self.attractiondetailmap.region; options.size = self.attractiondetailmap.frame.size; options.scale = uiscreen.mainscreen().scale; var fileurl:nsurl = nsurl(fileurlwithpath: "path/to/snapshot.png")!; var snapshotter:mkmapsnapshotter = mkmapsnapshotter(); snapshotter.startwithcompletionhandler { (snapshot:mkmapsnapshot!, error:nserror!) -> void in if(error != nil) { println("error: " + error.localizeddescription); return; } var image:uiimage = snapshot.image; var data:nsdata = uiimagepngrepresentation(image); data.writetourl(fileurl, atomically: true); var pin:mkannotationview = mkannotationview(); uigraphicsbeginimagecontextwithopt

How to maintain aspect ratio of html container using only CSS -

the title little misleading since maintaining aspect ratio of , html element trivial, using width , padding-bottom or padding-top in percentages. however, scenario little different. maybe solution trivial brain fried. so in case, have content div inside container div. assumption container div can have dimensions , size. requirement inner div needs maintain it's own aspect ratio needs fit either height or width of container div, whichever corresponds closer aspect ratio of content div. so example, content div has aspect ratio 16:9. container div 500px wide , 1000px high. in case, content div size 500px wide , 281px high, white space above , below content div. container div might resized 1000px wide , 500px high, in case content div resize 889px width , 500px height, white space left , right of content div. there's less convoluted way explain scenario again, brain fried today. appreciated. edit: looking css solution. know possible js/jquery. what want use obj

javascript - Long delay with jquery animation after scroll -

i have div width of 0px . after user scrolls x distance want animate div 140px . when scroll point there long delay before see animation. further scroll longer delay. i'm setting containing div fixed @ same point. fixed item works fine animation delayed: html: <div class="menu-bar"> <div class="wrap"> <div id="menu-logo"> <img src="..." /> </div> <nav id="site-navigation" role="navigation">...</nav> <div class="right-menu">...</div> </div> </div> js: $(window).scroll(function(){ var barpos = $('#content').offset().top - $(document).scrolltop(); var menuheight = $('.menu-bar').height(); var topcolors = $('#top-colors').height(); if(barpos <= (topcolors+menuheight)) { $('.menu-bar').css({'position':'fixed'

javascript - Angular directive calling parent controller function -

how can directive call parent's controller function? have directive this: html: <div ng-app="myapp" ng-controller="maincontroller mainctrl"> body text<br> <a href="javascript:;" ng-click="mainctrl.myfunc()">click me body</a> <photo photo-src="abc.jpg" caption="this cool" /> </div> javascript: var app = angular.module('myapp',[]); app.controller('maincontroller', function(){ var vm = this; vm.myfunc = myfunc; function myfunc(){ console.log("log myfunc"); } }); app.directive('photo',function(){ return { restrict: 'e', template: '<figure> <img ng-src="{{photosrc}}" width="500px"> <figcaption>{{caption}}</figcaption> <a href="javascript:;" ng-click="mainctrl.myfunc()">click me</a></figure>',

C# Windows Store WebView get user-agent -

is there way extract user-agent string webview control uses? if so, appreciate if can give me method so. using following not seem work: var useragent = new stringbuilder(256); int length = 0; urlmkgetsessionoption(urlmonoptionuseragent, useragent, useragent.capacity - 1, ref length, 0); i take back, using urlmkgetsessionoption mentioned in code above work.

cql - How to change the default value of Cassandra counter -

in cassandra counter, if try increase counter in none existing row , creates row set value 0 , increase value requested. my question can change default value not 0 else. example: previous bucket or similar (row2 = row1+value) you can't set value of counter increment or decrement. a counter column value 64-bit signed integer. cannot set value of counter, supports 2 operations: increment , decrement. http://docs.datastax.com/en/cql/3.1/cql/cql_reference/counter_type.html

javascript - push array object into localstorage -

var arr = []; var obj = {}; obj.order_id = 1; obj.name = "cake"; obj.price = "1 dollar"; obj.qty = 1; arr.push(obj); localstorage.setitem('buy',json.stringify(arr)); the problem above code when executing replace existing array object, how add new obj array if order_id not same? new answer: var arr = []; var obj = {}; obj.order_id = 1; obj.name = "cake"; obj.price = "1 dollar"; obj.qty = 1; $change = 'no'; for(i=0; i<arr.length; i++){ if(obj.order_id == arr[i].order_id){ obj.qty = obj.qty + arr[i].qty; arr[i] = obj; $change ='yes'; } } if($change == 'no'){ arr.push(obj); } console.log(arr); and saving in localstorage see answer here: push multiple array object localhost? old answer: best solution make 'arr' object order_id being key of object. this: var arr = {}; var obj = {}; obj.order_id = 1; obj.name = "cake"; obj.price = "1 dollar"; obj.qty = 1; arr[

azure - Can't access office365 Calendar API -

Image
i want access calendar rest api ruby application. i've created azure multi-tenant app, , configured it. i'm trying access token resource " https://outlook.office365com/ ", error 'aadsts50001: resource 'https://outlook.office365.com/' disabled.' i can't find description of error, , can't understand why it's disabled here azure app permissions: that's new error me! let's check if exchange principals disabled. you'll need use remote powershell connect azure ad service. here's how (i'm assuming have powershell installed on windows machine): install azure ad module powershell: https://msdn.microsoft.com/en-us/library/azure/jj151815.aspx#bkmk_installmodule open "windows azure active directory module windows powershell". follow steps under "connect azure ad" in linked article. run following command: get-msolserviceprincipal -appprincipalid 00000002-0000-0ff1-ce00-000000000000

c++ - How would I go on as to "return" string arrays between functions? -

hey experimenting knew , realized when tried passing string value return wasn't supported, idea? sorry if code noob style (i have 2 months of experience), planning on splitting code between functions can't seem because returning array of strings cant done return :( here's code: #include <iostream> #include <math.h> #include <sstream> using namespace std; int itemlist=0; int c=0; int r = 0; int itemlistdec() { cout<<"how many items input?"; cin>>itemlist; return itemlist; } int main() { itemlistdec(); string item[4][itemlist];//declares item , columns equal itemlist content declared right above (int c=0;c<itemlist;c++) { (int r=0;r<3;r++) //determines each record goes { if (r==0) { cout<<"please enter name of item "; } if (r==1) { cout<<"please input buying price\n"; } if (r

Adding JavaScript events to an HTML input -

this code isn't working in firefox working on ie , chrome. when click inside text box runs focusout() , focusin() functions. behavior expected , syntax recommended? <!doctype html> <html> <head> <title>page of cage</title> <meta charset="utf-8"> <link rel="icon" href="mkx-logo.png" type="image/x-icon"> <script type="text/javascript"> function focusin() { alert("focus in!"); }; function focusout() { alert("focus out!"); }; </script> </head> <body> <form> name:<input onfocus="focusin()" onblur ="focusout()" type="text" name="name"/> <br/> <input type="submit" value ="submit"/> </form> </body> </html> replac

java - How to set year limit in DatePickerDialog in Android? -

i have been researching on putting limits in datepickerdialog , nothing seems work, don't know wrong , how make work here current code: public void getdate() { final calendar mycalendar = calendar.getinstance(); final datepickerdialog.ondatesetlistener date = new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { // todo auto-generated method stub mycalendar.set(calendar.year, year); mycalendar.set(calendar.month, monthofyear); mycalendar.set(calendar.day_of_month, dayofmonth); updatelabel(); } }; birthdate.setontouchlistener(new view.ontouchlistener() { @suppresslint("clickableviewaccessibility") @override public boolean ontouch(view v, motionevent event) { if (

java - How to display a local html file in Android? -

i wanted display simple html page in webview in android, made assets folder in main , put test.html file, when run app, web page not available code public class androidhtmlactivity extends activity { webview mybrowser; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mybrowser = (webview)findviewbyid(r.id.mybrowser); final myjavascriptinterface myjavascriptinterface = new myjavascriptinterface(this); mybrowser.addjavascriptinterface(myjavascriptinterface, "androidfunction"); mybrowser.getsettings().setjavascriptenabled(true); mybrowser.loadurl("file:///assets/test.html"); } } for accessing asset folder need use android_asset . hence code should be, mybrowser.loadurl("file:///android_asset/test.html");

How can I get a html source code of any website using jquery/javascript like php's file_get_content? -

is possible? or require server? $.get("http://xxxxx.com", function (data) { alert(data); }); that's got doesn't print out anything. sorry can not retrieve data different domain using jquery due browser security restrictions. yes can use other scripts perl scrap html data third party url. by using jquery , ajax retrieve data own web-site.

r - Make Blockchiain inquiries using Rbitcoin -

i need information associated transactions made in blockchain since last january. specifically, need transaction fee , block height of every transaction. i assume need use command: blockchain.api.query(..., method, verbose = getoption("rbitcoin.verbose", 0)) but don´t know how. thank help! i recommend add r tag in questions related rbitcoin. regarding blockchain.api.query should find answer in package documentation. may see blockchain.api.process related function. regarding want achieve, rbitcoin - particularly backend of blockchain.api.* functions blockchain.info api, , not right solution you. recommend use json-rpc locally stored blockchain, not remote 1 on blockchain.info. there open ticket in rbitcoin repo support quering data locally stored blockchain: rbitcoin#8 . update 2015-11-08: i've released bitcoin daemon r client separate package, see: jangorecki/rbitcoind .

javascript - import socket.io using system.js -

i trying include aurelia framework project sockets.io . have installed sockets by: jspm install npm:socket.io then, import: import {io} "socket.io"; and results is: get http://localhost:9000/jspm_packages/npm/socket.io-client@1.3.5/package.js 404 (not found) where problem? why there reference package.js , not package.json or socket.io.js ? on client side (aurelia), should use server.io client import io 'socket.io-client'; var socket = io('http://localhost:9000'); socket.emit('news', { hello: 'world' });

php - Should I be returning DB results inside the function or loop through the results outside the function? -

so wondering what's best way/practise of querying database in function , printing results .php page. got taught query in function() , call function() inside .php page , loop through resultset inside .php page. here example of i'm doing - im wondering if "unsafe" or "not secure" or slower returning results in function? because @ moment - taking while load on page? because i'm doing using if statements inside while loop ? showplaylist($statictestuser); if($numrecords == 0){ echo "<div class='no-found'>no playlists found</div>"; } else{ $htmloutput = "<div class='playlist-wrap'>"; $i = 1; while($arrrows = $stmt->fetch(pdo::fetch_assoc)){ $title = $arrrows['song-title'] $thumbnail=$arrrows['thumb'] $playtitle = $arrrows['playlistnam

android - Error when attaching files with PhoneGap EMailComposer plugin -

i'm using phonegap emailcomposer plugin android send file attached when mail client (gmail app) opens same error "the file can't attached'. this code i'm using: cordova.plugins.email.open({ to: 'xx', subject: 'xx', body: 'xx', attachments: '//file.csv' }); i'm quite sure path right becasuse when use other file path error changes "attached file can't empty'. i'm using cordova cli 4.0.0 , plugin version 0.8.2. i've tested in android 4.4.2 , 4.2.1 any idea? according documentation need use attachments: 'file:///storage/sdcard/icon.png', //=> android but didn't work me tried without storage , works me. (i'm using android 5.1.1 tests, don't know if works in case android 4.x) try with: attachments: 'file:///sdcard/file.csv

vba - Importing graphics in order from folder to PowerPoint -

the situation: running macro import graphics folder powerpoint, 4 per slide in custom format, using macro found here. the issue: order pictures imported not done name of file. how import these photos in order? files named chart 1, chart 2, etc. the code: sub insertquadformat() dim presentation dim layout dim slide dim fso dim folder dim file dim foldername dim integer 'change folder per needs foldername = "c\" = 1 set presentation = application.activepresentation if presentation.slides.count > 0 presentation.slides.range.delete end if set layout = application.activepresentation.slidemaster.customlayouts(3) set fso = createobject("scripting.filesystemobject") set folder = fso.getfolder(foldername) ' loop though each image in folder each file in folder.files if lcase(mid(file.name, len(file.name) - 3, 4)) = ".png" if mod 4 = 1 ' 1,5,9 .... images

How to copy register with DetailView and get pk (Django) -

consider template: entry_detail.html <form class="navbar-form navbar-right" action="." method="get"> <!-- add --> <!-- <p name="filter_link" class="pull-right"><a href="">produtos em baixo estoque</a></p> --> <a name="new_customer" href="{% url 'proposal_list' %}"> <button type="button" class="btn btn-primary"> <span class="glyphicon glyphicon-plus"></span> criar orçamento </button> </a> </form> and considerer view: views.py class entrydetail(detailview): template_name = 'core/entry/entry_detail.html' model = entry def create_proposal(self, employee_pk=8): if 'new_customer' in self.request.get: employee = employee.objects.get(pk=employee_pk) num_last_proposal = numlastpr

node.js - npm install bower fails -

i trying install bower on mac os yosemite npm fails following message npm err! fetch failed http://registry.npmjs.org/nopt/-/nopt-3.0.3.tgz npm warn retry retry, error on last attempt: error: connect etimedout npm err! fetch failed http://registry.npmjs.org/request/-/request-2.53.0.tgz npm warn retry retry, error on last attempt: error: connect etimedout npm err! fetch failed http://registry.npmjs.org/shell-quote/-/shell-quote-1.4.3.tgz npm warn retry retry, error on last attempt: error: connect etimedout npm err! darwin 14.4.0 npm err! argv "node" "/usr/local/bin/npm" "install" "-g" "bower" npm err! node v0.12.7 npm err! npm v2.12.1 npm err! code etimedout npm err! errno etimedout npm err! syscall connect npm err! network connect etimedout npm err! network not problem npm npm err! network , related network connectivity. npm err! network in cases behind proxy or have bad network settings. npm err! network npm err! network if be

java - Google Appengine with Jersey 2.1x works fine in dev server but not in Appengine servers -

i have been using jersey v2.19 google appengine v1.9.22 , works fine in local devserver without issue, when tried deploy application appengine. multiple exceptions frameworks used : appengine java 1.9.22 jersey 2.19 objectify 5.1.5 guice 3.x gradle following exception in log: org.glassfish.jersey.internal.errors logerrors: following warnings have been detected: warning: unknown hk2 failure detected: multiexception stack 1 of 4 java.security.accesscontrolexception: access denied ("java.lang.runtimepermission" "getclassloader") @ com.google.appengine.runtime.request.process-84bc59f0ba240851(request.java) @ java.security.accesscontrolcontext.checkpermission(accesscontrolcontext.java:382) @ java.security.accesscontroller.checkpermission(accesscontroller.java:572) @ java.lang.securitymanager.checkpermission(securitymanager.java:549) @ java.lang.classloader.checkclassloaderpermission(classloader.java:1606) @ java.lang.class

c# - Dapper escape sp_tables procedure error -

am trying use dapper execute sp_tables stored procedure , escape procedure name follows still getting error. var procname = @"sp_tables @table_type = ""'type', 'table'"""; var tables = con.query(procname, commandtype: commandtype.storedprocedure); for future reference how solved it. var tables = con.query("sp_tables", new { table_type = @"""'type', 'table'""" }, commandtype: commandtype.storedprocedure);

Importing a SASS file from outside of a rails app -

i'm trying @import external sass file rails app no luck. the folder structure follows - / - external_dir - sass - main.sass <-- file need - rails_app - app - assets - stylesheets - app.sass <-- file should imported i've tried using relative paths (../../../../external_dir/sass/main), absolute paths (/external_dir/sass/main) , symlinks nothing working. have ideas? can't continue without these other styles , don't want have copy them over. in advance. as cimmanon said in comments duplicate of sass: import file different directory? the issue had @imports in external sass files using relative paths current directory wasn't able access. updating @imports paths accessible current working directory, sass able import correctly.

perl - HASH element from an object's return in a single string -

i have module module.pm function gethash() returns, guessed, hash of data)). know how element form hash, using standard model: use module; $m = new module; %hash = $m->gethash(); print $hash{needed_element's_key}; everything ok. if need write 2 last strings in single string without initializing new hash (and occupying memory whole hash, using 1 element)? is possible somehow? like, say, $m->gethash()->{needed_element's_key}; of course, given example not work. suggestions? thanks! it's impossible return hash. subs can return list of scalars. assigning list of scalars existing hash my %hash , getting element of hash. you disguise fact creating new hash using anonymous hash: my $val = { $m->getkeyvalpairs() }->{$key}; alternatively, custom filter more efficient: sub find_val { $target_key = shift; while (@_) { $key = shift; $val = shift; return $val if $key eq $target_key; } return undef; } $val = fi

multithreading - Consume non-overlapping vector chunks, and combine results -

i'm trying speed expensive computation on large vector using threads. function consumes vector, computes vector of new values (it doesn't aggregate, input order has retained), , returns it. however, i'm struggling figure out how spawn threads, assign vector slices each, , collect , combine results. // tunable const numthreads: i32 = 4; fn f(val: i32) -> i32 { // expensive computation let res = val + 1; res } fn main() { // choose odd number of elements let orig = (1..14).collect::<vec<i32>>(); let mut result: vec<vec<i32>> = vec!(); let mut flat: vec<i32> = vec::with_capacity(orig.len()); // split slices chunk in orig.chunks(orig.len() / numthreads usize) { result.push( chunk.iter().map(|&digit| f(digit)).collect() ); }; // flatten result vector subvec in result.iter() { elem in subvec.iter() { flat.push(elem.to_ow

ggplot2 - R/Knitr/ggplot - set default line width for entire document -

i know how change line graph using aes geom_line, adjusts line individual graph it's bound to. how can specify line entire graph? in way similar how can adjust font size document graphs: theme_set(theme_gray(base_size = 28)) thanks! i hope wrong, not believe possible in way request.

javascript - How can I change this PhantomJS script to NodeJS for web scraping -

this phantomjs script use scraping html dom in web page. use waiting dom ready //scrap_phantom.js var server = require("webserver").create(); var page = require("webpage").create(); var port = require('system').env.port || 3000; var url = "http://www.example.com"; server.listen(port, function (request, response) { function onpageready() { var htmlcontent = page.evaluate(function () { return document.documentelement.outerhtml; }); response.write(htmlcontent); response.close(); phantom.exit(); } page.open(url, function (status) { function checkreadystate() { settimeout(function () { var readystate = page.evaluate(function () { return document.readystate; }); if ("complete" === readystate) { onpageready(); } else { checkreadysta

ios - Update Subview in a Xib while animating bounds of superview -

i working on animating in modal-like window, has been built in xib using auto-layout constraints. attempting make appear grow uitableviewcell on tap. i've noticed superview animate it's bounds (width , height) using cakeyframeanimation(keypath: "bounds.size"), while none of it's subviews change @ all. i not want use catransform3d ends distorting images , text in subview.i've tried layoutifneeded() before , after animation, doesn't seem make difference on animating subviews.i tried snapshotting, not work because view not rendered on screen until animation begins. any thoughts on making work appreciated.

C gl-matrix, how to create vectors and matrices? -

it's code vec3.c in gl-matrix. vec3_t vec3_create(vec3_t vec) { vec3_t dest = calloc(sizeof(double_t), 3); if (vec) { dest[0] = vec[0]; dest[1] = vec[1]; dest[2] = vec[2]; } else { dest[0] = dest[1] = dest[2] = 0; } return dest; } how can crate new vector using function? how create vector different values? trying set double values array this: vec3_t vec; vec3_t vec3_create(vec); vec[0] = 1.0; vec[1] = 0.0; vec[2] = 0.0; but exc_bad_access. have same problem matrices. code in mat4.c in gl-matrix. mat4_t mat4_create(mat4_t mat) { mat4_t dest = calloc(sizeof(double), 16); if (mat) { dest[0] = mat[0]; dest[1] = mat[1]; dest[2] = mat[2]; dest[3] = mat[3]; dest[4] = mat[4]; dest[5] = mat[5]; dest[6] = mat[6]; dest[7] = mat[7]; dest[8] = mat[8]; dest[9] = mat[9]; dest[10] = mat[10]; dest[11] = mat[11]; dest[12] = mat[12]; dest[13] = mat[13]; dest[14] = mat[14]; dest[15] = mat[15]; } return

matlab - Error in using fzero -

i trying solve non-linear equation using while loop in matlab it's not giving me results , give me error in line uses fzero function. why happens? how solve issue? me this? in advance. function z=optp(z,p) z=3.067; p=0; while (z-p) > 0.8 syms y q p p=z; w=3; c=1; p=5; b=1.2; c=8; b=0.5; r=a^b*c*p^-b; q=(0.5-1/(p+5))*2400*((a^0.5)/(p^(6/5))); x=q; j1=int(int(a*x*0.01,y,a*x/r,100),a,0,q/x); j2=(b*x^2*0.01/r)*int(a^2*1,a,0,q/x); j3=(p*r*b/p)*(int(int(y*0.01,y,a*x/r,100),a,0,q/x)); j4=(b*r^2/x)*int(y^2*0.01,y,0,q/r); j5=(r*0.2)*(int(int(y*0.01,a,y*r/x,1),y,0,q/r)); j=j1+j3+j4-j2-j5; z=fzero(@ (p) j,p) end end

coding style - C conventions - how to use memset on array field of a struct -

i wold settle argument proper usage of memset when zeroing array field in struct (language c). let have following struct: struct my_struct { int a[10] } which of following implementations more correct ? option 1: void f (struct my_struct * ptr) { memset(&ptr->a, 0, sizeof(p->a)); } option 2: void f (struct my_struct * ptr) { memset(ptr->a, 0, sizeof(p->a)); } notes: if field of primitive type or another struct (such 'int') option 2 not work, , if pointer (int *) option 1 not work. please advise, for non-compound type, not use memset @ all, because direct assignment easier , potentially faster. allow compiler optimizations function call not. for arrays, variant 2 works, because array implictily converted pointer most operations. for pointers, note in variant 2 value of pointer used, not pointer itself, while array, pointer to array used. variant 1 yields address of object itself. pointer, of po

sql - Update existing records based on the order from a different column -

i have following table: x_id x_name x_type x_sort_id 10 book 1 null 20 pen 1 null 30 watch 2 null 5 tent 3 null what i'm trying achieve populate x_sort_id column incremented values starting 1 based on value in x_id. table this: x_id x_name x_type x_sort_id 10 book 1 2 20 pen 1 3 30 watch 2 4 5 tent 3 1 i need update table existing rows. records added in future use sequence set x_sort_id field next value. the query came not need. update x_items set x_sort_id = (select max(x_id) x_items) + rownum x_sort_id null; i use rownum, assign value of 4 last record x_id = 5, not wanted. i'd thankful suggestions. can use oracle row_number : update query update items ot set x_sort_id = ( select rw ( select x_id, row_number() on ( order x_id ) rw items ) it.x_id = ot.x_id ) ; result table +------+--------+--------+-

debugging - How to set up symbols in WinDbg? -

i using debugging tools windows , following error message when starting windbg / cdb or ntsd: symbol search path is: *** invalid *** **************************************************************************** * symbol loading may unreliable without symbol search path. * * use .symfix have debugger choose symbol path. * * after setting symbol path, use .reload refresh symbol locations. * **************************************************************************** when executing arbitrary commands, error message *** error: module load completed symbols not loaded <module>.<ext> and following seems related: ********************************************************************* * symbols can not loaded because symbol path not initialized. * * * * symbol path can set by: * * using _nt_symbol_path environment variable. *

selenium webdriver - Python UnicodeEncodeError: 'charmap' codec can't encode character '\u2014' in position 15: character maps to <undefined> -

from selenium import webdriver selenium.webdriver.common.keys import keys import unittest driver = webdriver.firefox() driver.maximize_window() driver.implicitly_wait(30) driver.get('http://habrahabr.ru/') q = driver.find_elements_by_xpath("//h1[@class='title']/a[@class='post_title']") driver.close() w in q: print(w.text) fails specific characters. adding .encode('utf-8') helps fail makes output this: b'\xd0\xa7\xd1\x82\xd0\xbe \xd0. converting w.text string doesn't either. appreciate explanation , solution! thanks!

java - PowerMock - How to call manipulate the parameters of a mocked method -

i'm using powermock/easymock test static method in 1 of parameters stringbuffer appended method in mocked class. this simplified class demonstrate. import java.util.date; public class contentchanger { public static int change(stringbuffer sb) { sb.append( new date() ); return 0; } } and here unit test... import org.easymock.easymock; import org.junit.test; import org.junit.runner.runwith; import org.powermock.api.easymock.powermock; import org.powermock.core.classloader.annotations.preparefortest; import org.powermock.modules.junit4.powermockrunner; @runwith(powermockrunner.class) @preparefortest(contentchanger.class) public class contentchangertest { @test public void test001() { // declare empty stringbuffer stringbuffer var = new stringbuffer(); // enable static mocking contentchanger class powermock.mockstatic( contentchanger.class ); // catch call , send test method easymock.expect(contentchanger.c

javascript - Keep form window open when form is submitted -

Image
consider image iframe window when user clicks on link. my problem when user clicks deposit form gets submitted , the window closes , user not know if deposit successful or not. what want do i looking way keep iframe window open after form has been submitted, display appropriate message form html <form name="depform" action="" id="register_form" method="post"> user name<br /><input type="text" name="uname" value="" /><br /> credit card nr<br /><input type="text" name="cc" value="" /><br /> csv nr<br /><input type="text" name="csv" value="" /><br /> amount<br /> <input type="text" name="amount" value="" /><br /> <input type="submit" value="deposit" na

ruby on rails - RSpec mocking response attribute -

i'm stuck small issue can't seem find on rspec doc (or elsewhere). suspect it's because it's trying http call unsure. i'm attempting mock response in controller, actual response coming straight aws-sdk (so it's external service). controller: response = { snapshot_id: client.copy_snapshot({foo, bar}).snapshot_id } is possible stub .snapshot_id? _spec.rb before allow(client).to receive(:copy_snapshot).and_return('something') put :update, format: :json puts json.parse(response.body) end the tests passes without adding .snapshot_id on controller page , can see {"snapshot_id"=>"something"} otherwise "this resource unavailable." adding in, i'm lost if i'm doing wrong or if intended behavior. the reasoning when server on response back, omitting snapshot_id causes server hang amazon returns lot of data (headers, etc) any appreciated.

html - What is the advantage of using .btn class inside a <div> vs inside a <button>? -

i have code that's loosely based on css of bootstrap. 1 thing did different placed .btn class inside button. seems there many times when spacing different , cannot work out why. can give me advice here. nono place .btn inside <button> element instead of <div> when using of standard css bootstrap? my guess permits visually customize more element when using div (or a tag) when using button tag since button tag has more associated attributes.

Can I apply 100% SEO to angularjs or generating pages at server side is more effective? -

i'm creating shopping , advertising web site , i'm going create public api @ server side , let other devices connect that. i'm going use angularjs client side web browsers,but seo important me . i know seo achievable in angular using phantomjs , prerender.io , , other tools. but question : do 100% seo using these tools or generating pages @ server side better decision? no, not automatically 100% seo, because inserting robots meta tags, canonical links etc in header not easy task in angular.js. can't implement full blown seo without tags. if pregenerate on server side, may have more control on these.

node.js - Sqlite module installs properly on Azure Web App during deploy, but uses different version of module at runtime. -

i attempting sqlite database in node app hosted on azure websites. i've listed sqlite3 in dependencies field of package.json : "sqlite3": "^3.0.8" when deploy, see following during install: remote: [sqlite3] success: "d:\home\site\wwwroot\node_modules\sqlite3\lib\binding\node-v11-win32-ia32\node_sqlite3.node" installed via remote however, every request returns 500 error, checked out app log. when @ application log, see following error each deploy: mon jun 29 2015 17:13:51 gmt+0000 (coordinated universal time): unaught exception: error: cannot find module 'd:\home\site\wwwroot\node_modules\sqlite3\lib\binding\node-v14-win32-ia32\node_sqlite3.node if notice, when running application looks node_modules\sqlite3\lib\binding\node-v14-win32-ia32\node_sqlite3.node installed node_modules\sqlite3\lib\binding\node-v11-win32-ia32\node_sqlite3.node . don't understand enough servers in general, or node's environment figure out ho

c - Why is `switch` so slow? -

in bytecode interpreting loop, after several tests, i'm surprised see using switch worst choice make. making calls function pointer array, or using gcc's computed goto extension 10~20% faster, computed goto version being fastest. i've tested real toy vm 97 instructions , mini fake vm pasted below. why using switch slowest? #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <inttypes.h> #include <time.h> enum { add1 = 1, add2, sub3, sub4, mul5, mul6, }; static unsigned int number; static void add1(void) { number += 1; } static void add2(void) { number += 2; } static void sub3(void) { number -= 3; } static void sub4(void) { number -= 4; } static void mul5(void) { number *= 5; } static void mul6(void) { number *= 6; } static void interpret_bytecodes_switch(uint8_t *bcs) { while (true) { switch (*bcs++) { case 0: return; ca

java - Reading *.xls file throws BiffException: Unable to recognize OLE stream -

i created .xls file. when read , add data using swing, working fine . but after adding values xls if want read again throwing following error jxl.read.biff.biffexception: unable recognize ole stream @ jxl.read.biff.compoundfile.<init>(compoundfile.java:116) @ jxl.read.biff.file.<init>(file.java:127) @ jxl.workbook.getworkbook(workbook.java:221) @ jxl.workbook.getworkbook(workbook.java:198) @ codes.operationclass.gettableready(operationclass.java:34) @ designs.viewstock.rbuttonallstockactionperformed(viewstock.java:181) @ designs.viewstock.access$0(viewstock.java:180) @ designs.viewstock$1.actionperformed(viewstock.java:50) @ javax.swing.abstractbutton.fireactionperformed(abstractbutton.java:2018) @ javax.swing.abstractbutton$handler.actionperformed(abstractbutton.java:2341) @ javax.swing.defaultbuttonmodel.fireactionperformed(defaultbuttonmodel.java:402) @ javax.swing.jtogglebutton$togglebuttonmodel.setpressed(jtogglebutton.java:308) @ javax.swing.plaf.basic.basic

php - Symfony key array in twig -

i want show information 1 entity. the entity has information related , use query obtain information. class playlist { private $id; private $name; private $items; public function __construct() { $this->items = new \doctrine\common\collections\arraycollection(); } public function additem(\publicartel\appbundle\entity\playlistcontent $content) { $content->setplaylist($this); $this->items->add($content); return $this; } public function removeitem(\publicartel\appbundle\entity\playlistcontent $content) { $this->items->removeelement($content); } public function getitems() { return $this->items; } } class playlistcontent { private $content; public function setcontent(\publicartel\appbundle\entity\content $content = null) { $this->content = $content; return $this; } public function getcontent() { retu