title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
Powershell error when using loaded assembly
<p>I’m having a problem with using zip compression in a Powershell script. The code snippet in question is:</p> <pre><code>$zipfile = $targetFile $file = 'Script.ps1' $stream = New-Object IO.FileStream($zipfile, [IO.FileMode]::Open) $mode = [System.IO.Compression.ZipArchiveMode]::Update $zip = New-Object IO.Compression.ZipArchive($stream, $mode) ($zip.Entries | ? { $file -contains $_.Name }) | % { $_.Delete() } # Add a newer Script.ps1 file with the new Comment Based Help template. $newFile = "$PSScriptRoot\$file" [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,$newFile,"Script.ps1","optimal") # Clean up. $zip.Dispose() $stream.Close() $stream.Dispose() </code></pre> <p>The code attempts to delete a file from the archive and then add a newer version of the same file. When I run the script, I receive the following:</p> <blockquote> <p>[ERROR] Unable to find type [System.IO.Compression.ZipArchiveMode]. Make sure that the [ERROR] assembly that contains this type is loaded. [ERROR] At C:\xxxxx\xxxxx\xxxxx\PowerShellIDEInstallers\PowerShel [ERROR] lIDEInstallers\VSInstallCBH.ps1:141 char:2 [ERROR] + $mode = [System.IO.Compression.ZipArchiveMode]::Update [ERROR] +<br> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ERROR] + CategoryInfo : InvalidOperation: (System.IO.Compression.ZipArch [ERROR] iveMode:TypeName) [], RuntimeException [ERROR] + FullyQualifiedErrorId : TypeNotFound [ERROR]</p> </blockquote> <p>However, if I run it again, it will work correctly. I found a few posts (<a href="https://stackoverflow.com/questions/12923074/how-to-load-assemblies-in-powershell">this</a> and <a href="https://stackoverflow.com/questions/29007742/unable-to-use-system-io-compression-filesystem-dll">this</a>) that spoke of similar problems. I’m currently using:</p> <pre><code>Add-Type -AssemblyName System.IO.Compression.FileSystem </code></pre> <p>At the top of the script. I also found <a href="http://tfl09.blogspot.co.uk/2010/08/using-newer-versions-of-net-with.html" rel="nofollow noreferrer">this post</a> which looked promising, but, did not work. I should also add that the problem occurs in the ISE, Visual Studio, and the command prompt. The code will work if I run it a second time in any of the environments.</p> <p>I’m baffled and at a loss. Can anyone tell me why this is happening?</p>
2
tvOS Button Action
<p>I create a UIButton in tvOS via Swift</p> <pre><code>let randomBtn = UIButton() randomBtn.setTitle("Zufällig", forState: .Normal) let RndNormal = UIImage(named: "RndNormal") let RndHoover = UIImage(named: "RndHoover") randomBtn.setImage(RndNormal, forState: .Normal) randomBtn.setImage(RndHoover, forState: .Focused) randomBtn.setTitleColor(UIColor.blackColor(), forState: .Normal) randomBtn.setTitleColor(UIColor.whiteColor(), forState: .Focused) randomBtn.addTarget(self, action: #selector(ViewController.click(_:)), forControlEvents: UIControlEvents.TouchUpInside) let screenSize: CGRect = UIScreen.mainScreen().bounds let screenWidth = screenSize.width randomBtn.frame = CGRect(x: screenWidth - 150, y: 60 , width: 70 , height: 70) self.view.addSubview(randomBtn) </code></pre> <p>But the action never get fired if I press the button, is there anything different in tvOS?</p> <pre><code>func click(sender: UIButton) { print("click") } </code></pre>
2
Calculate average in scala
<p>I'm getting a session from database which content result which content dimensions, now I'm trying to calculate average for dimensions:</p> <pre><code>sessionService.findById(sessionId).map { case Some(session) =&gt; val result = session.result.getOrElse(Seq.empty) for (dimension &lt;- result.dimensions) { var test += dimension.average } Ok(Json.toJson(session)).as("application/json") case None =&gt; NotFound(Json.toJson("Not found")) } </code></pre> <p>but I get this error : <a href="https://i.stack.imgur.com/cE7ar.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cE7ar.png" alt="enter image description here"></a></p> <p>UPDATE :</p> <p>When trying </p> <pre><code>var test = 0 for (dimension &lt;- result.dimensions) { test += dimension.average } </code></pre> <p>I get this error:</p> <p><a href="https://i.stack.imgur.com/YHAN5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YHAN5.png" alt="enter image description here"></a></p>
2
How to make Netty client read entire response
<p>I have a Camel route that communicates with a COBOL server using a TCP socket connection. The route basically looks like this:</p> <pre><code>&lt;route&gt; &lt;from uri="direct:sendMessage" /&gt; &lt;log message="Sending message to server: ${body}" /&gt; &lt;to uri="netty4:tcp://hostname:1234?requestTimeout=2000&amp;amp;encoding=windows-1252" /&gt; &lt;log message="Received response from server: ${body}" /&gt; &lt;/route&gt; </code></pre> <p>Calling this route results in the following exception:</p> <pre><code>Failed delivery for (MessageId: ID-vmuxfusepoc01-34999-1467706512020-14-2 on ExchangeId: ID-vmuxfusepoc01-34999-1467706512020-14-1). Exhausted after delivery attempt: 1 caught: io.netty.handler.codec.TooLongFrameException: Adjusted frame length exceeds 1048576: 1008807217 - discarded Message History --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor Elapsed (ms) [sendMessage ] [to51 ] [direct:sendMessage ] [ 697] [sendMessage ] [log60 ] [log ] [ 0] [sendMessage ] [to53 ] [netty4:tcp://jadev:7616?requestTimeout=2000&amp;encoding=windows-1252 ] [ 691] Exchange --------------------------------------------------------------------------------------------------------------------------------------- Exchange[ Id ID-vmuxfusepoc01-34999-1467706512020-14-1 ExchangePattern InOut Headers {breadcrumbId=ID-vmuxfusepoc01-34999-1467706512020-14-2, CamelHttpMethod=POST, CamelHttpPath=, CamelHttpQuery=null, CamelHttpServletRequest=(POST /message)@927654619 org.eclipse.jetty.server.Request@374ae2db, CamelHttpServletResponse=HTTP/1.1 500 Content-Type: text/plain;charset=ISO-8859-1 , CamelHttpUri=/message, CamelHttpUrl=http://localhost:8282/message, CamelRedelivered=false, CamelRedeliveryCounter=0, CamelServletContextPath=/message, Content-Length=690, Content-Type=null, Host=localhost:8282} BodyType String Body uid:dev2016070412325814024903532ºS:bookinfoºbkd0001:017953491ºcmn0001:wdedul01 ] Stacktrace --------------------------------------------------------------------------------------------------------------------------------------- io.netty.handler.codec.TooLongFrameException: Adjusted frame length exceeds 1048576: 1008807217 - discarded at io.netty.handler.codec.LengthFieldBasedFrameDecoder.fail(LengthFieldBasedFrameDecoder.java:501)[io.netty:netty-codec:4.0.27.Final] at io.netty.handler.codec.LengthFieldBasedFrameDecoder.failIfNecessary(LengthFieldBasedFrameDecoder.java:477)[io.netty:netty-codec:4.0.27.Final] at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:403)[io.netty:netty-codec:4.0.27.Final] at io.netty.handler.codec.serialization.ObjectDecoder.decode(ObjectDecoder.java:69)[io.netty:netty-codec:4.0.27.Final] at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:343)[io.netty:netty-codec:4.0.27.Final] at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:315)[io.netty:netty-codec:4.0.27.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:229)[io.netty:netty-codec:4.0.27.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)[io.netty:netty-transport:4.0.27.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)[io.netty:netty-transport:4.0.27.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)[io.netty:netty-transport:4.0.27.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)[io.netty:netty-transport:4.0.27.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)[io.netty:netty-transport:4.0.27.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)[io.netty:netty-transport:4.0.27.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)[io.netty:netty-transport:4.0.27.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)[io.netty:netty-transport:4.0.27.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)[io.netty:netty-common:4.0.27.Final] at java.lang.Thread.run(Thread.java:745)[:1.7.0_101] </code></pre> <p>After adding <code>textline=true</code> to the netty url the request is send correctly but only the first line of the servers response is returned by Netty to Camel. The server returns about 100 lines of text and then closes the connection.</p> <p>I've tried using StringEncoder and StringDecoder but this gives me the same result as 'textline=true'.</p> <p><strong>My question is:</strong> How can I configure Netty to return the entire response of the server as a String. Message delimiters are of no concern because exactly 1 message will be returned before the connection is closed by the server.</p>
2
Exception : java.net.MalformedURLException: no protocol: /setwindowsagentaddr
<p>I want to develop a HTTP Proxy , The code is here ; When I run my code , I get this exception :</p> <p>Started on: 9999 request for : /setwindowsagentaddr Encountered exception: java.net.MalformedURLException: no protocol: /setwindowsagentaddr</p> <pre><code>package proxy; import java.net.*; import java.io.*; public static void main(String[] args) throws IOException { ServerSocket serverSocket = null; boolean listenning = true; // String host="192.168.1.10"; int port = 9999; try{ port = Integer.parseInt(args[0]); }catch(Exception e){ } try{ serverSocket = new ServerSocket(port); System.out.println("Started on: " + port); }catch(Exception e){ // System.err.println("Could not listen on port: " + args[0]); System.exit(0); } while(listenning){ new ProxyThread(serverSocket.accept()).start(); } serverSocket.close(); } </code></pre> <p>}</p> <p>and the ProxyThread here :</p> <pre><code>public class ProxyThread extends Thread { private Socket socket = null; private static final int BUFFER_SIZE = 32768; public ProxyThread(Socket socket){ super("Proxy Thread"); this.socket=socket; } public void run(){ try { DataOutputStream out = new DataOutputStream(socket.getOutputStream()); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String inputLine , outputLine; int cnt = 0 ; String urlToCall=""; //get request from client // socket.getPort(); while((inputLine=in.readLine()) != null){ try{ StringTokenizer tok = new StringTokenizer(inputLine); tok.nextToken(); }catch(Exception e){ break; } ///parse the first line of the request to get url if(cnt==0){ String [] tokens = inputLine.split(" "); urlToCall = tokens[1]; System.out.println("request for : "+ urlToCall); } cnt++; } BufferedReader rd = null; try{ //System.out.println("sending request //to real server for url: " // + urlToCall); /////////////////////////////////// //begin send request to server, get response from server URL url = new URL(urlToCall); URLConnection conn = url.openConnection(); conn.setDoInput(true); //not doing http post conn.setDoOutput(false); System.out.println("Type is : "+ conn.getContentType()); System.out.println("length is : "+ conn.getContentLength()); System.out.println("allow user interaction :"+ conn.getAllowUserInteraction()); System.out.println("content encoding : "+ conn.getContentEncoding()); System.out.println("type is : "+conn.getContentType()); // Get the response InputStream is = null; HttpURLConnection huc = (HttpURLConnection) conn; if (conn.getContentLength() &gt; 0) { try { is = conn.getInputStream(); rd = new BufferedReader(new InputStreamReader(is)); } catch (IOException ioe) { System.out.println( "********* IO EXCEPTION **********: " + ioe); } } //end send request to server, get response from server //begin send response to client byte [] by = new byte[BUFFER_SIZE]; int index = is.read(by,0,BUFFER_SIZE); while ( index != -1 ) { out.write( by, 0, index ); index = is.read( by, 0, BUFFER_SIZE ); } out.flush(); //end send response to client }catch(Exception e){ //can redirect this to error log System.err.println("Encountered exception: " + e); //encountered error - just send nothing back, so //processing can continue out.writeBytes(""); } //close out all resources if (rd != null) { rd.close(); } if (out != null) { out.close(); } if (in != null) { in.close(); } if (socket != null) { socket.close(); } } catch (Exception e) { e.printStackTrace(); } } </code></pre> <p>How can I fix this exceptions?</p>
2
Google Maps API Drawing Polygon - overlaycomplete event only returns one set of coordinates?
<p>I have this event listener for when a shape is created:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>// This example requires the Drawing library. Include the libraries=drawing // parameter when you first load the API. For example: // &lt;script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&amp;libraries=drawing"&gt; function initMap() { var map = new google.maps.Map(document.getElementById('map'), { center: {lat: -33.872, lng: 151.252}, zoom: 6 }); var drawingManager = new google.maps.drawing.DrawingManager({ drawingMode: google.maps.drawing.OverlayType.POLYGON, drawingControl: false, drawingControlOptions: { position: google.maps.ControlPosition.TOP_LEFT, drawingModes: [] }, polygonOptions: { fillColor: 'rgba(255, 0, 0, 0.2)', fillOpacity: 1, strokeWeight: 2, clickable: true, editable: true, zIndex: 1 } }); drawingManager.setMap(map); // Define the LatLng coordinates for the outer path. var outerCoords = [ {lat: -25.364, lng: 155.207}, // north west {lat: -35.364, lng: 155.207}, // south west {lat: -35.364, lng: 148.207}, // south east {lat: -25.364, lng: 148.207} // north east ]; map.data.add({geometry: new google.maps.Data.Polygon([outerCoords])}); google.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) { if(event.type == 'polygon') { var verticles = event.overlay.getPaths(); verticles.forEach(function(verticle, ind){ console.log({ "index": ind, "lat": verticle.getAt(ind).lat(), "lng": verticle.getAt(ind).lng(), "obj": verticle.getAt(ind) }); }); } }); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width"&gt; &lt;title&gt;JS Bin&lt;/title&gt; &lt;style&gt; html, body { height: 100%; margin: 0; padding: 0; } #map { height: 100%; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="map"&gt;&lt;/div&gt; &lt;div id="capture"&gt;&lt;/div&gt; &lt;!-- Replace the value of the key parameter with your own API key. --&gt; &lt;script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBFOolEMjIlnlkVle8gsiDA1ym3aktxEGc&amp;libraries=drawing&amp;callback=initMap" async defer&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>However, .getPaths() seem to return only one set of lat/lng, regardless of how many lines my Polygon consists of. From the documentation it seemed that it should return an array of objects, where each one is an array of two points (lat/lng) needed to draw the line. What am I missing? </p>
2
Vagrant "Timed out while waiting for the machine to boot."
<p>I had a previously working setup with vagrant 1.8.1 and virtualbox 5.0.22, but after upgrading to vagrant 1.8.5 and 5.1.0, i now get the dreaded "Timed out while waiting for the machine to boot."</p> <p>Any options other than downgrading?</p> <p>Full output:</p> <pre><code>Bringing machine 'centos7' up with 'virtualbox' provider... ==&gt; centos7: Importing base box 'centos/7'... ==&gt; centos7: Matching MAC address for NAT networking... ==&gt; centos7: Checking if box 'centos/7' is up to date... ==&gt; centos7: Setting the name of the VM: centos7-openvpn ==&gt; centos7: Clearing any previously set network interfaces... ==&gt; centos7: Preparing network interfaces based on configuration... centos7: Adapter 1: nat centos7: Adapter 2: bridged ==&gt; centos7: Forwarding ports... centos7: 22 (guest) =&gt; 2222 (host) (adapter 1) ==&gt; centos7: Running 'pre-boot' VM customizations... ==&gt; centos7: Booting VM... ==&gt; centos7: Waiting for machine to boot. This may take a few minutes... centos7: SSH address: 127.0.0.1:2222 centos7: SSH username: vagrant centos7: SSH auth method: private key centos7: Warning: Remote connection disconnect. Retrying... centos7: centos7: Vagrant insecure key detected. Vagrant will automatically replace centos7: this with a newly generated keypair for better security. centos7: centos7: Inserting generated public key within guest... centos7: Removing insecure key from the guest if it's present... centos7: Key inserted! Disconnecting and reconnecting using new SSH key... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... centos7: Warning: Authentication failure. Retrying... Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period. If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong. If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly, as well. If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value. </code></pre>
2
data-target not working for dropdown menus in bootstrap
<p>I have index.html as home webpage with fixed nav-bar and i used scrollspy to navigate menu items. I created one other webpage with same nav-bar as in index.html page, now i like to link this second webpage menu's in dropdown with scrollspy div ID of home webpage i.e. in index.html page. My index.html file as like,</p> <pre><code>&lt;body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60"&gt; &lt;!-- navigation bar --&gt; &lt;div id="navigationbar"&gt; &lt;nav class="navbar navbar-default navbar-fixed-top" role="navigation"&gt; &lt;div class="container-fluid"&gt; &lt;!-- Brand and toggle get grouped for better mobile display --&gt; &lt;div class="navbar-header"&gt; &lt;ul&gt;&lt;a class="navbar-brand" href="#"&gt; &lt;strong&gt;COMPANY&lt;/strong&gt;&lt;/a&gt;&lt;/ul&gt; &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"&gt; &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"&gt; &lt;ul class="nav menu nav navbar-nav navbar-nav navbar-right"&gt; &lt;li class=""&gt;&lt;a href="index.html"&gt;Home&lt;span class="sr-only"&gt;&lt;/span&gt; &lt;/a&gt;&lt;/li&gt; &lt;li class="dropdown"&gt; &lt;a href="abc.html" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;About Us&lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt; &lt;ul class="dropdown-menu dropdown-menu-left"&gt; &lt;li id="dp1"&gt;&lt;a href="#pilot"&gt;menu1&lt;/a&gt;&lt;/li&gt; &lt;li id="dp2"&gt;&lt;a href="#design"&gt;menu2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#contact"&gt;contact&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#in-touch"&gt;social&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/nav&gt; &lt;/div&gt; &lt;div class="container-fluid"&gt; &lt;div id="pilot"&gt;&lt;p&gt;div1&gt;&lt;/p&gt;&lt;/div&gt; &lt;div id="design"&gt;&lt;p&gt;div2&gt;&lt;/p&gt;&lt;/div&gt; &lt;div id="contact"&gt;&lt;p&gt;div3&gt;&lt;/p&gt;&lt;/div&gt; &lt;div id="social"&gt;&lt;p&gt;div4&gt;&lt;/p&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>Now I have another webpage with same navigation bar and I like to call that id elements from index.html page to this second web page, for that, I have given data-target as below which works for nav-bar menus but not working for drop-down menus but still not working,</p> <p>working for contact tab- <li>contact</li></p> <p>but not working for dropdown menu1</li></p> <p>is there any solution...?</p>
2
Android App crashes when running on Windows 10 and VS2015 Android Emulator
<p>Been trying to figure this out for a while but with no luck...</p> <p><strong>Background:</strong></p> <p>I am trying to run a Xamarin.Forms application within an Android Emulator through Visual Studio 2015 (update 3) on Windows 10. I installed all the required Android SDK and also ran against different emulators ranging from 4.4 Kitkat to 6.0 Marshmellow and I get the same results. The app is built with Xamarin.Forms with the pages in a portable C#/XAML project. #rd paty library FreshMVVM is used for IOC and ViewModels</p> <p><strong>Issue</strong></p> <p>The app mostly starts up first time but I typically have to wait 20-30 sec after deploy to run the app otherwise the app crashes straight away but the real issue is that when I get to the first page with a button on it (navigating to LoginPageModel), clicking the button will crash the app. The logcat Android Device Logging Window prints out the following during the crash... (sensitive info masked)</p> <p>Things I have tried:</p> <ul> <li>Removing constructor code from LoginPageModel class ... no change</li> <li>Removing XAML. Mostly works but experience is inconsistant. Maybe related to the Xamarin forms controls?</li> <li><p>Conrols used are: ContentPage, Image, ContentView, StackLayout, Entry, Label, Switch, Button</p> <p>D/Mono ( 1585): Assembly Ref addref MyCompany[0xb7d43920] -> Xamarin.Insights[0xb7d3e690]: 3 I/MyCompany.REALAPI( 1585): Constructing ApiService. I/MyCompany.LOGIN( 1585): AuthenticationRepositoryService is being constructed I/MyCompany.LOGIN( 1585): Instantiating new LoginPageModel. D/DonatelloNative_Selector( 134): Removing selector for fd 33 W/InputDispatcher( 464): channel 'a94e5108 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9 D/DonatelloNative_Selector( 134): Removing selector for fd 32 E/InputDispatcher( 464): channel 'a94e5108 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity (server)' ~ Channel is unrecoverably broken and will be disposed! W/InputDispatcher( 464): channel 'a941cf20 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9 E/InputDispatcher( 464): channel 'a941cf20 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed! W/InputDispatcher( 464): Attempted to unregister already unregistered input channel 'a94e5108 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity (server)' W/InputDispatcher( 464): Attempted to unregister already unregistered input channel 'a941cf20 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity (server)' I/WindowState( 464): WIN DEATH: Window{a94e5108 u0 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity} I/ActivityManager( 464): Process com.mycompany.feature (pid 1585) has died. W/ActivityManager( 464): Force removing ActivityRecord{a9308df8 u0 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity t14}: app died, no saved state I/WindowState( 464): WIN DEATH: Window{a941cf20 u0 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity} D/Zygote ( 139): Process 1585 terminated by signal (11) W/EGL_emulation( 692): eglSurfaceAttrib not implemented W/Binder ( 631): Caught a RuntimeException from the binder stub implementation. W/Binder ( 631): java.lang.NullPointerException W/Binder ( 631): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280) W/Binder ( 631): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129) W/Binder ( 631): at android.os.Binder.execTransact(Binder.java:404) W/Binder ( 631): at dalvik.system.NativeStart.run(Native Method) W/InputMethodManagerService( 464): Got RemoteException sending setActive(false) notification to pid 1585 uid 10054</p></li> </ul> <p>Not sure if it is related to Hyper-V, the Emulator itself or the 3rd Party components. Running the app as a Windows Universal app works fine. Other machines running Windows 8.1 works fine also</p>
2
Android NativeAppInstallAdView never shows the ad
<p>I have a problem with showing native app install ad view in one of my activities. As Google shows the implementation of native ads on: <a href="https://github.com/googleads/googleads-mobile-android-examples/tree/master/admob/NativeExample" rel="nofollow">https://github.com/googleads/googleads-mobile-android-examples/tree/master/admob/NativeExample</a> I have integrated the code to my project. Here is my gradle file:</p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.somepack.tests" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:recyclerview-v7:23.4.0' compile 'com.android.support:cardview-v7:23.4.0' compile 'com.google.android.gms:play-services-ads:9.2.0' compile 'com.google.firebase:firebase-ads:9.0.0' } apply plugin: 'com.google.gms.google-services' </code></pre> <p>And I have also added same code to my root gradle file:</p> <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } </code></pre> <p>I have tried to run the app with Google's app id and unit id, and everything seems to be working. When I change app id and unit id to my values, it just keeps saying 'Failed to load native ad' with the error code 0. </p> <p>And here is my activity:</p> <pre><code>import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.RatingBar; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.ads.AdListener; import com.google.android.gms.ads.AdLoader; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.MobileAds; import com.google.android.gms.ads.formats.NativeAd; import com.google.android.gms.ads.formats.NativeAppInstallAd; import com.google.android.gms.ads.formats.NativeAppInstallAdView; import java.util.List; public class AdActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ad); String ADMOB_APP_ID = getString(R.string.admob_app_id); // Initialize the Mobile Ads SDK. MobileAds.initialize(this, ADMOB_APP_ID); refreshAd(); } private AdRequest.Builder getBuilder() { AdRequest.Builder builder = new AdRequest.Builder(); if (BuildConfig.DEBUG) { builder.addTestDevice("BDFA4B1F1E11FDA72D43368841CF0E04"); } return builder; } private void refreshAd() { AdLoader.Builder builder = new AdLoader.Builder(this, getString(R.string.admob_unit_id)); builder.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() { @Override public void onAppInstallAdLoaded(NativeAppInstallAd ad) { FrameLayout frameLayout = (FrameLayout) findViewById(R.id.fl_adplaceholder); NativeAppInstallAdView adView = (NativeAppInstallAdView) getLayoutInflater() .inflate(R.layout.ad_app_install, null); populateAppInstallAdView(ad, adView); frameLayout.removeAllViews(); frameLayout.addView(adView); } }); AdLoader adLoader = builder.withAdListener(new AdListener() { @Override public void onAdFailedToLoad(int errorCode) { Toast.makeText(AdActivity.this, "Failed to load native ad: " + errorCode, Toast.LENGTH_SHORT).show(); } }).build(); adLoader.loadAd(getBuilder().build()); } private void populateAppInstallAdView(NativeAppInstallAd nativeAppInstallAd, NativeAppInstallAdView adView) { adView.setHeadlineView(adView.findViewById(R.id.appinstall_headline)); adView.setImageView(adView.findViewById(R.id.appinstall_image)); adView.setBodyView(adView.findViewById(R.id.appinstall_body)); adView.setCallToActionView(adView.findViewById(R.id.appinstall_call_to_action)); adView.setIconView(adView.findViewById(R.id.appinstall_app_icon)); adView.setPriceView(adView.findViewById(R.id.appinstall_price)); adView.setStarRatingView(adView.findViewById(R.id.appinstall_stars)); adView.setStoreView(adView.findViewById(R.id.appinstall_store)); // Some assets are guaranteed to be in every NativeAppInstallAd. ((TextView) adView.getHeadlineView()).setText(nativeAppInstallAd.getHeadline()); ((TextView) adView.getBodyView()).setText(nativeAppInstallAd.getBody()); ((Button) adView.getCallToActionView()).setText(nativeAppInstallAd.getCallToAction()); ((ImageView) adView.getIconView()).setImageDrawable(nativeAppInstallAd.getIcon() .getDrawable()); List&lt;NativeAd.Image&gt; images = nativeAppInstallAd.getImages(); if (images.size() &gt; 0) { ((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable()); } // Some aren't guaranteed, however, and should be checked. if (nativeAppInstallAd.getPrice() == null) { adView.getPriceView().setVisibility(View.INVISIBLE); } else { adView.getPriceView().setVisibility(View.VISIBLE); ((TextView) adView.getPriceView()).setText(nativeAppInstallAd.getPrice()); } if (nativeAppInstallAd.getStore() == null) { adView.getStoreView().setVisibility(View.INVISIBLE); } else { adView.getStoreView().setVisibility(View.VISIBLE); ((TextView) adView.getStoreView()).setText(nativeAppInstallAd.getStore()); } if (nativeAppInstallAd.getStarRating() == null) { adView.getStarRatingView().setVisibility(View.INVISIBLE); } else { ((RatingBar) adView.getStarRatingView()) .setRating(nativeAppInstallAd.getStarRating().floatValue()); adView.getStarRatingView().setVisibility(View.VISIBLE); } // Assign native ad object to the native view. adView.setNativeAd(nativeAppInstallAd); } } </code></pre> <p>I thought it doesn't show the ad because my apk is debug and tried with release too. But no chance. Am I missing a setting on Admob panel or any code that I need to implement? I am greatly appriciated for any help.</p> <p>P.S: The code I wrote above is just a trial, I have the same code in my real app, which is on Play Store, but could not succeed.</p>
2
failed to use iconv to change encoding in shell
<p>I have a file to convert its encoding. In terminal, I have :</p> <pre><code>$file -i * </code></pre> <p>and it turns out <code>text/plain; charset=us-ascii</code></p> <p>Then I have this command line :</p> <pre><code>$ iconv -f us-ascii -t UTF-8 oldfile.txt &gt; newfile.txt </code></pre> <p>It turns out a message: <code>iconv: illegal input sequence at position 2575661</code> </p> <p>I searched and found that this suggests there are invalid sequences (for instance this page <a href="https://spin.atomicobject.com/2011/07/13/some-useful-iconv-functionality/" rel="nofollow">https://spin.atomicobject.com/2011/07/13/some-useful-iconv-functionality/</a>). I am wondering what would be the most reliable way to convert the encoding to the most appropriate encoding to sqlite, and how to find the invalid sequences? Thank you!!</p>
2
In spark and scala, how to convert or map a dataframe to specific columns info?
<p>Scala.<br> Spark.<br> intellij IDEA. </p> <p>I have a dataframe (multiple rows, multiple columns) from CSV file.<br> And I want it maps to another specific column info.<br> I think scala class (not case class, because columns count > 22) or <code>map()</code>..... </p> <p>But I don't know how to convert them.</p> <p>Example</p> <p>a dataframe from CSV file.</p> <pre><code>---------------------- | No | price| name | ---------------------- | 1 | 100 | "A" | ---------------------- | 2 | 200 | "B" | ---------------------- </code></pre> <p>another specific columns info.</p> <pre><code> =&gt; {product_id, product_name, seller} </code></pre> <p>First, <code>product_id</code> is mapping to 'No'. Second, <code>product_name</code> is mapping to 'name'. Third, <code>seller</code> is <code>null</code> or ""(empty string).</p> <p>So, finally, I want a dataframe that have another columns info.</p> <pre><code>----------------------------------------- | product_id | product_name | seller | ----------------------------------------- | 1 | "A" | | ----------------------------------------- | 2 | "B" | | ----------------------------------------- </code></pre>
2
Combine draft-js with redux-form
<p>I have a form with 2 usual inputs where i can use this common approach:</p> <pre><code>&lt;input {...title} /&gt; </code></pre> <p>And also i have a draftJS editor in the form. I need to convert draftJS content to HTML (via <code>draft-js-export-html</code>) on submit, and load html to it on component mount process. How to combine it with redux-form?</p>
2
React Native : Call method of RCTViewManager and Render a View
<p>In React Native, It is possible to render a UIView of a RCTBridgeModule and also call method of this Module ? Below i post the module i have created with two method. but i don't know if its correct :</p> <p>RCTAugmentPlayerManager.h</p> <pre><code>#import "RCTBridgeModule.h" @interface RCTAugmentPlayerManager : NSObject &lt;RCTBridgeModule&gt; @end </code></pre> <p>RCTAugmentPlayerManager.m</p> <pre><code>@implementation RCTAugmentPlayerManager RCT_EXPORT_MODULE(); // Method which execute treatment RCT_EXPORT_METHOD(oneMethod:(NSString *)name ) { RCTLogInfo(@"Display name %@", name); } // Method which return a view to render in Javascript RCT_EXPORT_METHOD(methodWithReturnView) { UIView * view = [[UIView alloc] init]; return view; } @end </code></pre> <p>AugmentPlayer.js</p> <pre><code>import { NativeModules } from 'react-native'; var RCTAugmentPlayerManager = NativeModules.RCTAugmentPlayerManager; </code></pre> <p>index.ios.js</p> <pre><code>import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, NativeModules } from 'react-native'; class mobileApp extends Component { constructor(props){ super(props); var augment = NativeModules.AugmentPlayer; augment.oneMethod('test'); } render() { return ( &lt;View style={{height:200, width:200}}&gt; {AugmentPlayer.methodWithReturnView} &lt;/View&gt; ); } } AppRegistry.registerComponent('mobileApp', () =&gt; mobileApp); </code></pre> <p>Thank you </p>
2
React-router: difference between history.push and location.href in flux app?
<p>I'm a bit new with React, react-router, and flux, and I'm curious. I'm curious, what's the difference between the 2 types of link click handling. My feeling is <code>location.href</code> may "reset" the application, like if page was reloaded. Is that right or wrong? And what's the difference between the 2 methods? Cause I'm not always able to use <code>history.push</code> in the application.</p> <p>Thanks a lot in advance!</p>
2
How to make the Jump animations using curves smoothly?
<p>I've been working on an endless runner game using unity 5 engine studying some examples. I applied jump action to my character. It did work fine but I wanted it to be bit perfect so I implanted the jump using curves with this <a href="https://i.stack.imgur.com/asx0r.png" rel="nofollow noreferrer">example</a>, came across this issue. That is after applying curves for the character controller with some adjustments, now when I jump, the curves starting to adjust the controller after I touched a platform (the ground) which make the jump unrealistic. I did tried to achieve the jump using fixed Update method, since the game is an endless runner which basically updates everything frame by frame it did not work. How do I achieve a realistic jump? below is what I tried so far.</p> <pre><code>if (controller.isGrounded) { verticalVelocity = -0.5f; //upward thrust / jump height if (currentBaseState.fullPathHash == locoState) // is character in moving state { if (Input.GetButtonDown("Jump")) { verticalVelocity = 18f; anim.SetBool("Jump", true); } } else if (currentBaseState.fullPathHash == jumpState) //Is character in jump state { if (!anim.IsInTransition(0)) { if (useCurves) { controller.height = anim.GetFloat("ColliderHeight"); //get the controller height using curves controller.center = new Vector3(0f, anim.GetFloat("ColliderY"), 0f); //Get the controller Y axis using the curves (center of chr ctrlr) } anim.SetBool("Jump", false); } // Applying curves Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up); RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(ray, out hitInfo)) { print(ray.ToString()); if (hitInfo.distance &gt; 1.75f) { anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0, 1f, 0), 0), 0.03f, 0.6f); } } } } </code></pre> <p><a href="https://i.stack.imgur.com/asx0r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/asx0r.png" alt="Character jumping at start"></a> Character jumping at start</p> <p><a href="https://i.stack.imgur.com/mxWGV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mxWGV.png" alt="Char controller touching the ground"></a> Char controller touching the ground</p> <p><a href="https://i.stack.imgur.com/ckoZb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ckoZb.png" alt="Result after touching the ground"></a> Result after touching the ground</p> <p>Help would be deeply appreciated</p>
2
How do you rotate the x and y axis in D3 bar chart
<p>I am trying to figure out how to have a horizontal bar chart instead of a vertical. I have watched a video to try to explain how to do this, as well as looked at forums and other D3 codes, but I still can't figure it out. Here is my code below. </p> <pre><code> &lt;script&gt; var data = [ { skill:"FBSO", TEAM:57, OPP:50 }, { skill:"SO", TEAM:73, OPP:61 }, { skill:"ModSO", TEAM:69, OPP:57 }, { skill:"ErndSO", TEAM:67, OPP:52 }, { skill:"FBPS", TEAM:35, OPP:25 }, { skill:"PS", TEAM:43, OPP:29 } ]; var margin = { top: 20, right: 20, bottom: 40, left: 60 }, width = 450 - margin.left - margin.right, height = 315 - margin.top - margin.bottom, that = this; var x = d3.scale.ordinal().rangeRoundBands([0, width], .3); var x2 = d3.scale.ordinal().rangeRoundBands([0, width], .3); var y = d3.scale.linear().rangeRound([height, 0]); var color = d3.scale.category20(); var xAxis = d3.svg.axis().scale(x).orient("bottom"); var xAxis2 = d3.svg.axis().scale(x).orient("top"); var yAxis = d3.svg.axis().scale(x).orient("left"); var yAxis2 = d3.svg.axis().scale(x).orient("right"); // var yAxis = d3.svg.axis().scale(y).orient("left").tickFormat(d3.format(".0%")); var svg = d3.select(".viz-portfolio-delinquent-status").append("svg").attr("width", width + margin.left + margin.right).attr("height", height + margin.top + margin.bottom).append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")"); color.domain(d3.keys(data[0]).filter(function (key) { return key !== "interest_rate"; })); data.forEach(function (d) { var y0 = 0; d.rates = color.domain().map(function (name) { // console.log(); // ; return { name: name, y0: y0, y1: y0 += +d[name], amount: d[name] }; }); d.rates.forEach(function (d) { d.y0 /= y0; d.y1 /= y0; }); // console.log(data); }); data.sort(function (a, b) { return b.rates[0].y1 - a.rates[0].y1; }); x.domain(data.map(function (d) { return d.interest_rate; })); svg.append("g").attr("class", "x axis").attr("transform", "translate(0," + height + ")").call(xAxis); svg.append('g').attr('class', 'x axis').attr('transform', 'translate(0,'+ height/375 +')').call(xAxis2); svg.append("g").attr("class", "x axis").attr("transform", "translate(" + width + ",0)").call(yAxis2); svg.append('g').attr('class', 'y axis').attr('transform', 'translate('+ height/375 +',0)').call(yAxis); // svg.append("g").attr("class", "y axis").call(yAxis); var interest_rate = svg.selectAll(".interest-rate").data(data).enter().append("g").attr("class", "interest-rate").attr("transform", function (d) { // conosole.log(d) return "translate(" + x(d.interest_rate) + ",0)"; }); interest_rate.selectAll("rect") .data(function (d) { return d.rates; }) .enter() .append("rect") .attr("width", x.rangeBand()) .attr("y", function (d) { return y(d.y1); }) .attr("height", function (d) { // console.log(d) return y(d.y0) - y(d.y1); }) .style("fill", function (d) { return color(d.name); }) .on('mouseover', function (d) { var total_amt; total_amt = d.amount; // console.log('----'); // d3.select(".chart-tip").style('opacity', '1').html('Amount: &lt;strong&gt;$' + that.numberWithCommas(total_amt.toFixed(2)) + '&lt;/strong&gt;'); }).on('mouseout', function () { d3.select(".chart-tip").style('opacity', '0'); }); </code></pre> <p></p> <p>I am sure it isn't too difficult, I just can't figure which x's and y's I need to change. Thanks!</p>
2
Cannot click on HTML input button with Javascript and WebView (Possibly an iframe issue, not sure)
<p>I am working on an iOS app that performs some actions in a webview using injected javascript. I am trying to press a submit button on a router's web-interface (So I can't give you a url). I've tried many other proposed solutions online but nothing is working. One thing I must do is click an input button of type=SUBMIT and for whatever reason it is not responding. I have tried using .click() along with calling the onClick event handler, but nothing is working. Any help is appreciated. The HTML code is below:</p> <pre><code>&lt;div class="fix_button"&gt; &lt;table width="100%" border="0" cellpadding="0" cellspacing="2"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td nowrap="" colspan="2" align="center"&gt; &lt;input class="cancel_bt" type="RESET" name="Cancel" value="Cancel" onclick="doCancel();" languagecode="51"&gt; &amp;nbsp; &lt;input class="apply_bt" type="SUBMIT" name="Apply" value="Apply" onclick="return checkData();" languagecode="50"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>The input button is the one with the <code>class="apply_bt"</code>. This div is within an iframe and submits data that is within another iframe within this frame. The structure is sort of like this:</p> <pre><code>&lt;iframe&gt; // Contains the Apply Button &lt;div class="fix_button"&gt;&lt;/div&gt; // Contains the iframe where the info to be submitted is &lt;div id="main" class="main_top_button"&gt; // Contains data to be submitted &lt;iframe src="WLG_2g_wireless2.htm&amp;amp;todo=wifi_primary_init" id="2g_setting" name="wl2gsetting" onload="SetCwinHeight(this.id)" marginheight="0" marginwidth="0" scrolling="no" width="100%" frameborder="0" height="288px"&gt; &lt;/iframe&gt; &lt;/div&gt; &lt;/iframe&gt; </code></pre> <p>This is the code I am using to click the button:</p> <pre><code>// Gets the outer iframe iframe1 = document.getElementById("formframe"); // Gets the html within the iframe var innerDoc=iframe1.contentDocument || iframe1.contentWindow.document; // Gets iframe within the iframe innerframe = innerDoc.getElementById("2g_setting"); // Gets the html within the inner iframe var innerDoc2=innerframe.contentDocument || innerframe.contentWindow.document; // I Enter some data in the inner iframe (not shown), this portion // of the code works perfectly. I can see fields being entered and // buttons being clicked. // Then I click the apply button... innerDoc.getElementsByName("Apply")[0].click() // And nothing happens </code></pre> <p>I am able to get the element and read data from the Apply Button, such as its text, but I am not able to perform a .click() action on the button. Also, I am not getting any errors. I have no idea why its not working. Please help!</p>
2
How do I remove all types of translation from wordpress site?
<p>Few days ago I installed my website with Bitnami with Azure Cloud server. I installed WordPress as my site, but Bitnami WordPress comes with all kind of language translation. I always use English and don't like to see any translation.</p> <p>Problem is when ever I update any plugin or theme it also comes with all of those translation. I didn't start posting on my site. Also I searched everywhere for this solution but there are no solution what I'm looking for. </p> <p>Is there any way to only use English as my site language and remove all those translation?</p>
2
IBM Watson: Invalid API Key
<p>I'm trying to make requests on the Visual Recognition API and getting the response error below:</p> <pre><code>HTTP/1.1 200 OK Server: nginx Date: Tue, 28 Jun 2016 13:53:07 GMT Content-Type: application/json Content-Length: 67 Connection: close Cache-Control: no-cache Access-Control-Allow-Origin: * { "status": "ERROR", "statusInfo": "invalid-api-key" } </code></pre> <p>I've already tried to recreate my account and the Visual Recognition Service many times this week, and the <strong>API Key</strong> provided by Bluemix is always invalid.</p>
2
Spring resource resolver with different maven modules
<p>So for our test structure we currently have a base module in which we have some of our common configuration files etc (example: ds.properties). Now I'm currently running tests in a different module and I'm trying to load all .properties files (to get all the configurations) and I was using </p> <pre><code>(new PathMatchingResourcePatternResolver(getClass().getClassLoader())).getResources("classpath:*.properties") </code></pre> <p>Now this is only finding alpha.properties (the property file in my module). Is there a way to get the property files in all modules?</p> <p>Some stuff I have already tried:</p> <pre><code>(new PathMatchingResourcePatternResolver(getClass().getClassLoader())).getResources("classpath:ds.properties") </code></pre> <p>Returns the ds.properties that I want but obviously not auth.properties.</p> <pre><code>(new PathMatchingResourcePatternResolver(getClass().getClassLoader())).getResources("classpath*:*.properties") </code></pre> <p>Again only alpha.properties</p> <pre><code>(new PathMatchingResourcePatternResolver(getClass().getClassLoader())).getResources("classpath*:**/*.properties") </code></pre> <p>Returns alpha.properties and a bunch of .properties files from the jre that I do not want.</p>
2
How can I run a single Android Test using Kotlin?
<p>I am using Kotlin 1.0.3 for Android Development in Unit Testing but when I try to run a single test it runs all tests of the class. Does anyone know how to avoid that behaviour?</p>
2
Tess4j Tesseract vs Tesseract1
<p>I am not 100% sure the difference about Tesseract and Tesseract1 object in the Java api package Tess4J, anyone can explain about it?</p> <p>I know Tesseract uses interface mapping, and Tesseract1 uses direct mapping. How this will change their behavior?</p> <p>Thanks in advance!</p>
2
ImageButton.getWidth() and getHeight() returns 0
<p>Currently in my android app, my ImageButton <code>getWidth()</code> and <code>getHeight()</code> returns 0. Upon searching the forums, I realized that this is because the Layout/View hasn't been done/finalized by the OS, hence returning 0. Thus, they recommend using the <code>OnGlobalLayoutListener</code> to solve this issue. However, the button is created in a Fragment, which has an <code>onCreateView()</code> method which returns the View of the fragment. So how do I attach this Listener in this case?</p> <p>Thanks.</p>
2
Get an element in DOM hierarchy from the link function of a directive [AngularJS]
<p>I have a simple DOM hierarchy and I want to grab a specific set of elements (I want all the <strong>canvas</strong> elements). This is the entire template for this directive:</p> <pre><code>&lt;div id='charts-container'&gt; &lt;div class='chart-wrapper' ng-repeat='chart in getNumberOfCharts() track by $index'&gt; &lt;canvas id="{{'exam-chart-' + $index}}" class='chart-canvas'&gt;&lt;/canvas&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I want to create a list with all the canvas within the <em>#charts-container</em> element, but I just can't. This is what I'm trying to do inside the link function:</p> <pre><code>link: function (scope, element, attributes, controller) { var look = element.find('#chart-canvas'); $log.debug(look); } </code></pre> <p>And then I get <a href="http://i.imgur.com/0Ejlk8d.png" rel="nofollow">this</a> element, but I don't know how to get all the chart-wrapper elements from here.</p> <p>I tried doing <code>look.context.children</code>, it returned an empty list, but at the same time showed me what I wanted as if the list were populated, here is an <a href="http://i.imgur.com/dWqxVLP.png" rel="nofollow">image</a>. If I try to access any index of this list, it returns undefined (which is fine, because it's an empty list. But why the console is showing me these values?)</p> <p>What is the best way to achieve this? To get all the canvas elements in this template? (there are 15 of them). Thanks!</p> <hr> <p><strong>--- UPDATE ---</strong> </p> <p>I realized that if I remove the <strong>ng-repeat</strong> attribute I'm using in the template, it works! But I need the ng-repeat...</p> <p><code>element.find('.chart-canvas')</code> manage to get the canvas element, but only if there are no ng-repeat attribute.</p> <p>Is this a common issue when using ng-repeat. Is there any special treatment when falling in this case?</p>
2
Is a full clone the only way to submodule add a branch?
<p>I want to add a submodule that references a specific (non-master) branch. The following will only grab the master branch due to <code>--depth=1</code>, so the command will inevitably fail;</p> <pre><code>git submodule add -b myBranch --depth=1 [email protected]:some/large/repo </code></pre> <p>Because <code>submodule add</code> doesn't support <code>--single-branch</code>, does this mean my only option is to clone the entire repo?</p>
2
rand() expects parameter 1 to be long, string given
<p>I get the error:</p> <blockquote> <p>rand() expects parameter 1 to be long, string given </p> </blockquote> <p>PHP code:</p> <pre><code> // Set global last updated time $ab_options['lastupdate'] = time(); ab_saveOptions(); $this-&gt;ab_logMsg('Setting last update time to '.date("g:i a", $ab_options['lastupdate']), AB_LOG_INFO + AB_LOG_ONLY, 'debug'); set_transient('Auto_LastRun', time(), 3600); set_transient('Auto_Interval', rand($ab_options['mintime'], $ab_options['maxtime']), 86400); </code></pre>
2
Android studio proguard not working for library aar even if minifyenabled true
<p>I have a Gradle app with 1 library aar project and few flavours, I am trying to implement proguard for library project.</p> <p>I have declared proguard-rules.pro file as well as proguard-library.pro file. I have minifyenabled true, useproguard true but Proguard does not seem to work. I am using Android studio 2.1.2 with a gradle wrapper 2.10.</p> <p>I also followed steps from the link below but did not work, <a href="https://stackoverflow.com/questions/26983248/proguard-ignores-config-file-of-library/27052696#27052696">Proguard ignores config file of library</a></p> <p>Can someone help to get proguard to run for my library aar project.</p> <p>Edited: I am just testing if proguard works for debug or not, My gradle file is as below:</p> <p>Edited debug code below:</p> <pre><code>defaultConfig { proguardFiles 'proguard-library.pro' consumerProguardFiles 'proguard-rules.pro' ... ... } buildTypes{ debug { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' .... ... } } </code></pre>
2
Eloquent is saving no values in not null fields
<p>I'm making a migration and I want some fields to be not nullable. To make easier I will use the users migration that comes with Laravel as an example.</p> <pre><code>Schema::create('users', function (Blueprint $table) { $table-&gt;increments('id'); $table-&gt;string('name'); $table-&gt;string('email')-&gt;unique(); $table-&gt;string('password'); $table-&gt;rememberToken(); $table-&gt;timestamps(); }); </code></pre> <p>None of its fields are nullables but if I make:</p> <pre><code>$user = new User(); $user-&gt;save(); User::all(); </code></pre> <p>It returns </p> <pre><code>Illuminate\Database\Eloquent\Collection {#639 all: [ App\User {#640 id: "1", name: "", email: "", created_at: "2016-06-29 15:51:01", updated_at: "2016-06-29 15:51:01", }, ], } </code></pre> <p>Where is the point of the nullable() modifier if I can save records without data in not null fields?</p>
2
Adding WAI-ARIA attributes with JS
<p>At work I have been optimizing one of the sites I have helped developed for one of our clients (I can't say who) for be ADA compliant using WAI-ARIA attributes. I've been wondering if it wouldn't just be easier to create a small JS library that does things like add "role=button" to anchors I've styled to look like a button, add "tabindex=0" to elements I want to be "tabable" etc.</p> <p>I was wondering if it is a good practice to add in WAI-ARIA attributes with JS or is that frowned upon. Some accessibility evaluation tools won't run the page's JS when evaluating it so it will think these are pain points when they are really not.</p>
2
NSURLConnection method use with IPv6
<p>I have code my project using SOAP methods in NSURLConnection.Recently new version update reject it cause of ipV6 issue for ios9+</p> <p>Now i check that for supporting ipV6 you need to convert code to standard networking APIs like NSURLSession and CFNetwork APIs provided by apple.</p> <p>Is there alternative without converting my more then 350+ api , it will work with ipV6 . </p>
2
unable to load Glide with uri
<p>I am working on an App, where, I am listening to image share requests.</p> <pre><code>&lt;intent-filter&gt; &lt;action android:name="android.intent.action.SEND"/&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="image/*"/&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.SEND_MULTIPLE"/&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="image/*"/&gt; &lt;/intent-filter&gt; </code></pre> <p>I am able to get the Uri(s) of the images shared. </p> <pre><code>private ArrayList&lt;Uri&gt; mGalleryImagesList; if(recievedAction == Intent.ACTION_SEND){ mSelectedImages.add(Uri.parse(extras.get(Intent.EXTRA_STREAM).toString())); } else if(recievedAction == Intent.ACTION_SEND_MULTIPLE){ ArrayList&lt;Parcelable&gt; fileList = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM); for (Parcelable file: fileList) { mSelectedImages.add(Uri.parse(file.toString())); } } </code></pre> <p>However, when I am trying to load ImageView, using Glide, it is not loading, I am seeing only the place holder.</p> <pre><code>... @Override public void onBindViewHolder(ViewHolder holder, final int position) { Glide.with (mContext) .load(mGalleryImagesList.get(position)) .centerCrop() .placeholder(R.drawable.image_loading) .crossFade() .into(holder.imgAlbum); } </code></pre> <p>Example of Uri that I got when I shared a photo using "Photos" app to my App. <strong>content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Ffile%2F3924/ORIGINAL/NONE/1472614544</strong></p> <p>No exceptions, only issue is that, ImageView is not loaded.</p>
2
Scroll event fire delay in mobile
<p>I got event listener to the scroll and everything works fine with desktop browsers(when scrolling starts - the event fired straight away) and chrome browser in mobile(chrome latest version + android version 5.0), but with other mobile browsers(ff, android browser) this works differently, and after googling for some I found the reason: it's because the scroll event is not fired until the scrolling action comes to a complete stop(releasing the finger from the screen). </p> <p>My question is there some workaround for this, perhaps some best practice, so it will fire normally(as for desktop) and without dramatically performance changes?</p> <p>*JS solution only(no for jquery).</p>
2
How to find out the PredType of a dataset in HDF5 using the C++ library
<p>So I just found out, that if I write an <code>unsigned char</code> array into a <code>float</code> dataset in my HDF5 file the library does not complain. Therefore, I want to check before I write that the two are actually compatible. So for my <code>unsigned char</code> array I have the corresponding <code>PredType</code>. But the dataset does not offer an obvious way to get the <code>PredType</code>, if I am not mistaken.</p> <p><strong>Question:</strong> Given a <code>H5::Dataset</code>, how do I obtain the <code>PredType</code> that was used to initialize it?</p>
2
how to decode the result of listenning to port 162 (Snmp Trap)?
<p>I want to get the snmp trap by using my own traplistener. In fact, I used a code found in internet I added some modifications and now it is working. I can listen through the port 162.</p> <pre><code>#include "stdio.h" #include "winsock2.h" #pragma comment(lib, "ws2_32.lib") #define SNMP_TRAP_PORT 162 #define MAX_MSG 400 static void init(void) { WSADATA wsa; int err = WSAStartup(MAKEWORD(2, 2), &amp;wsa); if(err &lt; 0) { puts("WSAStartup failed !"); exit(EXIT_FAILURE); } } static void end(void) { WSACleanup(); } int main(int argc, char *argv[]) { int sd, rc, n, cliLen; struct sockaddr_in cliAddr, servAddr; char msg[MAX_MSG]; /* socket creation */ init(); sd= socket(AF_INET, SOCK_DGRAM, 0); if(sd&lt;0) { printf("can't open socket \n"); exit(1); } /* bind local server port */ servAddr.sin_family = AF_INET; servAddr.sin_addr.s_addr = htonl(INADDR_ANY); servAddr.sin_port = htons(SNMP_TRAP_PORT); rc = bind (sd, (struct sockaddr *) &amp;servAddr,sizeof(servAddr)); if(rc&lt;0) { printf("can't bind port number %d \n", SNMP_TRAP_PORT); exit(1); } printf("waiting for SNMP Traps on UDP port %d\n", SNMP_TRAP_PORT); /* server infinite loop */ while(1) { /* init buffer */ memset(msg,0x0,MAX_MSG); /* receive message */ cliLen = sizeof(cliAddr); n = recvfrom(sd, msg, MAX_MSG, 0, (struct sockaddr *) &amp;cliAddr, &amp;cliLen); if(n&lt;0) { printf("%s: cannot receive data \n",argv[0]); continue; } /*message is encoded with ASN1 and should be decoded*/ /* print received message */ printf("SNMP Trap received from %s : %o\n", inet_ntoa(cliAddr.sin_addr),msg); }/* end of server infinite loop */ end(); return 0; } </code></pre> <p>The code works fine now when I get traps I receive a number. Normally, I should get the trap in ASN1 (hex or bin) but I get just this: <a href="http://i.stack.imgur.com/bmXCq.png" rel="nofollow">Traplistner result</a>. I was wondering what does the 12175440 means. Thx </p>
2
Not able to add predicate to selector with Google Adwords API
<p>I am using Google Adwords API version - 201603</p> <p>While generating Criteria report, I am filtering the data using predicate. Here is the code where I am adding predicate to the selector to filter the data.</p> <pre><code>final Selector selector = new Selector(); selector.getFields().addAll(Lists.newArrayList("CampaignId", "AdGroupId", "Id", "CriteriaType", "Criteria", "FinalUrls", "Impressions", "Clicks", "Cost")); final Predicate p=new Predicate(); p.setField("CriteriaType"); p.setOperator(PredicateOperator.CONTAINS_ANY); p.getValues().add("Webpage"); final Collection&lt;Predicate&gt; predicates=new ArrayList&lt;&gt;(); predicates.add(p); selector.getPredicates().add(p); </code></pre> <p>But when i run the code, I am getting below error.</p> <pre><code> __rdxml: &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;reportDefinition xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201603"&gt;&lt;ns2:selector&gt;&lt;ns2:fields&gt;CampaignId&lt;/ns2:fields&gt;&lt;ns2:fields&gt;AdGroupId&lt;/ns2:fields&gt;&lt;ns2:fields&gt;Id&lt;/ns2:fields&gt;&lt;ns2:fields&gt;CriteriaType&lt;/ns2:fields&gt;&lt;ns2:fields&gt;Criteria&lt;/ns2:fields&gt;&lt;ns2:fields&gt;FinalUrls&lt;/ns2:fields&gt;&lt;ns2:fields&gt;Impressions&lt;/ns2:fields&gt;&lt;ns2:fields&gt;Clicks&lt;/ns2:fields&gt;&lt;ns2:fields&gt;Cost&lt;/ns2:fields&gt;&lt;ns2:predicates&gt;&lt;ns2:field&gt;CriteriaType&lt;/ns2:field&gt;&lt;ns2:operator&gt;CONTAINS_ANY&lt;/ns2:operator&gt;&lt;ns2:values&gt;Webpage&lt;/ns2:values&gt;&lt;/ns2:predicates&gt;&lt;/ns2:selector&gt;&lt;ns2:reportName&gt;Criteria performance report #1467042784488&lt;/ns2:reportName&gt;&lt;ns2:reportType&gt;CRITERIA_PERFORMANCE_REPORT&lt;/ns2:reportType&gt;&lt;ns2:dateRangeType&gt;ALL_TIME&lt;/ns2:dateRangeType&gt;&lt;ns2:downloadFormat&gt;CSV&lt;/ns2:downloadFormat&gt;&lt;/reportDefinition&gt; [27 Jun 2016 11:53:04,876-report_download:WARN:main] Response received with status code 400 and message: Bad Request Report was not downloaded due to: HTTP Response Code: 400, FieldPath: selector, Trigger: CriteriaType, Type: SelectorError.INVALID_PREDICATE_OPERATOR </code></pre> <p>I am not able to figure out what is the error. If anyone has idea about what is going on. Please do answer the question.</p>
2
Travis: how to know android sdk/ndk path?
<p>My android project is built with Ant and i have to edit <code>ant.properties</code> manually file to pass <code>sdk.path</code> variable pointing to android sdk directory. i'm going to change it to get sdk path from environment variable to make build possible on Travis CI. What is android sdk variable for this? </p> <p>Also i have some jni code to be built with android ndk, so the similar question - what is env variable for android ndk on Travis?</p>
2
Tweepy reply to tweet in stream
<p>I have a twitter bot that responds to tweets containing a hashtag. I've been using the <code>twt = api.search(q='param')</code> to pull tweets and it's been working perfectly but I've since switched to <code>myStreamListener = MyStreamListener() twt = tweepy.Stream(auth = api.auth, listener=myStreamListener())</code> to pull tweets in real time. this isn't working though and I don't know why. Here's my code: </p> <pre><code>myStreamListener = MyStreamListener() twt = tweepy.Stream(auth = api.auth, listener=myStreamListener()) twt.filter(track=['#www'], async=True) #list of specific strings we want to omit from responses badWords = ['xxx','yyy' ] #list of specific strings I want to check for in tweets and reply to genericparam = ['@zzz'] def does_contain_words(tweet, wordsToCheck): for word in wordsToCheck: if word in tweet: return True return False for currentTweet in twt: #if the tweet contains a good word and doesn't contain a bad word if does_contain_words(currentTweet.text, genericparam) and not does_contain_words(currentTweet.text, badWords): #reply to tweet screen = currentTweet.user.screen_name message = "@%s this is a reply" % (screen) currentTweet = api.update_status(message, currentTweet.id) </code></pre>
2
Why can't I pass the React unique key to onChange method
<p>I'm using React ES6. I'm rendering an inventory list containing unique fish elements, each fish element is mapped to a unique key and inherits props from parent component. I'd like to be able to edit the fish text and have this change feed in to the parent state.</p> <p>My code below doesn't work as the key prop is not available to the onChange handler. Most of the documentation online recommends ReactLink for bi-directional flow but this is now deprecated so I would rather find another solution. My question is two-fold - what is the best pattern for bi-directional flow in ES6 react components and why does this code not work -specifically why can't I console log 'key' in the onChange handler.</p> <p>Much gratitude</p> <pre><code> render () { var fishIds = Object.keys(this.props.fishes); console.log("fishes are....." +fishIds); return ( &lt;div&gt; &lt;h2&gt;Inventory&lt;/h2&gt; {fishIds.map(this.renderInventory)} &lt;AddFishForm {...this.props}/&gt; &lt;button onClick={this.props.loadSamples}&gt; Load Sample Fishes&lt;/button&gt; &lt;/div&gt; ) } </code></pre> <p>Maps Keys and passes them to renderInventory</p> <pre><code>renderInventory(key) { var fish = this.props.fishes[key]; console.log(fish); console.log("the key is" +key); var nameOfFish = fish.name return( &lt;div className = "fish-edit" key={key}&gt; &lt;input type = "text" value ={nameOfFish} onChange={this.handleChange(key)} /&gt; &lt;input type = "text" value ={fish.price}/&gt; &lt;select&gt; &lt;option value = "unavailable"&gt;Sold out! &lt;/option&gt; &lt;option value = "available"&gt;Fresh! &lt;/option&gt; &lt;/select&gt; &lt;textarea value={fish.desc}&gt; &lt;/textarea&gt; &lt;/div&gt; ) } </code></pre> <p>HandleChange can't log key</p> <pre><code>handleChange(event, key){ console.log("the change handler is now firing and the key is" + key); } </code></pre>
2
How do I differentiate between MQTT Publish events originating from Users vs internal messages meant to broadcast only
<p>I am using mosquitto mqtt client.</p> <p>For example, you have users that publish and subscribe to topics. The topic actually correlates to a REsT endpoint.</p> <p><strong>Scenario 1 (typical pub/sub usage)</strong></p> <ol> <li>UserA subscribes to topic /device/123/meta</li> <li>UserB publishes some data to topic /device/123/meta <ul> <li>by definition, this publish is broadcasted out to the subscribers</li> <li>we have a script subscribed to /devices/# which knows how to save the payload for the topic /device/123/meta when it receives publish'ed data. This data is saved to the database. </li> </ul></li> </ol> <p><strong>Scenario 2</strong></p> <ol> <li>Someone updates data /device/123/meta via a ReST interface (or a direct DB update, the key is it's not a MQTT publish). <ul> <li>database is updated</li> <li>a publish message is sent to the MQTT broker so that all subscribers get the updates as a payload</li> </ul></li> </ol> <p>Scenario 2 is what I'm trying to wrap my head around. This creates a nasty feedback loop. When internal messages are broadcasted out, my script to deal with publish events from users can't differentiate between publish events originating from a 3rd party user or an internal publish event only meant to broadcast out some data (with no saving of data needed).</p> <p>How should I handle this? The MQTT message is very simplistic and I'm not finding anything I can base logic off of. I'm trying to explore using the origin somehow, but no luck this far. I realize I can write plugins, but this is quite the task for mosquitto. </p>
2
Fabric.js create image on Node server after loading canvas from JSON
<p>I've been racking my brain the last couple of days trying to figure this out. In the app I'm writing, a user can upload two images, one that overlays the other. After placing one image on top of the other, they click a button and the canvas is converted to JSON and sent to a node (express) server. The canvas is then recreated by loading the JSON data to the canvas, calling toDataURL with a multiplier of 2 and writing the data to a png file. </p> <pre><code>router.post('/', function(req, res) { var canvas = fabric.createCanvasForNode(600, 600); canvas.loadFromJSON(req.body, function() { var dataUrl = canvas.toDataURL({ format: 'png', multiplier: 2 }); imageSrc = dataUrl.replace(/^data:image\/png;base64,/, ""); fs.writeFile('hello.png', imageSrc, 'base64', function(err) { console.log('Error: ' + err); }); }); </code></pre> <p>If I don't use a multiplier (i.e. multiplier is 1), a 600x600px image is created, as expected. But when I set the multiplier to 2, to get a higher resolution image, only the top-right quarter of the produced image contains the image created from the canvas. </p> <p><a href="http://i.stack.imgur.com/6rWBK.png" rel="nofollow">PNG image that is cutoff</a></p> <p>I've found resources online that say this <em>was</em> an issue in previous versions of fabric and I've seen others' workarounds, but nothing seems to fix my issue. Any help, advice or resources would be greatly appreciated!</p> <p>EDIT Maybe I should include an example of how I pass the JSON canvas to the server:</p> <pre><code>var json = JSON.stringify(canvas); var http = new XMLHttpRequest(); var url = '/designer'; http.open('POST', url, true); http.setRequestHeader('Content-type', 'application/json'); http.onreadystatechange = function () { if (http.readyState == 4 &amp;&amp; http.status == 200) { alert(http.responseText); } }; http.send(json); </code></pre>
2
JAX-WS web service : Beans not injected : NullPointerException
<p>I have developed a JAX-WS based web-service. I have Web service layer, service layer and a Dao layer. When i call a service method from web service class it gives null pointer exception. The reason is the service class bean is not getting injected.</p> <p><strong>web-service class:</strong></p> <pre><code>package com.test.webservice.controller; import javax.jws.WebMethod; import javax.jws.WebService; import com.test.salary.service.SalaryService; @WebService public class EmployeeSalaryWebService { private SalaryService salaryService; /** * @param salaryService the salaryService to set */ @WebMethod(exclude = true) public void setSalaryService(SalaryService salaryService) { this.salaryService = salaryService; } @WebMethod public double getEmployeeSalary(String name){ System.out.println("==== Inside getEmployee Salary === "+salaryService ); return salaryService.calculateSalary(name); } } </code></pre> <p><strong>Application-context</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt; &lt;bean name="salaryWebService" class="com.test.webservice.controller.EmployeeSalaryWebService"&gt; &lt;property name="salaryService" ref="salaryService" /&gt; &lt;/bean&gt; &lt;bean name="salaryService" class="com.test.salary.service.SalaryServiceImpl"&gt; &lt;property name="salaryDAO" ref="salaryDAO" /&gt; &lt;/bean&gt; &lt;bean name="salaryDAO" class="com.test.salary.dao.SalaryDaoImpl"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt; &lt;/bean&gt; &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt; &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt; &lt;property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /&gt; &lt;property name="username" value="LOCAL" /&gt; &lt;property name="password" value="abcdef" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p><strong>web.xml:</strong></p> <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"&gt; &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/salaryConfiguration.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;/web-app&gt; </code></pre> <p>Please let me know why the <strong>SalaryService salaryService</strong> not getting injected.</p>
2
Camera Rotation Issue in Unity3D C# (likely easy fix)
<p>I have got some CS code here which I am attempting to use in unity to rotate a camera around the y axis. The issue is that the camera currently seems to rotate around the z axis, which is causing some visual difficulties in my game.</p> <pre><code>public class TouchCamera : MonoBehaviour { Vector2?[] oldTouchPositions = { null, null }; Vector2 oldTouchVector; float oldTouchDistance; void Update() { if (Input.touchCount == 0) { oldTouchPositions[0] = null; oldTouchPositions[1] = null; } else if (Input.touchCount == 1) { if (oldTouchPositions[0] == null || oldTouchPositions[1] != null) { oldTouchPositions[0] = Input.GetTouch(0).position; oldTouchPositions[1] = null; } else { Vector2 newTouchPosition = Input.GetTouch(0).position; transform.position += transform.TransformDirection((Vector3)((oldTouchPositions[0] - newTouchPosition) * GetComponent&lt;Camera&gt;().orthographicSize / GetComponent&lt;Camera&gt;().pixelHeight * 2f)); oldTouchPositions[0] = newTouchPosition; } } else { if (oldTouchPositions[1] == null) { oldTouchPositions[0] = Input.GetTouch(0).position; oldTouchPositions[1] = Input.GetTouch(1).position; oldTouchVector = (Vector2)(oldTouchPositions[0] - oldTouchPositions[1]); oldTouchDistance = oldTouchVector.magnitude; } else { Vector2 screen = new Vector2(GetComponent&lt;Camera&gt;().pixelWidth, GetComponent&lt;Camera&gt;().pixelHeight); Vector2[] newTouchPositions = { Input.GetTouch(0).position, Input.GetTouch(1).position }; Vector2 newTouchVector = newTouchPositions[0] - newTouchPositions[1]; float newTouchDistance = newTouchVector.magnitude; transform.position += transform.TransformDirection((Vector3)((oldTouchPositions[0] + oldTouchPositions[1] - screen) * GetComponent&lt;Camera&gt;().orthographicSize / screen.y)); transform.localRotation *= Quaternion.Euler(new Vector3(0, 0, Mathf.Asin(Mathf.Clamp((oldTouchVector.y * newTouchVector.x - oldTouchVector.x * newTouchVector.y) / oldTouchDistance / newTouchDistance, -1f, 1f)) / 0.0174532924f)); GetComponent&lt;Camera&gt;().orthographicSize *= oldTouchDistance / newTouchDistance; transform.position -= transform.TransformDirection((newTouchPositions[0] + newTouchPositions[1] - screen) * GetComponent&lt;Camera&gt;().orthographicSize / screen.y); oldTouchPositions[0] = newTouchPositions[0]; oldTouchPositions[1] = newTouchPositions[1]; oldTouchVector = newTouchVector; oldTouchDistance = newTouchDistance; } } } </code></pre> <p>I am and artist and by no means a coder and this code is not my creation. I am just seeking assistance in correcting it to suit my needs. So if someone can let me know the most simplistic adjustment I can make to this current code I would much appreciate it. I know this is not the most conventional question, I am just hoping for a little help.</p>
2
Error: No provider for Compiler! DI Exception Angular 2 Testing
<p>The given unit test throws error when executed using npm test command. It says there was a DI Exception with error message "Error: No provider for compiler!"</p> <pre><code>import {TestComponentBuilder} from "@angular/compiler/testing"; import { expect, it, describe, async, inject, beforeEach, beforeEachProviders } from "@angular/core/testing"; import {provide} from '@angular/core'; import {TestService} from "../services/Test.service"; import {TestComponent} from "./Test.component"; describe('Component: TestComponent', () =&gt; { let tcb; beforeEachProviders(() =&gt; [ TestComponentBuilder, TestComponent, TestService ]); beforeEach(inject([TestComponentBuilder], (testComponentBuilder) =&gt; { tcb = testComponentBuilder; })); it('getTest', testGetTest =&gt; { **tcb.createAsync(TestComponent)** .then(fixture =&gt; { let TestComponent = fixture.componentInstance; TestComponent.selectedUserId = 3; expect(TestComponent.selectedUserId).beEqual(3); }); }); }); </code></pre> <p>The error is thrown most probably on tcb.createAsync</p> <p>Following dependencies were added to project</p> <pre><code>"jasmine-core": "~2.4.1", "karma": "1.x || ^0.13.0", "karma-chrome-launcher": "1.x || ~0.2.2", "karma-firefox-launcher": "1.x || ~0.1.7", "karma-cli": "*", "karma-jasmine": "1.x || ^0.3.6", "karma-spec-reporter": "0.0.13", "browserify": "latest", "karma-browserify": "latest" </code></pre>
2
Laravel return records from relation table
<p>Hello I want to returned a list of products with the selected category. I have two tables connected by relationship table products:</p> <pre><code>public function up() { Schema::create('products', function (Blueprint $table) { $table-&gt;increments('id'); $table-&gt;integer('user_id')-&gt;unsigned(); $table-&gt;integer('article_id')-&gt;unsigned(); $table-&gt;integer('category_id')-&gt;unsigned(); $table-&gt;string('sn'); $table-&gt;integer('quantity'); $table-&gt;date('warranty'); $table-&gt;timestamps(); }); Schema::table('products', function(Blueprint $table) { $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users'); $table-&gt;foreign('article_id')-&gt;references('id')-&gt;on('articles'); $table-&gt;foreign('category_id')-&gt;references('id')-&gt;on('categories'); }); } </code></pre> <p>and table categories:</p> <pre><code>public function up() { Schema::create('categories', function (Blueprint $table) { $table-&gt;increments('id'); $table-&gt;string('category_name'); $table-&gt;timestamps(); }); } </code></pre> <p>product model:</p> <pre><code>public function user(){ return $this-&gt;belongsTo('App\User'); } public function article(){ return $this-&gt;belongsTo('App\Article'); } public function category(){ return $this-&gt;belongsTo('App\Category'); } </code></pre> <p>And category model:</p> <pre><code>public function products(){ return $this-&gt;hasMany('App\Product')-&gt;withTimestamps(); } </code></pre> <p>I write query SQL in phpmyadmin:</p> <pre><code>SELECT products.id, products.user_id, articles.article_name, categories.category_name, products.sn, products.quantity, products.warranty, products.created_at, products.updated_at, SUM(quantity) AS ilosc FROM products LEFT JOIN categories ON products.category_id = categories.id LEFT JOIN articles ON products.article_id = articles.id GROUP BY articles.article_name ORDER BY id; </code></pre> <p>This query works on phpmyadmin but I want write metohod in Laravel. <strong>How can I return a list of products assigned to the selected category ??</strong> I would add that the selected category is passed in the method show by ID CATEGORY:</p> <pre><code>public function show($id){ $categories = Category::find($id); return view('categories.showcategory', compact('categories')); } </code></pre> <p>I do not want a solution, only hints how I can do it. I found this theme <a href="http://I%20found%20this,%20but%20still%20do%20not%20know%20how%20to%20do%20it">enter link description here</a>, but still I do not know how to do it ;)</p> <p>I convert query SQL to query laravel i file CategoriesController:</p> <pre><code>public function show($id){ $categories = Category::find($id); $productsList = DB::table('products')-&gt;select('products.id, products.user_id, articles.article_name, categories.category_name, products.sn, products.quantity, products.warranty, products.created_at, products.updated_at, SUM(quantity) AS ilosc')-&gt;from('products')-&gt;where('id' , '=' , $categories-&gt;id)-&gt;leftJoin('categories', 'products.category_id', '=', 'categories.id')-&gt;leftJoin('articles', 'products.article_id', '=', 'articles.id')-&gt;groupBy('articles.article_name')-&gt;orderBy('id')-&gt;get(); return view('categories.showcategory', compact('categories', 'productsList')); } </code></pre> <p>But Laravel returned error:</p> <blockquote> <p>SQLSTATE[42S22]: Column not found: 1054 Unknown column 'products.id, ' in 'field list' (SQL: select <code>products</code>.<code>id,</code> as `` from <code>products</code> left join <code>categories</code> on <code>products</code>.<code>category_id</code> = <code>categories</code>.<code>id</code> left join <code>articles</code> on <code>products</code>.<code>article_id</code> = <code>articles</code>.<code>id</code> where <code>id</code> = 1 group by <code>articles</code>.<code>article_name</code> order by <code>id</code> asc)</p> </blockquote> <p>with the help of swatkins I wrote method:</p> <pre><code>public function show($id){ $categories = Category::find($id); $productsList = Category::with(['products' =&gt; function ($query) { $query-&gt;where('category_id', 20); }])-&gt;get(); return view('categories.showcategory', compact('categories', 'productsList')); } </code></pre> <p>Laravel returns correctly Products with selected category, but only when I write ID category. In this method ID category is equal to 20. </p> <p>$query->where('category_id', <strong>20</strong>);</p> <p><strong>How can I dynamically pass the value of GET category_id ??</strong></p>
2
Where is the (OSX) path for an updated version of the Android NDK?
<p>Where is the path for an updated version of the Android NDK? I'm on Mac OSX 10.11.5 (El Capitan)</p> <p>I used android-ndk-r10e for a good while, but just updated to the latest version of the NDK using Android Studio's SDK Manager. I watched its progress and noted that it was version r12 and also the root dir where it was installing, but when I went to look for it I can't find anything that looks like my original installation.</p> <p>When I originally installed r10e, the folder name that it installed into was/is:</p> <pre><code>/android-ndk-r10e </code></pre> <p>Below is my CHANGELOG.md that I found in the ndk-bundle folder of the dir where the update seemed to be installed. Seems clear that r12b was installed, but where? Shouldn't there be an "android-ndk-r12b" folder somewhere?</p> <pre><code>Changelog ========= Report issues to [GitHub]. [GitHub]: https://github.com/android-ndk/ndk/issues Announcements ------------- * `ndk-build` will default to using Clang in r13. GCC will be removed in a later release. * `make-standalone-toolchain.sh` will be removed in r13. Make sure `make_standalone_toolchain.py` suits your needs. r12b ---- * `ndk-gdb.py` has been fixed: https://github.com/android-ndk/ndk/issues/118 * NdkCameraMetadataTags.h has been updated to no longer contain the invalid enum value. * A bug in `ndk-build` that resulting in spurious warnings for static libraries using libc++ has been fixed: https://android-review.googlesource.com/#/c/238146/ * The OpenSLES headers have been updated for android-24. NDK --- * Removed support for the armeabi-v7a-hard ABI. See the explanation in the [documentation](docs/HardFloatAbi.md). * Removed all sysroots for pre-GB platform levels. We dropped support for them in r11, but neglected to actually remove them. * Exception handling when using `c++_shared` on ARM32 now mostly works (see [Known Issues](#known-issues)). The unwinder will now be linked into each linked object rather than into libc++ itself. * Default compiler flags have been pruned: https://github.com/android-ndk/ndk/issues/27. * Full changes here: https://android-review.googlesource.com/#/c/207721/5. * Added a Python implementation of standalone toolchains: `build/tools/make_standalone_toolchain.py`. * Windows users: you no longer need Cygwin to use this feature. * We'll be removing the bash flavor in r13, so test the new one now. * `-fno-limit-debug-info` has been enabled by default for Clang debug builds. This should improve debugability with LLDB. * `--build-id` is now enabled by default. * This will be shown in native crash reports so you can easily identify which version of your code was running. * `NDK_USE_CYGPATH` should no longer cause problems with libgcc: http://b.android.com/195486. * `-Wl,--warn-shared-textrel` and`-Wl,--fatal-warnings` are now enabled by default. If you have shared text relocations, your app will not load on Marshmallow or later (and have never been allowed for 64-bit apps). * Precompiled headers should work better: https://github.com/android-ndk/ndk/issues/14 and https://github.com/android-ndk/ndk/issues/16. * Unreachable ARM (non-thumb) STL libraries have been removed. * Added Vulkan support to android-24. * Added Choreographer API to android-24. * Added `libcamera2` APIs for devices with `INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED` or above (see [Camera Characteristics]). [Camera Characteristics]: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL Clang ----- * Clang has been updated to 3.8svn (r256229, build 2812033). * Note that Clang packaged in the Windows 64-bit NDK is actually 32-bit. * `__thread` should work for real this time. GCC --- * Synchronized with the ChromeOS GCC @ `google/gcc-4_9` r227810. * Backported coverage sanitizer patch from ToT (r231296). * Fixed libatomic to not use ifuncs: https://github.com/android-ndk/ndk/issues/31. Binutils -------- * "Erratum 843419 found and fixed" info messages are silenced. * Introduced option '--long-plt' to fix internal linker error when linking huge arm32 binaries. * Fixed wrong run time stubs for AArch64. This was causing jump addresses to be calculated incorrectly for very large DSOs. * Introduced default option '--no-apply-dynamic' to work around a dynamic linker bug for earlier Android releases. * NDK r11 KI for `dynamic_cast` not working with Clang, x86, `stlport_static` and optimization has been fixed. GDB --- * Updated to GDB 7.11: https://www.gnu.org/software/gdb/news/. * Some bugfixes for `ndk-gdb.py`. Known Issues ------------ * This is not intended to be a comprehensive list of all outstanding bugs. * x86 ASAN still does not work. See discussion on https://android-review.googlesource.com/#/c/186276/ * Exception unwinding with `c++_shared` still does not work for ARM on Gingerbread or Ice Cream Sandwich. * Bionic headers and libraries for Marshmallow and N are not yet exposed despite the presence of android-24. Those platforms are still the Lollipop headers and libraries (not a regression from r11). * RenderScript tools are not present (not a regression from r11): https://github.com/android-ndk/ndk/issues/7. </code></pre>
2
"ERROR ITMS-90029" Storyboard file LaunchScreen~ipad.storyboardc was not found
<p>I have a Xamarin Forms project which debugs fine, builds fine on both iOS and Android. However when building the IPA for iOS, I try to use the Application Loader to submit the IPA and it reveals the error below:</p> <p>I am getting the error "ERROR ITMS-90029" Storyboard file 'LaunchScreen~ipad.storyboardc' was not found. Please ensure the specified file is included in the bundle with any required device modifiers appended to the filename.</p> <p>I have configured the LaunchScreen.storyboard file to "Builds for" iOS 8.0 and later.</p> <p>As it's a Xamarin Forms project, I only have one storyboard file, LaunchScreen.storyboard . In my Info.plist, my Deployment Info is:</p> <ul> <li><p>Deployment Target: 7.0</p> <p>Devices: Universal</p> <p>Main Screen: LaunchScreen</p> <p>Device Orientations: Portrait, Upside Down</p> <p>Hide Status bar: no</p> <p>Requires full screen: no</p></li> </ul> <p>Launch Images:</p> <ul> <li>Launch Screen: LaunchScreen</li> </ul> <p>This is such an absolute nightmare. I have tried every combination of settings, rebuilding, cleaning, you name it. They all produce IPA successfully, and they all error out with the same error. I cannot figure it out.</p>
2
Why is @override annotation optional?
<p>I understand definition of an <a href="https://api.dartlang.org/stable/1.17.1/dart-core/override-constant.html" rel="noreferrer">@override</a> annotation.</p> <p>But, why is the usage of the annotation optional? </p>
2
Way to implement SSO for web and desktop applications
<p>I am reading alot about federated identity management and technologies like SAML, which can be used for implementing SSO for web applications, and Kerberos, which can be used for implementing SSO für desktop applications. </p> <p>This is how I understood it so far. If we have the case, that we want to have SSO for a set of web applications and desktop applications, what are the technologies that are available for that? Do I have to combine SAML and Kerberos or is there another technology that fits better?</p>
2
The layout is displayed incomplete when using thymelaf
<p>I'm trying to create a typical user panel with thymeleaf layouts.</p> <p>As you can see on the expected result picture below, the layout is composed by a header and left menu. The contents chosen from the menu are displayed in the child section:</p> <p><a href="https://i.stack.imgur.com/VQC5V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VQC5V.png" alt="EXPECTED RESULT"></a></p> <p>However, the result I get is this one:</p> <p><a href="https://i.stack.imgur.com/pgLld.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pgLld.png" alt="ACTUAL RESULT"></a></p> <p>This is my "fixed parts" code where the header is the "header" fragment and the menu is the "menu" fragment:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns:th="http://www.thymeleaf.org"&gt; &lt;head&gt; &lt;meta charset="utf-8"/&gt; &lt;title&gt;Thymeleaf Layout&lt;/title&gt; &lt;link href="bootstrap-3.3.6-dist/css/bootstrap.css" rel="stylesheet"/&gt; &lt;link href="font-awesome-4.5.0/css/font-awesome.css" rel="stylesheet"/&gt; &lt;link href="panel/css/custom.css" rel="stylesheet"/&gt; &lt;link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'/&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrapper"&gt; &lt;nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0" th:fragment="header"&gt; &lt;div class="navbar-header"&gt; &lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse"&gt; &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;/button&gt; &lt;a class="navbar-brand" href="index.html"&gt;UserName&lt;/a&gt; &lt;/div&gt; &lt;div style="color: white; padding: 15px 50px 5px 50px; float: right; font-size: 16px;"&gt; Last access : 30 May 2014 &amp;nbsp; &lt;a href="#" class="btn btn-danger square-btn-adjust"&gt;Logout&lt;/a&gt;&lt;/div&gt; &lt;/nav&gt; &lt;nav class="navbar-default navbar-side" role="navigation" th:fragment="menu"&gt; &lt;div class="sidebar-collapse"&gt; &lt;ul class="nav" id="main-menu"&gt; &lt;li&gt; &lt;a href="#"&gt;&lt;i class="fa fa-university fa-2x"&gt;&lt;/i&gt;&lt;label th:text="#{companyBasicData}" style="font-weight: normal"&gt;&lt;/label&gt;&lt;span class="fa arrow"&gt;&lt;/span&gt;&lt;/a&gt; &lt;ul class="nav nav-second-level"&gt; &lt;li&gt; &lt;a href="#"&gt;&lt;label th:text="#{companies}" style="font-weight: normal"/&gt;&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt;&lt;label th:text="#{employees}" style="font-weight: normal"/&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="/billing"&gt;&lt;i class="fa fa-balance-scale fa-2x"&gt;&lt;/i&gt; &lt;label th:text="#{billing}" style="font-weight: normal"/&gt;&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt;&lt;i class="fa fa-money fa-2x"&gt;&lt;/i&gt;&lt;label th:text="#{payrolls}" style="font-weight: normal"/&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/nav&gt; &lt;/div&gt; &lt;script src="panel/js/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script src="bootstrap-3.3.6-dist/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script src="panel/js/custom.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is my "child" page where I import both, the header and the menu fragments:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"&gt; &lt;head&gt; &lt;meta charset="utf-8"/&gt; &lt;title&gt;Thymeleaf Layout&lt;/title&gt; &lt;link href="bootstrap-3.3.6-dist/css/bootstrap.css" rel="stylesheet"/&gt; &lt;link href="font-awesome-4.5.0/css/font-awesome.css" rel="stylesheet"/&gt; &lt;link href="panel/css/custom.css" rel="stylesheet"/&gt; &lt;link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'/&gt; &lt;/head&gt; &lt;body onload="test()"&gt; &lt;div th:replace="fragments/panel :: header"&gt; &lt;/div&gt; &lt;div th:replace="fragments/panel :: menu"&gt; &lt;/div&gt; &lt;div&gt; my page content &lt;/div&gt; &lt;script&gt; function test() { alert("TEST"); } &lt;/script&gt; &lt;script src="panel/js/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script src="bootstrap-3.3.6-dist/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script src="panel/js/custom.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>You can find the gitHub repository with the sample code at this link: <a href="https://github.com/MichaelKnight/thymeleafLayout" rel="nofollow noreferrer">https://github.com/MichaelKnight/thymeleafLayout</a></p>
2
No 'Access-Control-Allow-Origin' error with Laravel and React
<p>I am sending a request from my react app <code>localhost:8080</code> to my lumen api <code>localhost:8000</code> to retrieve json data.</p> <p>This is my <code>routes.php</code> in lumen: <code>$app-&gt;get('list', 'ArticleController@listAll');</code></p> <p>And this is my <code>ArticleController.php</code> in lumen:</p> <pre><code>&lt;?php namespace App\Http\Controllers; use Response; use Illuminate\Support\Facades\Input; use App\Article as Article; class ArticleController extends Controller { public function listAll(){ $articles = Article::all(); return response() -&gt;json($articles) -&gt;setCallback(Input::get('callback')); } } </code></pre> <p>Because I get that error for cross domain fetch, I am trying to use jsonp, but for some reason it's still not working.</p> <p>This is my code in React:</p> <pre><code>componentWillMount(){ fetch('http://localhost:8000/list?callback=asdf', { method: 'GET' }).then(function(res) { console.log(res); }).catch(function(err) { console.log(err); }) } </code></pre> <p>Any help would be appreciated. I'm very new to this kind of stuff. Thanks</p>
2
Excel File upload using Angular JS and Spring?
<p>I am new to Angular JS but I have good experience in Spring MVC. So, now I have the requirement where I need to upload a file. But, here I need to develop UI screen for uploading excel sheet using AngulaJS and backend will be Spring controller. Can anyone provide example for the same.</p>
2
Write tests in phpunit for Laravel json API
<p>I have trouble in create tests for my API in laravel. Here how look my routes.php:</p> <pre><code>Route::group(['middleware' =&gt;'api', 'prefix' =&gt; '/api/v1', 'namespace' =&gt; 'Api\V1'], function () { Route::post('/login', 'Auth\AuthController@postLogin'); Route::group(['middleware' =&gt;'jwt.auth'], function () { Route::post('/projects', 'ProjectsController@postProjects'); ... }); }); </code></pre> <p>My <code>ProjectsController@postProjects</code> looks like this (I test it by POSTman and it works fine):</p> <pre><code>public function postProjects() { $project = new Project; $project-&gt;fill(request()-&gt;all()); $project-&gt;user_id = Auth::user()-&gt;id; $project-&gt;save(); return ['project_id' =&gt; $project-&gt;id]; } </code></pre> <p>I write my own middelware for authentication using JWT cookie which is described in details <a href="https://stackoverflow.com/questions/38415851/how-to-make-jwt-cookie-authentication-in-laravel/38416675#38416675">here</a>. But in my test, I try to turn off middelware (<code>use WithoutMiddleware</code>)and act as logged user (<code>actingAs($user)</code> - I have user (id=1) in my DB). My test looks like that (I wrote it using <a href="https://laravel.com/docs/5.2/testing#testing-json-apis" rel="nofollow noreferrer">this documentation</a>):</p> <pre><code>&lt;?php use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\Models\User; class ProjectsTest extends TestCase { use WithoutMiddleware; /** * A basic functional test example. * * @return void */ public function testBasicExample() { $user = User::find(1); $this-&gt;actingAs($user) -&gt;json('POST', '/projects', ['name' =&gt; 'Project_test_name' ]) -&gt;seeJson([ 'project_id' =&gt; 1, ]); // THIS IS LINE 26 } } </code></pre> <p>But I get the following error during execution of <code>vendor/bin/phpunit</code>:</p> <blockquote> <p>Time: 182 ms, Memory: 13.75MB</p> <p>There was 1 error:</p> <p>1) ProjectsTest::testBasicExample ErrorException: Invalid argument supplied for foreach()</p> <p>/Users/Kamil/Desktop/Code/kumarajiva.com/vendor/laravel/framework/src/Illuminate/Support/Arr.php:494 /Users/Kamil/Desktop/Code/kumarajiva.com/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:232 /Users/Kamil/Desktop/Code/kumarajiva.com/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:257 /Users/Kamil/Desktop/Code/kumarajiva.com/tests/ProjectsTest.php:26</p> <p>FAILURES! Tests: 2, Assertions: 2, Errors: 1.</p> </blockquote> <p>Any ideas what to do with this error?</p>
2
Rails 5, Devise, Omniauth, Twitter
<p>I know this has been asked many times, but the answers are never fully acceptable to me.</p> <p>So I am following <a href="http://railscasts.com/episodes/235-devise-and-omniauth-revised?autoplay=true">Ryan Bates' Railscast</a> about this topic, and mixing that with the official <a href="https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview">Devise Omniauth guide</a> (that is based on FB), but I am just not getting it to work like I expect, so I would love some help. </p> <p>I have a <code>Users::OmniauthCallbacksController</code> that looks like this:</p> <pre><code>class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController def all @user = User.from_omniauth(request.env["omniauth.auth"]) if @user.persisted? sign_in_and_redirect root_path, :event =&gt; :authentication #this will throw if @user is not activated set_flash_message(:notice, :success, :kind =&gt; "Twitter") if is_navigational_format? else session["devise.twitter_data"] = request.env["omniauth.auth"].except("extra") flash[:notice] = flash[:notice].to_a.concat resource.errors.full_messages redirect_to new_user_registration_url end end alias_method :twitter, :all def failure redirect_to root_path end end </code></pre> <p>Then I also have two methods on my <code>User.rb</code></p> <pre><code> def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.update( email: auth.info.email, password: Devise.friendly_token[0,20], username: auth.info.nickname, remote_avatar_url: auth.info.image, token: auth.credentials.token, secret: auth.credentials.secret ) end end def self.new_with_session(params, session) super.tap do |user| if data = session["devise.twitter_data"] # user.attributes = params user.update( email: params[:email], password: Devise.friendly_token[0,20], username: data["info"]["nickname"], remote_avatar_url: data["info"]["image"], token: data["credentials"]["token"], secret: data["credentials"]["secret"] ) end end end </code></pre> <p>I run into a variety of problems. The most immediate is because I am setting the password, the user doesn't know the password when they try to login (and I don't auto sign them in upon confirmation).</p> <p>But if I don't set the password, it doesn't ask them to set the password...so that's kinda weird too.</p> <p>These are my devise settings on my <code>User</code> model:</p> <pre><code> devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable, :omniauth_providers =&gt; [:twitter] validates :username, presence: true, uniqueness: { case_sensitive: false } validate :validate_username def validate_username if User.where(email: username).exists? errors.add(:username, :invalid) end end </code></pre> <p>So my question is this, when someone signs up via Twitter, do they need to enter a password? I automatically send them to the <code>registration/new.html.erb</code> anyway because Twitter doesn't return an email value. But I am trying to just get the process working first, before optimizing it.</p> <p>How do I deal with the password issue?</p> <p><strong>Edit 1</strong></p> <p>For more clarity, I will have to deal with this <code>password_required</code> issue regardless of the OAuth provider.</p> <p>So how do I override that requirement for all OAuth providers?</p>
2
Wrong position of the BottomSheet in the screen
<p>After the pressing of FAB BottomSheet appears in the screen, but the position of it is wrong (see picture 1), I want to make it as in the picture 2. How to fix it? </p> <p>My Activity:</p> <pre><code>public class FirstscreenActivity extends AppCompatActivity implements RecyclerItemClickListener.OnItemClickListener, ItemAdapter.ItemListener { private BottomSheetDialog mBottomSheetDialog; BottomSheetBehavior behavior; private ItemAdapter mAdapterItem; private FloatingActionButton floatButton; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.front); floatButton = (FloatingActionButton) findViewById(R.id.float_button); floatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showBottomSheetDialog(); mBottomSheetDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mBottomSheetDialog.getWindow().setGravity(Gravity.BOTTOM); } }); View bottomSheet = findViewById(R.id.bottom_sheet); behavior = BottomSheetBehavior.from(bottomSheet); behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { // React to state change } @Override public void onSlide(@NonNull View bottomSheet, float slideOffset) { // React to dragging events } }); mAdapterItem = new ItemAdapter(createItems(), this); } @Override protected void onResume() { super.onResume(); RecyclerViewAdapter adapter = (RecyclerViewAdapter) mList.getAdapter(); adapter.notifyDataSetChanged(); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); return super.onPrepareOptionsMenu(menu); } private void showBottomSheetDialog() { if (behavior.getState() == BottomSheetBehavior.STATE_EXPANDED) { behavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } mBottomSheetDialog = new BottomSheetDialog(this); View view = getLayoutInflater().inflate(R.layout.sheet, null); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(new ItemAdapter(createItems(), new ItemAdapter.ItemListener() { @Override public void onItemClick(Item item) { if (mBottomSheetDialog != null) { mBottomSheetDialog.dismiss(); } } })); mBottomSheetDialog.setContentView(view); mBottomSheetDialog.show(); mBottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { mBottomSheetDialog = null; } }); } @Override protected void onDestroy() { super.onDestroy(); mAdapterItem.setListener(null); } public List&lt;Item&gt; createItems() { ArrayList&lt;Item&gt; items = new ArrayList&lt;&gt;(); items.add(new Item("Add new record")); items.add(new Item(R.drawable.camera, "from new shoots")); items.add(new Item(R.drawable.folder_multiple_image, "from ready images")); return items; } @Override public void onItemClick(Item item) { behavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } } </code></pre> <p>Code of the adapter of the RecyclerView, which is in the BottomSheet:</p> <pre><code>public class ItemAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; { private List&lt;Item&gt; mItems; private ItemListener mListener; public ItemAdapter(List&lt;Item&gt; items, ItemListener listener) { mItems = items; mListener = listener; } public void setListener(ItemListener listener) { mListener = listener; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { switch (viewType) { case 0: return new ViewHolderModified(LayoutInflater.from(parent.getContext()) .inflate(R.layout.bottom_title, parent, false)); default: return new ViewHolder(LayoutInflater.from(parent.getContext()) .inflate(R.layout.item, parent, false)); } } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (position == 0){ ViewHolderModified holderModified = (ViewHolderModified)holder; holderModified.setData(mItems.get(position)); } else { ViewHolder viewHolder = (ViewHolder)holder; viewHolder.setData(mItems.get(position)); } } @Override public int getItemCount() { return mItems.size(); } public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public ImageView imageView; public TextView textView; public Item item; public ViewHolder(View itemView) { super(itemView); itemView.setOnClickListener(this); imageView = (ImageView) itemView.findViewById(R.id.imageView); textView = (TextView) itemView.findViewById(R.id.textView); } public void setData(Item item) { this.item = item; imageView.setImageResource(item.getDrawableResource()); textView.setText(item.getTitle()); } @Override public void onClick(View v) { if (mListener != null) { mListener.onItemClick(item); } } } public class ViewHolderModified extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView textView; public Item item; public ViewHolderModified(View itemView) { super(itemView); itemView.setOnClickListener(this); textView = (TextView) itemView.findViewById(R.id.titleView); } public void setData(Item item) { this.item = item; textView.setText(item.getTitle()); } @Override public void onClick(View v) { if (mListener != null) { mListener.onItemClick(item); } } } public interface ItemListener { void onItemClick(Item item); } @Override public int getItemViewType(int position) { return position; } } </code></pre> <p>xml of the screen:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout 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:orientation="vertical"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#118b0a" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/my_toolbar" /&gt; &lt;android.support.design.widget.FloatingActionButton android:id="@+id/float_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_margin="16dp" android:src="@drawable/add_white" app:backgroundTint="@color/red" /&gt; &lt;android.support.design.widget.CoordinatorLayout android:layout_width="0dp" android:layout_height="0dp"&gt; &lt;LinearLayout android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#fff" android:gravity="bottom" android:orientation="vertical" app:layout_behavior="@string/bottom_sheet_behavior"&gt; &lt;/LinearLayout&gt; &lt;/android.support.design.widget.CoordinatorLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Item in the RecyclerView:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" android:clickable="true" android:gravity="center_vertical" android:orientation="horizontal"&gt; &lt;ImageView android:id="@+id/imageView" android:layout_width="40dp" android:layout_height="40dp" android:layout_margin="16dp" android:src="@mipmap/ic_launcher" /&gt; &lt;TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginStart="16dp" android:textColor="@color/black" android:gravity="center_vertical" android:textSize="22sp" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Xml of BottomSheet:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" android:clickable="true" android:gravity="center_vertical" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/titleView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginStart="16dp" android:gravity="center_vertical" android:textColor="#787878" android:textSize="20sp" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Picture 1:</p> <p><a href="https://i.stack.imgur.com/IsS6l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IsS6l.png" alt="enter image description here"></a></p> <p>Picture 2: </p> <p><a href="https://i.stack.imgur.com/omPuB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/omPuB.png" alt="enter image description here"></a></p>
2
Getting a reference to NgMap inside Angular controller
<p>This syntax taken from ngMap <a href="https://github.com/allenhwkim/angularjs-google-maps" rel="nofollow">https://github.com/allenhwkim/angularjs-google-maps</a> works fine:</p> <pre><code> angular .module('trails') .controller('MyController', function (NgMap) { NgMap.getMap().then(function (map) { console.log(map.getCenter()); console.log('markers', map.markers); console.log('shapes', map.shapes); }); }); </code></pre> <p>But the syntax I use for declaring controllers is different and I get the error: </p> <blockquote> <p>angular.js:13642 TypeError: Cannot read property 'getMap' of undefined</p> </blockquote> <p>It fails on the line as further below:</p> <blockquote> <p>NgMap.getMap().then(function (map) {</p> </blockquote> <p>The controller is declared as:</p> <pre><code> angular .module('trails') .controller('ActivityDetailsController', [ '$mdSidenav', '$mdBottomSheet', '$timeout', '$log', '$http', '$location', '$routeParams', ActivityDetailsController ]); function ActivityDetailsController($mdSidenav, $mdBottomSheet, $timeout, $log, $http, $location, $routeParams, NgMap) { var self = this; $http.get('/activity/detailStats/' + $routeParams.id, { params: { max: "1000" } }) .success(function (data) { self.stats = data.stats; // Zoom to fit var bounds = new google.maps.LatLngBounds(); for (var i = 0; i &lt; self.stats.activityTrackPoints.length; i++) { var latlng = new google.maps.LatLng(self.stats.activityTrackPoints[i][0], self.stats.activityTrackPoints[i][1]); bounds.extend(latlng); } NgMap.getMap().then(function (map) { map.setCenter(bounds.getCenter()); map.fitBounds(bounds); }); }) .error(function (data, status) { console.error('https error', status, data); }) .finally(function () { }); </code></pre> <p>I have tried adding the NgMap in other obvious places, such as:</p> <pre><code>...'$routeParams', NgMap, ActivityDetailsController... </code></pre> <p>or doing a ActivityDetailsController.$inject = NgMap before the controller declaration etc but it gives a similar error to above in that NgMap cannot be referenced.</p> <p>Edit: ngMap dependency was setup in another file similar to the answers already. Sorry I didn't put this earlier, but the above code that works and doesn't work are in the same place together so I thought it seemed ok to leave that out originally.</p> <pre><code>var app = angular .module('trails', ['ngMaterial', 'md.data.table', 'ngRoute', 'ngMap']) </code></pre> <p>I'm not sure if this is to do with the way I am incorrectly trying to inject NgMap using this controller declaration or something in NgMap...or most likely my inexperience with either framework!</p>
2
How to write a dataset of Null Terminated Fixed Length Strings with h5py
<p>I have an example in C++ that I'm trying to reproduce using h5py, but it is not working as expected. I'm getting null padded strings with h5py where I expect null terminated strings.</p> <p>Here is my C++ driver...</p> <p><code>main.cpp</code></p> <pre><code>#include &lt;hdf5.h&gt; int main(void) { auto file = H5Fcreate("test-c.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); char strings[5][64] = { "please work 0", "please work 1", "please work 2", "please work 3", "please work 4"}; auto H5T_C_S1_64 = H5Tcopy (H5T_C_S1); H5Tset_size(H5T_C_S1_64, 64); hsize_t dims[1] = {5}; auto dataspace = H5Screate_simple(1, dims, NULL); auto dataset = H5Dcreate(file, "test dataset", H5T_C_S1_64, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite (dataset, H5T_C_S1_64, H5S_ALL, H5S_ALL, H5P_DEFAULT, strings); H5Dclose(dataset); H5Sclose(dataspace); H5Tclose(H5T_C_S1_64); H5Fclose(file); return 0; } </code></pre> <p>Which I build with the following SCons script.</p> <p><code>SConstruct</code></p> <pre><code>env = Environment() env.Append(LIBS=['hdf5'], CPPFLAGS=['-std=c++11']) env.Program('writeh5', 'main.cpp') </code></pre> <p>And here is my python script that I'm trying to get to write out the same hdf5 file with.</p> <p><code>main.py</code></p> <pre><code>import h5py hdf5 = h5py.File('test-p.h5', 'w') H5T_C_S1_64 = h5py.h5t.C_S1.copy() H5T_C_S1_64.set_size(64) print "Null Terminated String: %s" % ( H5T_C_S1_64.get_strpad() == h5py.h5t.STR_NULLTERM) dataset = hdf5.create_dataset('test dataset', (5,), data=['please work %s' % n for n in xrange(5)], dtype=H5T_C_S1_64) hdf5.close() </code></pre> <p>I'm using python v2.7.11, and I have tried this with h5py v2.5.0, and v2.6.0, with the following same results.</p> <pre><code>&gt;&gt; python --version Python 2.7.11 &gt;&gt; python -c "import h5py; print h5py.version.version" 2.5.0 &gt;&gt; tree . ├── main.cpp ├── main.py └── SConstruct 0 directories, 3 files &gt;&gt; scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... g++ -o main.o -c -std=c++11 main.cpp g++ -o writeh5 main.o -lhdf5 scons: done building targets. &gt;&gt; tree . ├── main.cpp ├── main.o ├── main.py ├── SConstruct └── writeh5 0 directories, 5 files &gt;&gt; ./writeh5 &gt;&gt; tree . ├── main.cpp ├── main.o ├── main.py ├── SConstruct ├── test-c.h5 └── writeh5 0 directories, 6 files &gt;&gt; python main.py Null Terminated String: True &gt;&gt; tree . ├── main.cpp ├── main.o ├── main.py ├── SConstruct ├── test-c.h5 ├── test-p.h5 └── writeh5 0 directories, 7 files &gt;&gt; h5dump test-c.h5 HDF5 "test-c.h5" { GROUP "/" { DATASET "test dataset" { DATATYPE H5T_STRING { STRSIZE 64; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SIMPLE { ( 5 ) / ( 5 ) } DATA { (0): "please work 0", "please work 1", "please work 2", (3): "please work 3", "please work 4" } } } } &gt;&gt; h5dump test-p.h5 HDF5 "test-p.h5" { GROUP "/" { DATASET "test dataset" { DATATYPE H5T_STRING { STRSIZE 64; STRPAD H5T_STR_NULLPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SIMPLE { ( 5 ) / ( 5 ) } DATA { (0): "please work 0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", (1): "please work 1\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", (2): "please work 2\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", (3): "please work 3\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", (4): "please work 4\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" } } } } </code></pre> <p>As you can see from the output above, I am still ending up with null padded fixed length strings when using h5py, even though I am specifying I want null terminated fixed length strings.</p> <p>So how do I modify my python script to end up with null terminated fixed length strings in the dataset? If it is a bug in h5py, are there any workarounds?</p> <p>Thanks in advance for any help.</p>
2
Windows 10 (UWP) manifest issue
<p>My UWP app has these package.manifest extensions content:</p> <pre><code> &lt;Extensions&gt; &lt;Extension Category="windows.activatableClass.inProcessServer"&gt; &lt;InProcessServer&gt; &lt;Path&gt;MobilePos.Win10.exe&lt;/Path&gt; &lt;ActivatableClass ActivatableClassId="PclUtilitiesUniversel.CompanionInfo" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PclUtilitiesUniversel.DeviceManager" ThreadingModel="both" /&gt; &lt;/InProcessServer&gt; &lt;/Extension&gt; &lt;Extension Category="windows.activatableClass.inProcessServer"&gt; &lt;InProcessServer&gt; &lt;Path&gt;PCLServiceUniversel.dll&lt;/Path&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.TransOut" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.PCLService" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.TransIn" ThreadingModel="both" /&gt; &lt;/InProcessServer&gt; &lt;/Extension&gt; &lt;/Extensions&gt; </code></pre> <p>But when i compile (tried to rebuild in debug/release mode too) the project, appxmanifest.xml generated has a new "CLRHost.dll" tag added automatically, that generate error (in Visual Studio 2015):</p> <blockquote> <p>error C00CE012: App manifest validation error: The app manifest must be valid as per schema: Line 63, Column 8, Reason: In base a quanto definito nella DTD o nello schema, il contenuto dell'elemento "{<a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10" rel="nofollow">http://schemas.microsoft.com/appx/manifest/foundation/windows10</a>}InProcessServer" è incompleto. Previsto: {<a href="http://schemas.microsoft.com/appx/manifest/foundation/windows10" rel="nofollow">http://schemas.microsoft.com/appx/manifest/foundation/windows10</a>}ActivatableClass.</p> </blockquote> <pre><code> &lt;Extensions&gt; &lt;Extension Category="windows.activatableClass.inProcessServer"&gt; &lt;InProcessServer&gt; &lt;Path&gt;MobilePos.exe&lt;/Path&gt; &lt;ActivatableClass ActivatableClassId="PclUtilitiesUniversel.CompanionInfo" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PclUtilitiesUniversel.DeviceManager" ThreadingModel="both" /&gt; &lt;/InProcessServer&gt; &lt;/Extension&gt; &lt;Extension Category="windows.activatableClass.inProcessServer"&gt; &lt;InProcessServer&gt; &lt;Path&gt;PCLServiceUniversel.dll&lt;/Path&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.TransOut" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.PCLService" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.TransIn" ThreadingModel="both" /&gt; &lt;/InProcessServer&gt; &lt;/Extension&gt; &lt;Extension Category="windows.activatableClass.inProcessServer"&gt; &lt;InProcessServer&gt; &lt;Path&gt;CLRHost.dll&lt;/Path&gt; &lt;/InProcessServer&gt; &lt;/Extension&gt; &lt;/Extensions&gt; </code></pre> <p>Why during building tags "<strong>CLRHost.dll</strong>" is added? Where i'm wrong in manifest data?</p> <p>Thank you for any suggestions, Lewix</p> <p><strong>UPDATE</strong> Seems adding only these tags (only one dll) project build successfully</p> <pre><code> &lt;Extensions&gt; &lt;Extension Category="windows.activatableClass.inProcessServer"&gt; &lt;InProcessServer&gt; &lt;Path&gt;PCLServiceUniversel.dll&lt;/Path&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.TransOut" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.PCLService" ThreadingModel="both" /&gt; &lt;ActivatableClass ActivatableClassId="PCLServiceUniversel.TransIn" ThreadingModel="both" /&gt; &lt;/InProcessServer&gt; &lt;/Extension&gt; &lt;/Extensions&gt; </code></pre>
2
float d3 SVG element to top right corner CSS
<p>I have the following drawing appended to canvas:</p> <pre><code>&lt;svg data="BusinessRoleFigure" x="180" y="110" width="128" height="66" id="WA7WAcWA0WAaWA4WA3WA3WA9" style="position: relative;"&gt; &lt;rect x="0" y="0" width="100%" height="100%" stroke="rgb(178,178,126)" stroke-width="1" fill="rgb(255,255,181)" style="position: relative;"&gt; &lt;/rect&gt; &lt;rect stroke="black" fill="black" class="insider" style="right: 0px;top: 0px;"&gt; &lt;/rect&gt; &lt;/svg&gt; </code></pre> <p>I have the following CSS for class <strong>.insider</strong></p> <pre><code>.insider{ height:20px; width:40px; top:0; right:0; fill:green; position:absolute; float:right; x:40px; } </code></pre> <p>I want the second rect element with class insider to stick to the top right of the main SVG element. I tried <strong>float;right</strong> and <strong>top:0; right:0;</strong> in CSS but that doesn't makes it move. However, if I specify the <strong>X</strong> and <strong>Y</strong> value in the CSS the rect changes it's position. </p> <p><a href="https://jsfiddle.net/L9kjjpwh/" rel="nofollow">JsFiddle</a></p> <p>How can I make it stick to the top right corner when the parent (SVG) is resized?</p>
2
How to convert HashMap to XML using dataweave in mule
<p>I want to convert DB records into XML. Select query from DB records is giving LinkedHashMap as payload. Now I want to use dataweave to transform this into XML. I am pretty new to mule so a bit lost. What all steps do I need to follow to do this?</p> <p>Thank you.</p>
2
Android light and fast way to implement data storage from Api Rest service
<p>I'd have to implement a simple app that retrieves some data from Api Rest service through JSON and save them to internal data storage.</p> <p>Until now, I'm using AsynTask custom class for each call but it seems a complicated and slow process to retrieve json, check, parse and save it to storage ( I'm usic DBHelper with an SQLLite DB ).</p> <p>I don't need to manage a large amount of data, I need to manage events with some strings, an image url, and some dates. The important is having a fast process to load/update/storage/retrieve information from API Rest Service to android internal storage.</p> <p>What is the best solution to implement it?</p> <p>Thank you guys</p>
2
VHDL: How to use 2 regular 4-Bit adders to design an 8-Bit BCD counter?
<p>Unlike most counters that i have viewed on this website, my BCD counter requires the use of two 4-Bit adders in order to make 1 8-Bit BCD counter. What I have done so far is design a regular full adder, used that to design a regular 4 bit adder.</p> <p>This is my code so far:</p> <pre><code>library ieee; use ieee.std_logic_1164.all; entity adder8b_custom is port( X: in std_logic_vector( 7 downto 0); Y: in std_logic_vector (7 downto 0); S: out std_logic_vector (7 downto 0)); end adder8b_custom; architecture adder8b_custom of adder8b_custom is component adder4b port ( X : in STD_LOGIC_VECTOR (3 downto 0); Y : in STD_LOGIC_vector (3 downto 0); C0: in STD_LOGIC; S : out STD_LOGIC_VECTOR (3 downto 0); C4: out STD_LOGIC); end component; signal s1:std_logic_vector ( 7 downto 0); --for addition signal s2:std_logic_vector ( 7 downto 0); --for subtraction signal s3, s4, s5, s6: std_logic_vector (3 downto 0);--placeholders signal i, j, k, l: std_logic; begin u1: adder4b port map (X =&gt; X (3 downto 0), Y =&gt; "0001",c0=&gt;'0', S =&gt; s3 (3 downto 0), c4=&gt;i); s1(3 downto 0) &lt;=s3(3 downto 0) when s3 (3 downto 0) /="1010" else "0000"; s&lt;=s1; --u2: adder4b port map (X =&gt; X (7 downto 4), Y =&gt; "0001" ,c0 =&gt; i, S =&gt; s4 (3 downto 0), c4=&gt;j); --s1( 7 downto 4) &lt;= s4( 3 downto 0) when s4( 3 downto 0) /= "1010" --else "0000"; --s(7 downto 4)&lt;= s1; end; </code></pre> <p>As you can see, everything after the signals is messed up and i do know know how to fix it.</p> <p>I appreciate all input.</p>
2
Trigger function on click for hangman game
<p>I'm new to JavaScript and have been trying to code up this Hangman game, but am running into issues. What I have to far is the following: </p> <p>My HTML: </p> <pre><code>&lt;div class="col-md-4"&gt; &lt;div id="placeHolder"&gt;_ _ _ _ _ _&lt;/div&gt; &lt;div id="gamestatus"&gt;&lt;/div&gt; &lt;input type="text" size="1" id="letterGuess" maxlength="1"&gt; &lt;button id="button" onclick="guess()"&gt;Press to start&lt;/button&gt; &lt;/div&gt; </code></pre> <p>My JavaScript:</p> <pre><code>var dictionary = ['music', 'mountain', 'forest', 'florida', 'sweden', 'golf']; var wordUsed, input, placeHolder; function startGame() { placeHolder = ""; var totalGuesses = 10; wordUsed = dictionary[Math.floor(Math.random() * dictionary.length)]; console.log(wordUsed); var buttonText = document.getElementById("button").innerHTML = "Guess"; for(var i = 0; i &lt; wordUsed.length; i++) { placeHolder += "_ "; } document.getElementById("placeHolder").innerHTML = placeHolder; document.getElementById("gamestatus").innerHTML = "Game is in progress."; } function guess() { var correctGuess = false; var ip = document.getElementById("letterGuess"); input = ip.value; for(var i = 0; i &lt; wordUsed.length; i++) { if(input == wordUsed.substring(i, i + 1)) { correctGuess = true; placeHolder = placeHolder.substring(0, i) + input + placeHolder.substring(i + 1, placeHolder.length + 1); document.getElementById("placeHolder").innerHTML = placeHolder; } } if(!correctGuess) { totalGuesses--; } if(placeHolder == wordUsed) { alert("You WIN!"); } if(totalGuesses == 0) { alert("You LOSE!") startGame(); } } startGame(); document.getElementById("button").onclick = guess; </code></pre> <p>So the code is correctly selecting a word and placing the correct amount of underscores in places of the letters; but nothing happens when I run my code. I might've over-looked something really simple and would really appreciate if someone could point out what is wrong with the code/logic. </p> <p>Also, any other tips on how to improve the code/logic will be appreciated! Thanks. </p>
2
Can't connect to AWS PostgreSQL instance
<p>I'm trying to login to a newly created PostgreSQL DB instance created using AWS's RDS service.</p> <p>This is the command I've been running (I've redacted the sensitive info): </p> <pre><code>psql \ --host=my_aws_end_point \ --port=5432 \ --username the_username \ --password the_password \ --dbname=ebdb </code></pre> <p>For the security group associated with the instance I have allowed the following inbound connections:</p> <pre><code>PostgreSQL TCP 5432 PostgreSQL TCP 5432 My_IP PostgreSQL TCP 5432 0.0.0.0/0 All traffic All All 0.0.0.0/0 Custom TCP Rule TCP 0 0.0.0.0/0 </code></pre> <p>This is the error I'm getting:</p> <pre><code>psql: could not connect to server: Operation timed out Is the server running on host "aws_db_enpoint..." (IP...) and accepting TCP/IP connections on port 5432? </code></pre> <p>I've also tried running other commands but have ran into the same issue.</p> <p>The one command that does seem to work is the following:</p> <pre><code>pg_restore -v -h 'aws_db_enpoint' --port 5432 -U user_name dump.sql </code></pre> <p>Any help would be much appreciated!</p>
2
How to index Dynamodb streams data in Amazon Elasticsearch Services via AWS Lambda?
<p>I followed step by step <a href="https://aws.amazon.com/fr/blogs/compute/indexing-amazon-dynamodb-content-with-amazon-elasticsearch-service-using-aws-lambda/" rel="nofollow noreferrer">this tutorial</a> but when I'm arriving at the "Testing the result" step, I don't see my table name in the indices time as "all products" is showed in the example.</p> <p>So it means my dynamodb table is not indexed in my Amazon ES domain.</p> <p>I set all authorizations and configured lambda just as in the example.</p> <p>Now I just don't know how to do for triggering my dynamodb streams in AWS ES.</p>
2
Jsoup selector - How to select the first 5 <p> elements inside <div> element
<p>There is a bunch of html elements as following:</p> <pre><code>&lt;div class="abcdefghijk"&gt; &lt;p&gt;a&lt;/p&gt; &lt;p&gt;b&lt;/p&gt; &lt;p&gt;c&lt;/p&gt; &lt;p&gt;d&lt;/p&gt; &lt;p&gt;e&lt;/p&gt; &lt;p&gt;f&lt;/p&gt; &lt;p&gt;h&lt;/p&gt; &lt;p&gt;i&lt;/p&gt; &lt;p&gt;j&lt;/p&gt; &lt;p&gt;k&lt;/p&gt; &lt;/div&gt; </code></pre> <p>I want to select the first 5 <code>&lt;p&gt;</code> elements. Please help!</p>
2
Unity Networking - [command] function executes when it is not supposed to
<p>I'm fairly new to unity networking and Networking itself.</p> <p><strong>Game:</strong> I have 2 players multiplayer game where each player can shoot.</p> <p><strong>Problem:</strong></p> <p>Code 1 makes both players shoot (in the host game only) when host player press spacebar. The client player cannot shoot from the client's game. </p> <p>Note: the <code>if (Input.GetKeyDown (KeyCode.Space))</code> is inside the CmdShoot method.</p> <p><em>Code 2 executes correctly</em>. Host can shoot in the host game and the client can shoot from the client's game.</p> <p>Note: the <code>if (Input.GetKeyDown (KeyCode.Space))</code> is outside the CmdShoot method for code 2.</p> <p><strong>Question:</strong> In code 1, why can't the client shoot and why does host makes both player shoot?</p> <p>Code 1:</p> <pre><code>// Update is called once per frame void Update () { if (!isLocalPlayer) { return; } CmdShoot (); } [Command] void CmdShoot(){ if (Input.GetKeyDown (KeyCode.Space)) { GameObject force_copy = GameObject.Instantiate (force) as GameObject; force_copy.transform.position = gameObject.transform.position + gameObject.transform.forward; force_copy.GetComponent&lt;Rigidbody&gt;().velocity = gameObject.transform.forward * force.GetComponent&lt;Force&gt;().getSpeed(); NetworkServer.Spawn (force_copy); Destroy (force_copy, 5); } } </code></pre> <p>Code 2:</p> <pre><code>// Update is called once per frame void Update () { if (!isLocalPlayer) { return; } if (Input.GetKeyDown (KeyCode.Space)) { CmdShoot (); } } [Command] void CmdShoot(){ GameObject force_copy = GameObject.Instantiate (force) as GameObject; force_copy.transform.position = gameObject.transform.position + gameObject.transform.forward; force_copy.GetComponent&lt;Rigidbody&gt;().velocity = gameObject.transform.forward * force.GetComponent&lt;Force&gt;().getSpeed(); NetworkServer.Spawn (force_copy); Destroy (force_copy, 5); } </code></pre>
2
line graph spot in the top middle of the bar graph
<p>I have created a combo dual bar graph using chartjs. My code is given below. The bar combo dual graph is working fine but I had got a requirement to put a line for the green color bar graph which connects all its top mid points. I have somewhat drew a line graph connecting the green graph but the problem which I am facing is that the line graph spot point is not in the top middle of the green bar graph like as shown below.</p> <p>Can anyone please tell me how to make the line spot in the top middle of the bar graph</p> <p><a href="https://i.stack.imgur.com/2K4hV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2K4hV.png" alt="![enter image description here"></a></p> <p><strong><a href="http://plnkr.co/edit/lETsyOckH7Q0Sdylc6Tk?p=preview" rel="noreferrer">Working Demo</a></strong></p> <p><strong>html</strong></p> <pre><code>&lt;canvas id="canvas"&gt;&lt;/canvas&gt; </code></pre> <p><strong>js</strong></p> <pre><code>var barChartData = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ type: 'bar', label: "Visitor", data: [10, 59, 340, 521, 450, 200, 195], fill: false, backgroundColor: "rgba(220,220,220,0.5)", borderColor: '#71B37C', hoverBackgroundColor: '#71B37C', hoverBorderColor: '#71B37C' }, { type: 'bar', label: "Visitor", data: [200, 185, 590, 621, 250, 400, 95], fill: false, backgroundColor: '#71B37C', borderColor: '#71B37C', hoverBackgroundColor: '#71B37C', hoverBorderColor: '#71B37C' }, { type:'line', data: [200, 185, 590, 621, 250, 400, 95], fill: false, borderColor: '#EC932F', backgroundColor: '#EC932F', pointBorderColor: '#EC932F', pointBackgroundColor: '#EC932F', pointHoverBackgroundColor: '#EC932F', pointHoverBorderColor: '#EC932F' } ] }; window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx, { type: 'bar', data: barChartData, options: { responsive: true, tooltips: { mode: 'label' }, elements: { line: { fill: false } }, scales: { xAxes: [{ display: true, gridLines: { display: false }, labels: { show: true, } }], yAxes: [{ type: "linear", display: true, position: "left", id: "y-axis-1", gridLines:{ display: false }, labels: { show:true, } }, { type: "linear", display: true, position: "right", id: "y-axis-2", gridLines:{ display: false }, labels: { show:true, } }] } } }); }; </code></pre>
2
Spark append mode for partitioned text file fails with SaveMode.Append - IOException File already Exists
<p>Something simple as writing partitioned text files fails.</p> <pre><code>dataDF.write.partitionBy("year", "month", "date").mode(SaveMode.Append).text("s3://data/test2/events/") </code></pre> <p>Exception - </p> <pre><code>16/07/06 02:15:05 ERROR datasources.DynamicPartitionWriterContainer: Aborting task. java.io.IOException: File already exists:s3://path/1839dd1ed38a.gz at com.amazon.ws.emr.hadoop.fs.s3n.S3NativeFileSystem.create(S3NativeFileSystem.java:614) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:913) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:894) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:791) at com.amazon.ws.emr.hadoop.fs.EmrFileSystem.create(EmrFileSystem.java:177) at org.apache.hadoop.mapreduce.lib.output.TextOutputFormat.getRecordWriter(TextOutputFormat.java:135) at org.apache.spark.sql.execution.datasources.text.TextOutputWriter.&lt;init&gt;(DefaultSource.scala:156) at org.apache.spark.sql.execution.datasources.text.TextRelation$$anon$1.newInstance(DefaultSource.scala:125) at org.apache.spark.sql.execution.datasources.BaseWriterContainer.newOutputWriter(WriterContainer.scala:129) at org.apache.spark.sql.execution.datasources.DynamicPartitionWriterContainer.newOutputWriter$1(WriterContainer.scala:424) at org.apache.spark.sql.execution.datasources.DynamicPartitionWriterContainer.writeRows(WriterContainer.scala:356) at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelation$$anonfun$run$1$$anonfun$apply$mcV$sp$3.apply(InsertIntoHadoopFsRelation.scala:150) at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelation$$anonfun$run$1$$anonfun$apply$mcV$sp$3.apply(InsertIntoHadoopFsRelation.scala:150) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66) at org.apache.spark.scheduler.Task.run(Task.scala:89) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 16/07/06 02:15:05 INFO output.DirectFileOutputCommitter: Nothing to clean up on abort since there are no temporary files written 16/07/06 02:15:05 ERROR datasources.DynamicPartitionWriterContainer: Task attempt attempt_201607060215_0004_m_001709_3 aborted. 16/07/06 02:15:05 ERROR executor.Executor: Exception in task 1709.3 in stage 4.0 (TID 12093) org.apache.spark.SparkException: Task failed while writing rows. at org.apache.spark.sql.execution.datasources.DynamicPartitionWriterContainer.writeRows(WriterContainer.scala:414) at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelation$$anonfun$run$1$$anonfun$apply$mcV$sp$3.apply(InsertIntoHadoopFsRelation.scala:150) at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelation$$anonfun$run$1$$anonfun$apply$mcV$sp$3.apply(InsertIntoHadoopFsRelation.scala:150) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66) at org.apache.spark.scheduler.Task.run(Task.scala:89) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: File already exists:s3://path/a984-1839dd1ed38a.gz at com.amazon.ws.emr.hadoop.fs.s3n.S3NativeFileSystem.create(S3NativeFileSystem.java:614) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:913) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:894) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:791) at com.amazon.ws.emr.hadoop.fs.EmrFileSystem.create(EmrFileSystem.java:177) at org.apache.hadoop.mapreduce.lib.output.TextOutputFormat.getRecordWriter(TextOutputFormat.java:135) at org.apache.spark.sql.execution.datasources.text.TextOutputWriter.&lt;init&gt;(DefaultSource.scala:156) at org.apache.spark.sql.execution.datasources.text.TextRelation$$anon$1.newInstance(DefaultSource.scala:125) at org.apache.spark.sql.execution.datasources.BaseWriterContainer.newOutputWriter(WriterContainer.scala:129) at org.apache.spark.sql.execution.datasources.DynamicPartitionWriterContainer.newOutputWriter$1(WriterContainer.scala:424) at org.apache.spark.sql.execution.datasources.DynamicPartitionWriterContainer.writeRows(WriterContainer.scala:356) ... 8 more </code></pre>
2
How to set clientUserId for a Recipient in DocuSign using the REST API?
<p>I'm trying to create a RecipientView to send through an app to the recipients of envelopes that are created. With DocuSign's newer API, this requires a <code>userName</code> which is entered by the person who creates the document needed to be signed, an <code>email</code> which is just the email of the recipient, and a <code>clientUserId</code> which is a sender generated string value that authenticates the recipient as an embedded signer so that a RecipientView can be generated to host the signing ceremony.</p> <p>DocuSign documentation references that I need to set <code>clientUserId</code>, but it doesn't mention <strong>how</strong> to to do this other than when the envelope is created through the API. However, in this scenario, envelopes will be created by DocuSign Admin clients through the templates on the actual web interface, and <strong>not</strong> through the API. </p> <p>My code to generate the RecipientView is all set up here:</p> <pre><code>$url = "https://demo.docusign.net/restapi/v2/accounts/$account_id/envelopes/$envelope_id/views/recipient"; $body = array("returnUrl" =&gt; "http://www.docusign.com/devcenter", "authenticationMethod" =&gt; "None", "email" =&gt; "$email", "userName" =&gt; "$name", "recipientId" =&gt; "$recipientId", "clientUserId" =&gt; "1000" ); $body_string = json_encode($body); $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Accept: application/json', 'Content-Type: application/json', 'Content-Length: '.strlen($body_string), "Authorization: Bearer $access_token" )); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $body_string); $json_response = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($status != 201){ die('Could not connect to end point: '.mysqli_error($conn)); } $response = json_decode($json_response, true); $url = $response["url"]; </code></pre> <p>This code <strong>does</strong> work when the embedded signer is the Admin account, but not when the envelope is sent to an actual recipient. The return JSON from DocuSign after this request should be:</p> <pre><code>{ "url": "example.example.com" } </code></pre> <p>However, the return I get for recipients that are not the Admin of the DocuSign account is:</p> <pre><code>{ "errorCode": "UNKNOWN_ENVELOPE_RECIPIENT", "message": "The recipient you have identified is not a valid recipient of the specified envelope." } </code></pre> <p>I believe not setting <code>clientUserId</code> is the reason behind this, since the <a href="https://www.docusign.com/developer-center/explore/features/embedding-docusign" rel="nofollow">documentation</a> says I need to set <code>clientUserId</code> and not just create a value when making the call. How do I set a recipient's <code>clientUserId</code> via the REST API?</p> <p><strong>UPDATE:</strong> Within this scenario, I will not be the one creating and sending envelopes. That will be done by the clients I have through my app, and the large majority of them will most likely use the web interface to do this, not the API. I do have access to all information regarding the Admin account for each client, including the Integrator Key, Access Tokens, Envelope IDs, Account IDs, etc.</p>
2
Undefined symbols for architecture arm64 xcode 7.3
<p>I have created a static library with simple math function and built a universal binary with it. Build for active architectures only was set to NO while building this. </p> <pre><code>lipo -info libcheckC.a Architectures in the fat file: libcheckC.a are: armv7 x86_64 arm64 </code></pre> <p>I have added this file to another project and verified that Other linker flags have -ObjC, -lcheckC, $(inherited)</p> <p>The library is also present under "Build Phases --> Link binary with libraries".</p> <p>I have created the bridging header and added the header file to my project.</p> <p>I am still getting the error </p> <pre><code>Undefined symbols for architecture arm64: "_squareOf", referenced from: checkCLib.ViewController.calculate (__ObjC.UIButton) -&gt; () in ViewController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) </code></pre> <p>I am using Xcode 7.3</p> <p>When I try the command manually, I fire following - copied from Xcode with added -v and going deeper from there. I get following details.</p> <pre><code>@(#)PROGRAM:ld PROJECT:ld64-264.3.101 configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) Library search paths: /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/ /Users/test/Documents/MyIApps/checkCLib/checkCLib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/usr/lib Framework search paths: /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/ /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/ Undefined symbols for architecture arm64: "_squareOf", referenced from: checkCLib.ViewController.calculate (__ObjC.UIButton) -&gt; () in ViewController.o ld: symbol(s) not found for architecture arm64 </code></pre> <p>The library exists at the mentioned path, contains the symbol and supports the architecture as well.</p> <pre><code>lipo -info /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a Architectures in the fat file: /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a are: armv7 x86_64 arm64 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a /Users/test/Library/Developer/Xcode/DerivedData/Build/Products/Release-universal/libcheckC.a(square.o): 0000000000000000 T _sqaureOf </code></pre>
2
var_dump a php Class object reveals database username and password
<p>I am a bit worried when I incidentally <code>var_dump()</code> the object of a child class, the result showed all my sql elements and variable values including database username,password and DBname. Is there a security issue with it. If yes how do I shield it? Would be thankful if someone show me a light on it.</p> <pre><code>$ClassObject=new MyChildClass(); var_dump($ClassObject); </code></pre> <p>A sample result is as follows:-</p> <blockquote> <p>object(MyChildClass)#1 (17) { ["database":protected]=> object(Crud)#2 (13) { ["rows"]=> string(12) "column_name" ["vals"]=> NULL ["query"]=> NULL ["table"]=> string(8) "users" ["DB_TYPE":"Database":private]=> string(5) "mysql" ["host":"Database":private]=> string(9) "localhost" ["user":"Database":private]=> string(4) "root" ["pass":"Database":private]=> string(7) "mypass" ["db":"Database":private]=> string(13) "mydbname" ["conn":"Database":private]=> object(PDO)#3 (0) { } ["error":"Database":private]=> NULL ["result"]=> NULL ["stmt":"Database":private]=> object(PDOStatement)#5 (1) { ["queryString"]=> string(51) "SELECT column_name FROM ms_users WHERE userid=:uid" } } ["loguserid":"Users":private]=> string(1) "4" ["rows"]=> array(0) { } ["vals"]=> NULL ["query"]=> NULL ["table"]=> string(16) "MyTable_name" ["DB_TYPE":"Database":private]=> string(5) "mysql" ["host":"Database":private]=> string(9) "localhost" ["user":"Database":private]=> string(4) "root" ["pass":"Database":private]=> string(7) "MyPass" ["db":"Database":private]=> string(13) "mydbname" ["conn":"Database":private]=> NULL ["error":"Database":private]=> NULL ["result"]=> NULL ["stmt":"Database":private]=> NULL ["join"]=> string(0) "" ["where"]=> string(35) "user_id=:id1 AND column_name=:id2" }</p> </blockquote>
2
Linux support for AMP architecture?
<p>When I search about linux kernel, I know that linux support for SMP architecture.<br> But I don't find any specification about the linux for AMP.<br> Does linux support for AMP?<br> Have any documents or specification for descripting about that? </p> <p>Anyone help?</p>
2
Realm Swift: Is it possible to keep database after the apps is uninstalled?
<p>Using realm swift, is it possible to keep and maintain the realm database file of the apps in device memory even after the apps is uninstalled from the device?</p> <p>Thank you very much for any help.</p>
2
Dexie: difference bulkPut and BulkAdd
<p>I have checked <a href="https://github.com/dfahlander/Dexie.js/wiki/WriteableTable" rel="nofollow">the Documentation</a>, but there seems to be no difference between using bulkPut and bulkAdd.</p> <p>Yet I noticed that when I try to use bulkAdd with a list of events including one that I previously deleted, it does not add this event. If I use bulkPut it does add the event.</p> <p>I would like to have a better understanding of the difference between this two methods.</p> <p>Thanks</p>
2
MP3 Title in VB.net
<p>I'm trying to get the title of an MP3 which is in the properties. For example the file name is "iasn_E_052" but the song title is "Guard Your Heart". Getting the file name is easy but the song title is I don't know how. I'm using vb.net visual studio 2013.</p>
2
Rendering html to pdf
<p>I am new to Laravel. I want to convert my HTML page into PDF therefore I am using:</p> <p><a href="https://github.com/barryvdh/laravel-snappy" rel="nofollow">https://github.com/barryvdh/laravel-snappy</a></p> <p>Now from my controller I am using the following code:</p> <pre><code>$data = $this-&gt;getdata(); $html = view('myview', [ 'data' =&gt; $data] )-&gt;render(); $pdf = \App::make('snappy.pdf.wrapper'); $pdf-&gt;loadHtml($html); return $pdf-&gt;inline(); </code></pre> <p>When I dump or return the <code>$html</code> variable, it's giving the desire view on the browser but when I convert it its not giving that output. My HTML page is also using Bootstrap but I think after rendering its just a normal HTML string. Can anyone tell what I am missing here?</p> <p>I have also tried <code>$pdf-&gt;loadView()</code> but it's not working.</p>
2
How can I turn all my 'perform_later's into 'perform_now's locally?
<p>I'm working on a product that calls of <code>perform_later</code> jobs. This works for our product in production because we have a series of workers who will run all the jobs. </p> <p>But, when I'm using the app locally, I don't have access to these workers, and I'd like to change all the <code>perform_later</code>s into <code>perform_now</code>s <em>only when</em> I use the app locally. </p> <p>What's the best way to do this? One idea I had was to add something in my <code>env</code> file that would add a variable to make all <code>perform_later</code>s into <code>perform_now</code>s -- but I'm not sure what a flag or variable like that would look like. </p> <p>Ideas?</p>
2
Angular2 CLI what is different from ng build and auto reload?
<blockquote> <p>When i do <code>ng build</code> i have a set of files in my <code>/dist/vendor</code> folder. </p> </blockquote> <p><a href="https://i.stack.imgur.com/L4JpC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L4JpC.png" alt="enter image description here"></a> </p> <blockquote> <p>But when a file change is detected with the magic scripts that reload the browser page, and some other magic that they do, my <code>dist/vendor</code> folder gets "screwed" somehow. Look: </p> </blockquote> <p><a href="https://i.stack.imgur.com/S6DOd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S6DOd.png" alt="enter image description here"></a> </p> <p>This is my <code>angular-cli-build.js</code> that should be responsible for this, but i don't see how:</p> <pre><code>var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); module.exports = function(defaults) { return new Angular2App(defaults, { vendorNpmFiles: [ 'systemjs/dist/system-polyfills.js', 'systemjs/dist/system.src.js', 'zone.js/dist/**/*.+(js|js.map)', 'es6-shim/es6-shim.js', 'reflect-metadata/**/*.+(js|js.map)', 'rxjs/**/*.+(js|js.map)', '@angular/**/*.+(js|js.map)', // above are the existing entries // below are the AngularFire entries 'angularfire2/**/*.js', 'firebase/*.js', '@angular2-material/**/*.js', 'ng2-uploader/*.js', 'underscore/underscore.js', 'primeng/**/*.js', 'primeui/**/*.*' ] }); }; </code></pre> <p>This is the package.json:</p> <pre><code>{ "name": "test", "version": "1.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "postinstall": "typings install", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", "pree2e": "webdriver-manager update", "e2e": "protractor" }, "private": true, "dependencies": { "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", "@angular/core": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/router": "3.0.0-alpha.3", "@angular2-material/button": "^2.0.0-alpha.6", "@angular2-material/checkbox": "^2.0.0-alpha.6", "@angular2-material/core": "^2.0.0-alpha.6", "angularfire2": "^2.0.0-beta.2", "es6-shim": "0.35.1", "firebase": "^3.0.5", "ng2-slim-loading-bar": "^1.2.3", "primeng": "^1.0.0-beta.9", "primeui": "^4.1.12", "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", "systemjs": "0.19.26", "underscore": "^1.8.3", "zone.js": "0.6.12" }, "devDependencies": { "angular-cli": "1.0.0-beta.6", "codelyzer": "0.0.20", "ember-cli-inject-live-reload": "1.4.0", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "0.13.22", "karma-chrome-launcher": "0.2.3", "karma-jasmine": "0.3.8", "protractor": "3.3.0", "ts-node": "0.5.5", "tslint": "3.11.0", "typescript": "1.8.10", "typings": "0.8.1" } } </code></pre> <p><strong>This is messing up my 3-rd party libraries. Why is this happening?</strong></p>
2
MySQl IF NOT EXISTS, CREATE Stored procedure
<p>I come from a background with Microsoft SQl using their Server management studio. I have recently switched to mysql and am looking to create a stored procedure with the same method I use with MSSQL. I want to create a procedure if it does not exists because I prefer that to dropping if exists. Below is the syntax I would use in MSSQL. Any help would be much appreciated.</p> <pre><code>IF NOT EXISTS ( SELECT 1 FROM sysobjects WITH (NOLOCK) WHERE [type] = 'P' AND name = 'Sproc' ) EXEC('CREATE PROCEDURE dbo.Sproc AS BEGIN SET NOCOUNT ON; END') GO ALTER PROCEDURE dbo.Sproc ( @Sproc_Params ) AS BEGIN .... --Sproc code END </code></pre>
2
Python 2.7 PyTesseract AttributeError: 'PixelAccess' object has no attribute 'split'
<pre><code>Traceback (most recent call last): File "C:\Python27\Stuff\imagetotext.py", line 9, in &lt;module&gt; i = pytesseract.image_to_string(img) File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 143, in image_to_string if len(image.split()) == 4: AttributeError: 'PixelAccess' object has no attribute 'split' </code></pre> <p>So, I'm really not sure what to do with this. <a href="https://gyazo.com/63c6439285d629c72e9076c1b4a29a42" rel="nofollow">https://gyazo.com/63c6439285d629c72e9076c1b4a29a42</a> is test.png. I've tried a lot. </p> <pre><code>try: import Image except ImportError: from PIL import Image import pytesseract img = Image.open('test.bmp').load() #img.load() i = pytesseract.image_to_string(img) print i </code></pre> <p>I've read it might be a bug with PIL, but I just have no idea.</p>
2
TeamCity nuget pack step missing files when packaged
<p>Our first step is a MsBuild for our .sln file. We pass in our platform and config and everything is built correctly.</p> <p>Next we want to NuGet pack all the files for Octopus Deploy to use. In this step we specify all of our .csproj files (not sure why, everything is already built) </p> <p>The package that is created contains 2 folders, Content which contains all the files needed minus bin and the Lib folder which contains only the projects compiled dlls. It's not including any of the other dlls referenced in the project.</p>
2
How to select ALL UICollectionView cells like in the iOS Photos app using Swift?
<p>I can't seem to get this to work for me and I haven't found any other answers to similar questions that work. </p> <p>I am working with Swift and need to know how to be able to have a "Select All" button in my app select all visible &amp; non-visible cells just like the stock Photos app on iOS.</p> <p>My app is dealing with photos too, and so each cell has two UIImageViews, one that is the photo in question, and another that is a hidden UIImageView that appears upon selection of an image (it is just a check mark).</p> <p>The code I've been using (which won't work) is this:</p> <pre><code> for cell in self.collectionView.visibleCells() as! [ImageCell]{ if cell.checkMark.hidden{ cell.checkMark.hidden = false } else{ cell.checkMark.hidden = true } } </code></pre>
2
PHP- get previous rows value
<p>I have a database that contains the following:</p> <pre><code>ID | value 1 | Hello 14 | Potato 34 | Henry </code></pre> <p>The information is echoed using the following foreach:</p> <pre><code>foreach($db-&gt;query(&quot;SELECT * FROM table&quot;) as $X){ echo $X['ID']; echo $X['value']; } </code></pre> <p>Is there a way to get the ID from the previous row in the table as a variable? So as the result looks something along the lines of this:</p> <pre><code>echo &quot;Current ID: &quot;.$X['ID']; echo &quot;Current value: &quot;.$X['value']; echo &quot;Previous value: &quot;.$PreviousValue; </code></pre> <p>gives</p> <blockquote> <p>Current ID: 14</p> <p>Current value: Potato</p> <p>Previous value: Hello</p> </blockquote>
2
in illustrator javascript to ungroup and group
<p>illustrator in .ai file i am having layer name as "Layer1" inside this layer i am having group named as " rename" this rename group i have to ungroup and move it to new group .can anybody please help me in javascript for this , i have also attached image.</p> <p><a href="http://i.stack.imgur.com/wicVR.jpg" rel="nofollow">layer 1 image</a> ,<a href="http://i.stack.imgur.com/oLufZ.jpg" rel="nofollow">rename group </a></p> <pre><code>var itemKinds = new Array("pathItems","compoundPathItems","textFrames","placedItems","rasterItems","meshItems","pluginItems","graphItems","symbolItems","groupItems"); function getChildAll(obj) { var childsArr = new Array(); for(var i=0;i&lt;obj.pageItems.length;i++)childsArr.push(obj.pageItems[i]); return childsArr; } if(app.activeDocument) { doc = app.activeDocument; if(doc.groupItems.length)for(var i=0;i&lt;doc.layers.length;i++)ungroup(doc.layers[i]); } function ungroup(obj) { var elements = getChildAll(obj); if(elements.length&lt;1){ obj.remove(); return; }else{ for(var i=0;i&lt;elements.length;i++) { try{ if(elements[i].parent.typename!="Layer 1")elements[i].moveBefore(obj); if(elements[i].typename=="rename")ungroup(elements[i]); }catch(e){ } } } } </code></pre>
2
How to pass parameter to a gen_server function?
<p>I have a <code>gen_server</code> which increments the counter each time it's <code>increment()</code> function is called.</p> <pre><code>-module(genserver). -export([start_link/0, start/0, increment/0]). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). init([]) -&gt; {ok, "counter.txt"}. start() -&gt; gen_server:start({local, ?MODULE}, ?MODULE, [], []). increment() -&gt; gen_server:call(?MODULE, increment). handle_call(increment, _From, File) -&gt; Counter = case file:read_file(File) of {ok, Binary} -&gt; binary_to_integer(Binary); {error, enoent} -&gt; 0 end, ok = file:write_file(File, integer_to_binary(Counter + 1)). handle_cast(_Req, State) -&gt; {noreply, State}. handle_info(_Info, State) -&gt; {noreply, State}. terminate(_Reason, _State) -&gt; ok. code_change(_OldVsn, State, _Extra) -&gt; {ok, State}. </code></pre> <p>Here is the shell execute example</p> <pre><code>Eshell V7.3 (abort with ^G) 1&gt; c("C:/Users/guga.melkadze/Desktop/testgen"). {ok,testgen} 2&gt; testgen:start(). {ok,&lt;0.39.0&gt;} 3&gt; testgen:increment(). 920 4&gt; testgen:increment(). 921 5&gt; testgen:increment(). 922 </code></pre> <p>Now I need to send one parameter every time I call the <code>genserver:increment()</code> method. For example <code>genserver:increment(someParameter)</code>. How do I achieve this?</p>
2
REST api for processing parallel HTTP GET requests
<p>My question might be quite basic. </p> <p>I have a Spring MVC (Spring Boot) REST api, and multiple Spark workers that send parallel <code>HTTP GET</code> requests to this REST api (e.g. 4 workers on different nodes -> 4 parallel <code>HTTP</code> requests). I want my REST api be able to process these requests in parallel.</p> <p>How can I do it? Should I use callbacks and <code>DeferredResult</code> inside my REST api? Any example would be really helpful.</p>
2
Compile Error : [dcc32 Error] E2064 Left side cannot be assigned to
<p><strong>I an new to Delphi and tried to compile Inno Setup's <code>Setup.e32</code> file using Inno Setup's Source Code with Delphi 10.1 Berlin.</strong></p> <p><em>But the problem is when I try to compile, I keeps getting Error <code>[dcc32 Error] uPSUtils.pas(944): E2064 Left side cannot be assigned to.</code></em></p> <p><em>I don't know how to resolve this and also read questions in this site which asked about that Error but even can't determine what is wrong in this code.</em></p> <p><strong><em>The Parts of the Code:</em></strong></p> <pre><code>function FastUpperCase(const s: String): string; {Fast uppercase} var I: Integer; C: Char; begin Result := S; I := Length(Result); while I &gt; 0 do begin C := Result[I]; if c in [#97..#122] then Dec (Byte(Result[I]), 32); &lt;&lt;&lt;Error E2064 HERE&gt;&gt;&gt; Dec(I); end; end; function FastLowerCase(const s: String): string; {Fast lowercase} var I: Integer; C: Char; begin Result := S; I := Length(Result); while I &gt; 0 do begin C := Result[I]; if C in [#65..#90] then Inc(Byte(Result[I]), 32); &lt;&lt;&lt;ERROR E2064 HERE&gt;&gt;&gt; Dec(I); end; end; function ParseToken(var CurrTokenPos, CurrTokenLen: Cardinal; var CurrTokenId: TPSPasToken): TPSParserErrorKind; {Parse the token} var ct, ci: Cardinal; hs: Boolean; p: PChar; begin ParseToken := iNoError; ct := CurrTokenPos; case FText[ct] of #0: begin CurrTokenId := CSTI_EOF; CurrTokenLen := 0; end; 'A'..'Z', 'a'..'z', '_': begin ci := ct + 1; while (FText[ci] in ['_', '0'..'9', 'a'..'z', 'A'..'Z']) do begin Inc(ci); end; CurrTokenLen := ci - ct; FLastUpToken := GetToken(CurrTokenPos, CurrtokenLen); p := pchar(FLastUpToken); while p^&lt;&gt;#0 do begin if p^ in [#97..#122] then Dec ((Byte(p^)), 32); &lt;&lt;&lt;ERROR E2064 HERE&gt;&gt;&gt; inc(p); end; if not CheckReserved(FLastUpToken, CurrTokenId) then begin CurrTokenId := CSTI_Identifier; end; end; </code></pre> <p>What is wrong in these codes?</p> <p>After I created <code>compilesettings.bat</code> and Clicked on <code>compile.bat</code> to Compile non Unicode Inno Setup (As now I installed Delphi 7.............) , this is what happened.</p> <p><a href="https://i.stack.imgur.com/Albhx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Albhx.jpg" alt="This is what happened after following instructions..........."></a></p>
2
Angular2 and Typescript development tools
<p>I am very new to development using Angular2 and Typescript . Can anyone suggest some of the best development tools which has autocomplete and debugging facility. I am already aware of debugging in chrome so please don't mention that.</p>
2
Bind WPF DataGrid Column Header Text in a Cell Values
<p>I'm having a DataGrid, I wish to append the Column Header Text in each value in a Cell</p> <p>The XAML Source Code is</p> <pre><code>&lt;Window x:Class="DataGrid_Index.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:cust="clr-namespace:DataGrid_Index" &gt; &lt;Grid&gt; &lt;DataGrid Name="Grid1" AutoGenerateColumns="False" ItemsSource="{Binding MobileList, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" SelectionUnit="Cell" SelectionChanged="Grid1_SelectionChanged" &gt; &lt;DataGrid.Columns&gt; &lt;!--Column 1--&gt; &lt;DataGridTextColumn Binding="{Binding MobileName}" Header="Name" /&gt; &lt;!--Column 2--&gt; &lt;DataGridTextColumn Binding="{Binding MobileOS}" Header="OS" /&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>The C# View Model is </p> <pre><code>public class MobileVM : ViewModel { private ObservableCollection&lt;Mobile&gt; _mobileList = new ObservableCollection&lt;Mobile&gt;(); public ObservableCollection&lt;Mobile&gt; MobileList { get { return _mobileList; } set { _mobileList = value; OnPropertyChanged(); } } public MobileVM() { MobileList = new ObservableCollection&lt;Mobile&gt;() { new Mobile() { MobileName = "iPhone 6", MobileOS = "IOS" }, new Mobile() { MobileName = "Galaxy S6", MobileOS = "Android" }, new Mobile() { MobileName = "Lumina", MobileOS = "Windows" } }; } } public class Mobile { public string MobileName { get; set; } public string MobileOS { get; set; } } </code></pre> <p>I'm expecting output</p> <pre><code> Name OS _________________________________________ Name: iPhone 6 OS: IOS Name: Galaxy S6 OS: Android Name: Lumina OS: Windows </code></pre> <p>How to bind the <code>Column.Header</code> in a Cell ? Kindly assist me.</p>
2
Unable to get value of the property ReactJS in IE9/10
<p>I have a react component that I am rendering into the DOM using the following code:</p> <pre><code>ReactDOM.render(React.createElement(PROJECT.CalendarApp, { key : 'globalcalendar', roomPage : false, localeRegion : PROJECT.user.locale().region, localeStartDay : PROJECT.user.locale().startDay, showCalendarOnLoad : false, name : 'globalcalendar', availabilityCalendar : false }), document.getElementById('global_calendar_component')); </code></pre> <p>I am receiving the following error in IE 9/10 and can't seem to work out why - <code>Unable to get value of the property 'localeRegion' object is null or undefined reactjs</code>.</p> <p><code>PROJECT.user.locale().region</code> is correctly defined and returns a string of <code>'en'</code>. </p> <p>This issue is only occurring in IE 9 and 10 and my webpack setup at the moment looks like this:</p> <pre><code>var webpack = require('webpack'); var path = require('path'); var BUILD_DIR = path.resolve(__dirname, '../src/Family/SystemBundle/Resources/public/js/components/compiled'); var APP_DIR = path.resolve(__dirname, '../src/Family/SystemBundle/Resources/public/js/components/'); var config = { entry: { calendar : APP_DIR + '/calendar.jsx' }, output: { path: BUILD_DIR, filename: '[name].js' }, module : { loaders : [ { test : /\.jsx?/, include : APP_DIR, loader : 'babel', query: { presets:[require.resolve('babel-preset-es2015'), require.resolve('babel-preset-react')] // Brackets - required for babel symlinking because node_modules is not in the root folder. } } ] } }; module.exports = config; </code></pre> <p>I already have Babel Polyfill loaded into the project and am quite stumped on this issue. If anyone has experienced anything similar then it would be great to know how you managed to solve it.</p>
2
Powershell Remove-Item locking file after script finishes
<p>I am creating a basic script that should access my NetApp, run two commands and output the results to a csv file, and then email that csv file to me. Finally, the file should be deleted.</p> <p>From what I have learned while reading, shouldn't powershell wait until the previous step was completed and then automatically close the file after it was sent? I can still delete the file up until the Send-MailMessage command. The very next command is to delete the file, and the error is generated. This also happens if I highlight each line in the script and run them manually, waiting several minutes between commands. The only way I have found, so far, to unlock the file is to close Powershell.</p> <p>How can I force Powershell to delete this open file? No other process is using it, I have received the email, and am no longer interested in keeping the file. I would prefer not to use a third party tool to do this</p> <p>I am getting an error when I try to delete the file.</p> <p>The delete command:</p> <pre><code>If (Test-Path $attachment){ Remove-Item $attachment -Force } </code></pre> <p>The error:</p> <pre><code>Remove-Item : Cannot remove item C:\perfstat\NcVol.csv: The process cannot access the file 'C:\perfstat\NcVol.csv' because it is being used by another process. At line:1 char:1 + Remove-Item $attachment -Force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (C:\perfstat\NcVol.csv:FileInfo) [Remove-Item], IOException + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand </code></pre> <p>Other bits:</p> <pre><code>$attachment = "c:\perfstat\NcVol.csv" # Get the stats from the NetApp Get-NcVol | Export-Csv -LiteralPath $attachment -Force -NoTypeInformation -Verbose Get-NcAggr | Export-Csv -LiteralPath $attachment -Force -NoTypeInformation -Verbose -Append #Send the message Send-MailMessage -To $emailTo -From $emailFrom -Subject $emailSubject -Body $emailBody -BodyAsHTML -Attachments $attachment -SmtpServer $emailSmtpServer #Now delete the file </code></pre>
2
Inserting into SQLite database with parameters
<p>I am building a cross-platform app using AngularJS, Monaca and OnsenUI.</p> <p>I have implemented a SQLite database to save data to be able to work offline. My implementation is based on the answer found <a href="https://stackoverflow.com/questions/26604952/a-simple-cordova-android-example-including-sqlite-read-write-and-search">HERE</a></p> <p>I have a view where the user can select any number of options and those option values should then be saved to the SQLite database. Each option value can be saved to the same database table or separate tables - depending on the option value selected.</p> <p>With this I am trying to refactor my insert statement to make it more efficient as it may be called many times. In my <strong><em>app.js</em></strong> controller I have a function that checks which option value was selected in the view, and then calls the <em>goInsert()</em> function that inserts the selected option value into the SQLite Database. Below is a sample of my function.</p> <pre><code>$scope.selectedIDOne = ""; // Variable to hold selected options value $scope.changedValue = function (item, identifier) // item = selected option value; identifier = identifies table name to insert into { switch (identifier) { case "Square": $scope.selectedIDOne = item; db.transaction(goInsert(identifier), errorCB, successCB); // Error on refactored goInsert(identifier) function trying to pass identifier break; default: // TODO } } </code></pre> <p>Then I try the following in my goInsert() function.</p> <pre><code>function goInsert(identifier) // Error here { switch (identifier) { case "Square": db.transaction(insertSquareDB, errorCB, successCB); break; } } function insertSquareDB(tx) { tx.executeSql('INSERT OR IGNORE INTO tb_square (square_id) VALUES ("' + $scope.selectedIDOne + '" )'); } </code></pre> <p>When I run the code I get an error where indicated but the value is nonetheless inserted int the database. The error is thrown at the goInsert(identifier) function call. The error is: </p> <p>TypeError: Failed to execute 'Transaction' on 'Database'. The callback provided as parameter 1 is not a function.</p> <p>How can I implement this solution please? Or is there a better way? I would also ideally not like to create multiple <em>insertSquareDB(tx)</em> functions e.g. insertCircleDB(tx), insertROundDB(tx) etc. Is there a way I can have 1 function defined that inserts values dynamically e.g. (hypothetical)</p> <pre><code>function insertSquareDB(tx, tableName, columnName, optionValues) { tx.executeSql('INSERT OR IGNORE INTO tableName (columnName) VALUES ("' + optionValues + '" )'); } </code></pre>
2
Lower-bounded wild card causes trouble in javac, but not Eclipse
<p>This piece of code compiles in Eclipse but not in javac:</p> <pre class="lang-java prettyprint-override"><code>import java.util.function.Consumer; public class Test { public static final void m1(Consumer&lt;?&gt; c) { m2(c); } private static final &lt;T&gt; void m2(Consumer&lt;? super T&gt; c) { } } </code></pre> <p>javac output:</p> <pre class="lang-none prettyprint-override"><code>C:\Users\lukas\workspace&gt;javac -version javac 1.8.0_92 C:\Users\lukas\workspace&gt;javac Test.java Test.java:5: error: method m2 in class Test cannot be applied to given types; m2(c); ^ required: Consumer&lt;? super T&gt; found: Consumer&lt;CAP#1&gt; reason: cannot infer type-variable(s) T (argument mismatch; Consumer&lt;CAP#1&gt; cannot be converted to Consumer&lt;? super T&gt;) where T is a type-variable: T extends Object declared in method &lt;T&gt;m2(Consumer&lt;? super T&gt;) where CAP#1 is a fresh type-variable: CAP#1 extends Object from capture of ? 1 error ---------------------------------------------------------------- </code></pre> <p>Which compiler is wrong and why? (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=497380">Eclipse bug report and parts of discussion here</a>)</p>
2
If Multi-Window Lifecycle affect activity lifecycle in android N?
<p>I am working on a application in which I have to provide Multi-Window Support. So I build my application with the <code>N Preview SDK</code>. But conceptually I am not clear if <code>Multi-Window Lifecycle</code> affect <code>Activity Lifecycle</code> in Android N?</p>
2
AmCharts don't plot graph when data = 0
<p><a href="https://i.stack.imgur.com/grYXp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/grYXp.png" alt="enter image description here"></a></p> <pre><code>[ { "category": "Q12012", "value1": 31845935.15, "value3": 0.00 }, { "category": "Q22012", "value1": 29674500.79, "value3": 0.00 }, { "category": "Q32012", "value1": 30935441.96, "value3": 0.00 }, { "category": "Q42012", "value1": 31748214.07, "value3": 0.00 }, { "category": "Q12013", "value1": 36601910.60, "value3": 31051022.99 }, { "category": "Q22013", "value1": 39663505.35, "value3": 32240016.86 }, { "category": "Q32013", "value1": 39822373.03, "value3": 34737268.00 }, { "category": "Q42013", "value1": 37821101.06, "value3": 36959000.76 }, { "category": "Q12014", "value1": 47430411.67, "value3": 38477222.51 }, { "category": "Q22014", "value1": 47493801.18, "value3": 41184347.78 }, { "category": "Q32014", "value1": 0.00, "value3": 43141921.74 } ] </code></pre> <p>Picture showing my graph was created using the code below. </p> <ol> <li>How can I not display if my data value = 0?</li> <li>Means that if my <code>data == 0.00</code>, I don't want it to be plotted on the graph. Where can I set them? </li> <li>How can I name both line (orange and yellow line), my x-axis and y-axis?</li> </ol> <p>thank you</p> <pre><code> &lt;!-- the chart code --&gt; &lt;script&gt; var chart; // create chart AmCharts.ready(function() { // load the data var chartData = AmCharts.loadJSON('dataMainForecasting.php'); // SERIAL CHART chart = new AmCharts.AmSerialChart(); chart.pathToImages = "http://www.amcharts.com/lib/images/"; chart.dataProvider = chartData; chart.categoryField = "category"; chart.title = 'Hello'; //chart.dataDateFormat = "YYYY-MM-DD"; // GRAPHS var graph1 = new AmCharts.AmGraph(); graph1.valueField = "value1"; graph1.bullet = "round"; graph1.bulletBorderColor = "#FFFFFF"; graph1.bulletBorderThickness = 2; graph1.lineThickness = 2; graph1.lineAlpha = 0.5; chart.addGraph(graph1); var graph2 = new AmCharts.AmGraph(); graph2.valueField = "value2"; graph2.bullet = "round"; graph2.bulletBorderColor = "#FFFFFF"; graph2.bulletBorderThickness = 2; graph2.lineThickness = 2; graph2.lineAlpha = 0.5; chart.addGraph(graph2); // CATEGORY AXIS chart.categoryAxis.parseString = true; // WRITE chart.write("Quarter2"); }); json = json.filter(function(val) { return val !== 0; }); &lt;/script&gt; </code></pre> <p>and this is all my data being extracted from</p> <pre><code> mysql_select_db("test",$connect); // Fetch the data $query = " SELECT * FROM `table 5` "; $result = mysql_query( $query ); // All good? if ( !$result ) { // Nope $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die( $message ); } // Print out rows // Print out rows $prefix = ''; echo "[\n"; while ( $row = mysql_fetch_assoc( $result ) ) { echo $prefix . " {\n"; echo ' "category": "' . $row['category'] . '",' . "\n"; echo ' "value1": ' . $row['value1'] . ',' . "\n"; echo ' "value2": ' . $row['value2'] . '' . "\n"; echo " }"; $prefix = ",\n"; } echo "\n]"; // Close the connection //mysql_close($link); ?&gt; </code></pre>
2
Updates in my React application aren't taken into account Webpack dev server
<p>I'm trying to set up an environment for my React application using Webpack and Babel. I use JSX to implement components and I would like to leverage live reload.</p> <p>Here is my <code>package.json</code> file:</p> <pre><code>{ (...) "scripts": { "start": "webpack-dev-server --hot --inline" }, "dependencies": { "babel-loader": "^6.2.4", "babel-preset-es2015": "^6.9.0", "babel-preset-react": "^6.11.1", "jsx-loader": "^0.13.2", "react": "^15.1.0", "react-dom": "^15.1.0", "react-hot-loader": "^1.3.0", "webpack": "^1.13.1", "webpack-dev-server": "^1.14.1" } } </code></pre> <p>Here is my Webpack configuration:</p> <pre><code>var webpack = require('webpack'); var path = require('path'); var BUILD_DIR = path.resolve(__dirname, 'src/client/public'); var APP_DIR = path.resolve(__dirname, 'src/client/app'); var config = { entry: [ 'webpack-dev-server/client?http://0.0.0.0:8080', 'webpack/hot/only-dev-server', APP_DIR + '/index.jsx' ], output: { path: BUILD_DIR, filename: 'bundle.js' }, module : { loaders : [ { test : /\.jsx?/, include : APP_DIR, loaders: ['react-hot', 'babel'] } ] }, plugins: [ new webpack.HotModuleReplacementPlugin() ] }; module.exports = config; </code></pre> <p>After having executed <code>npm run start</code> and with this configuration, I see in my console that updates in a JSX file are detected but the browser isn't updated. Moreover, if I have a look at the <code>module.js</code> file, my updates aren't taken into account.</p> <p>Running the command <code>webpack -d</code>, they are...</p> <p>See this repo: <a href="https://github.com/templth/react-webpack-hot-reload" rel="nofollow">https://github.com/templth/react-webpack-hot-reload</a>.</p> <p>Additional hints. I see the following traces in the JavaScript console of the browser:</p> <pre><code>[HMR] Waiting for update signal from WDS... Download the React DevTools for a better development experience: https://(...)/react-devtools XHR finished loading: GET "http://localhost:8080/sockjs-node/info?t=1467375470671".AbstractXHRObject._start @ abstract-xhr.js:132(anonymous function) (...) [WDS] Hot Module Replacement enabled. [WDS] App updated. Recompiling... [WDS] App hot update... [HMR] Checking for updates on the server... GET http://localhost:8080/src/client/0cf06dae430007853b6f.hot-update.json 404 (Not Found)hotDownloadManifest @ bootstrap (...) [HMR] Cannot find update. Need to do a full reload! </code></pre> <p>only-dev-server.js:28 [HMR] (Probably because of restarting the webpack-dev-server)</p> <p>and in the console that started the webpack dev server</p> <pre><code>Hash: 85771179bfa8706bc10f Version: webpack 1.13.1 Time: 275ms Asset Size Chunks Chunk Names bundle.js 991 kB 0 [emitted] main 0.8073da5d40a8dd413f96.hot-update.js 3.6 kB 0, 0 [emitted] main, main 8073da5d40a8dd413f96.hot-update.json 36 bytes [emitted] chunk {0} bundle.js, 0.8073da5d40a8dd413f96.hot-update.js, 0.8073da5d40a8dd413f96.hot-update.js (main) 897 kB [rendered] [76] ./src/client/app/index.jsx 3.58 kB {0} [built] + 255 hidden modules webpack: bundle is now VALID. </code></pre> <p>Thanks very much for your help!</p>
2
Is it possible to do static code analysis for python using SonarQube?
<p>I need to check for errors in my python files before building the project. Is this possible using SonarQube? If Yes, what checks are performed for Python(syntax, indentation, import errors, etc)?</p>
2
Is there a way to programmatically add some default message to git commit?
<p>I am trying to auto generate my commit message title fetching directly from Phrabricator or Jira.</p> <p>I have a bash script that does a http call and get the title. </p> <p>I know you can have a commit template for each commit message.</p> <p>eg.</p> <p><code>~/.gitconfig</code></p> <pre><code>[commit] template = ~/.gitmessage </code></pre> <p><code>~/.gitmessage</code></p> <pre><code>Some template for user </code></pre> <p>But is it possible to dynamically generate commit template using bash or python scripts?</p>
2
Capybara with Selenium: Can't click on hidden element
<p>I have a situation in my view where a clickable icon is only visible when it's containing div is hovered over (using Knockout JS, SCSS) . Something like this:</p> <h1>HTML</h1> <pre><code>&lt;div id=&quot;button_div&quot;&gt; &lt;i id=&quot;icon&quot; data-bind=&quot;click: dosomething&quot;&gt;&lt;/i&gt; &lt;/div&gt; </code></pre> <h1>SCSS</h1> <pre><code>i { display: none; } #button_div:hover { i { display: block; } } </code></pre> <p>Everything works fine on the page, but I can't seem to figure out how to click the element in Capybara. I've tried adding the :visible symbol to the method, but with no luck:</p> <pre><code>find('#icon', visible: false).click </code></pre> <p>This gives me the a &quot;Selenium::WebDriver::Error::ElementNotVisibleError&quot; error.</p> <p>Using:</p> <pre><code>Capybara.ignore_hidden_elements = false </code></pre> <p>Gives me the exact same error</p> <p>I've also tried using a Selenium Action such as:</p> <pre><code>button_div_element = find('#button_div').native button_element = find('#button', visible: false).native page.driver.browser.action.move_to(button_div_element).click(button_element).perform </code></pre> <p>While this doesn't throw an error, it also doesn't click the button.</p> <p>Does anyone have any idea what I might be doing wrong?</p>
2