Search Results

Search found 3180 results on 128 pages for 'david sauter'.

Page 95/128 | < Previous Page | 91 92 93 94 95 96 97 98 99 100 101 102  | Next Page >

  • WPF: Convert memory stream to BitmapImage?

    - by David Veeneman
    I have an image that was originally a PNG that I have converted to a byte[] and saved in a database. Originally, I simply read the PNG into a memory stream and converted the stream into a byte[]. Now I want to read the byte[] back and convert it to a BitmapImage, so that I can bind a WPF Image control to it. I am seeing a lot of contradictory and confusing code online to accomplish the task of converting a byte[] to a BitmapImage. I am not sure whether I need to add any code due to the fact that the image was originally a PNG. Can anyone provide the code to convert the stream to a BitmapImage? Thanks for your help.

    Read the article

  • How do i know if this is random enough?

    - by David
    I wrote a program in java that rolls a die and records the total number of times each value 1-6 is rolled. I rolled 6 Million times. Here's the distribution: #of 0's: 0 #of 1's: 1000068 #of 2's: 999375 #of 3's: 999525 #of 4's: 1001486 #of 5's: 1000059 #of 6's: 999487 (0 wasn't an option.) Is this distribution consistant with random dice rolls? What objective statistical tests might confirm that the dice rolls are indeed random enough?

    Read the article

  • Visual Studio 2012 won't start

    - by David Aleu
    I installed VS2012 Premium from our MSDN subscription and it was working fine the first couple of days but then I installed a few extensions I can't now start VS2012 and it gives the error: Faulting application name: devenv.exe, version: 11.0.50727.1, time stamp: 0x5011ecaa Faulting module name: ntdll.dll, version: 6.1.7601.17725, time stamp: 0x4ec49b8f Exception code: 0xc0000374 Fault offset: 0x000ce6c3 Faulting process id: 0xee8 Faulting application start time: 0x01cd89bb777fc1dd Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe Faulting module path: C:\Windows\SysWOW64\ntdll.dll I'm running it on Windows 7 64 bit. I've tried to repair, uninstall and install again and nothing. I tried to restore to a previous restore system point but nothing. The extensions I installed I can remember: VS10x Code Map VSCommands Visual SVN Nuget manager (all the above my colleagues have it too and it works fine for them) and: Web Essentials Visual Studio Color Theme Editor SlowCheetah Mobile Ready HTML5 Questions are: Anyone else has had this problem? Is there a way I can uninstall extensions from a command line or software? (I removed the extensions folder but that doesn't do anything) Can I repair the "C:\Windows\SysWOW64\ntdll.dll"? Is it really a problem with this dll? I haven't been able to find any similar issue in other versions and because VS2012 is new doesn't seem to be much information either.

    Read the article

  • Output something other than True or False

    - by David
    Newb to JS. Trying to determain how to to output something other than Question 1 is True and False. If I understand this correctly, the output is the expression of the flag True or False. Trying to change to say Correct and Incorrect. Also trying to express a percentage of correct instead of the for example: Your total score is 10/100 $(function(){ var jQuiz = { answers: { q1: 'd', q2: 'd', }, questionLenght: 2, checkAnswers: function() { var arr = this.answers; var ans = this.userAnswers; var resultArr = [] for (var p in ans) { var x = parseInt(p) + 1; var key = 'q' + x; var flag = false; if (ans[p] == 'q' + x + '-' + arr[key]) { flag = true; g } else { flag = false; } resultArr.push(flag); } return resultArr; }, init: function(){ $("[class=btnNext]").click(function(){ if ($('input[type=radio]:checked:visible').length == 0) { return incorrect ; } $(this).parents('.questionContainer').fadeOut(500, function(){ $(this).next().fadeIn(500); }); var el = $('#progress'); el.width(el.width() + 11 + 'px'); }); $('.btnPrev').click(function(){ $(this).parents('.questionContainer').fadeOut(500, function(){ $(this).prev().fadeIn(500) }); var el = $('#progress'); el.width(el.width() - 11 + 'px'); }) $("[class=btnShowResult]").click(function(){ var arr = $('input[type=radio]:checked'); var ans = jQuiz.userAnswers = []; for (var i = 0, ii = arr.length; i < ii; i++) { ans.push(arr[i].getAttribute('id')) } }) $('.btnShowResult').click(function(){ $('#progress').width(260); $('#progressKeeper').hide(); var results = jQuiz.checkAnswers(); var resultSet = ''; var trueCount = 0; for (var i = 0, ii = results.length; i < ii; i++){ if (results[i] == true) trueCount++; resultSet += '<div> Question ' + (i + 1) + ' is ' + results[i] + '</div>' } resultSet += '<div class="totalScore">Your total score is ' + trueCount * 4 + ' / 100</div>' $('#resultKeeper').html(resultSet).show(); }) } }; jQuiz.init(); })

    Read the article

  • Cross-Origin Resource Sharing (CORS) - am I missing something here?

    - by David Semeria
    I was reading about CORS (https://developer.mozilla.org/en/HTTP_access_control) and I think the implementation is both simple and effective. However, unless I'm missing something, I think there's a big part missing from the spec. As I understand, it's the foreign site that decides, based on the origin of the request (and optionally including credentials), whether to allow access to its resources. This is fine. But what if malicious code on the page wants to POST a user's sensitive information to a foreign site? The foreign site is obviously going to authenticate the request. Hence, again if I'm not missing something, CORS actually makes it easier to steal sensitive information. I think it would have made much more sense if the original site could also supply an immutable list of servers its page is allowed to access. So the expanded sequence would be: 1) Supply a page with list of acceptable CORS servers (abc.com, xyz.com, etc) 2) Page wants to make an XHR request to abc.com - the browser allows this because it's in the allowed list and authentication proceeds as normal 3) Page wants to make an XHR request to malicious.com - request rejected locally (ie by the browser) because the server is not in the list. I know that malicious code could still use JSONP to do its dirty work, but I would have thought that a complete implementation of CORS would imply the closing of the script tag multi-site loophole. I also checked out the official CORS spec (http://www.w3.org/TR/cors) and could not find any mention of this issue.

    Read the article

  • Convert codes to HTML with CSS style

    - by David.Chu.ca
    I normally use VIM to edit my codes and convert them to HTML by using TOhtml command. The only thing I don't like is that the converted HTML does not have css class style definitions. I am not sure if there is tool to convert codes to HTML with css, or I can use additional tool or command to convert HTML HTML with css?

    Read the article

  • Efficient way to maintain a sorted list of access counts in Python

    - by David
    Let's say I have a list of objects. (All together now: "I have a list of objects.") In the web application I'm writing, each time a request comes in, I pick out up to one of these objects according to unspecified criteria and use it to handle the request. Basically like this: def handle_request(req): for h in handlers: if h.handles(req): return h return None Assuming the order of the objects in the list is unimportant, I can cut down on unnecessary iterations by keeping the list sorted such that the most frequently used (or perhaps most recently used) objects are at the front. I know this isn't something to be concerned about - it'll make only a miniscule, undetectable difference in the app's execution time - but debugging the rest of the code is driving me crazy and I need a distraction :) so I'm asking out of curiosity: what is the most efficient way to maintain the list in sorted order, descending, by the number of times each handler is chosen? The obvious solution is to make handlers a list of (count, handler) pairs, and each time a handler is chosen, increment the count and resort the list. def handle_request(req): for h in handlers[:]: if h[1].handles(req): h[0] += 1 handlers.sort(reverse=True) return h[1] return None But since there's only ever going to be at most one element out of order, and I know which one it is, it seems like some sort of optimization should be possible. Is there something in the standard library, perhaps, that is especially well-suited to this task? Or some other data structure? (Even if it's not implemented in Python) Or should/could I be doing something completely different?

    Read the article

  • C++ online RPG game

    - by David
    So I've been learning C++ and SDL to make some basic 2d games. I want to create a game sort of like World of Warcraft but a 2D version. I want it to be online and use a database or something to start data like amount of Gold, HP, etc. I was wondering though, if I do this in SDL, would it still work online or would the user have to download SDL themselves to play? I just want a game like this but be able to play it with some friends, just for learning purposes you know. I was also looking at DirectX because everyone has that on windows pretty much. Anyways much help is appreciated, thanks!

    Read the article

  • .NET 2.0: Invoking Methods Using Reflection And Generics Causes Exception

    - by David Derringer
    Hi all, I'm new to Stack Overflow, so forgive me. I've just started transititoning over to C# and I am stuck on a problem. I am wanting to pass a generic class in and call a method from that class. So, my code looks as such: public void UpdateRecords<T>(T sender) where T : new() //where T: new() came from Resharper { Type foo = Type.GetType(sender.GetType().ToString()); object[] userParameters = new object[2]; userParameters[0] = x; userParameters[1] = y; sender = new T(); //This was to see if I could solve my exception problem MethodInfo populateRecord = foo.GetMethod("MethodInOtherClass"); populateMethod.Invoke(sender, userParameters); } Exception thrown: "Object reference not set to an instance of an object." Again, I really apologize, as I am nearly brand new to C# and this is the first time I've ever handled reflection and generics. Thank you!

    Read the article

  • How do I switch out Views in a Cocoa application?

    - by David Garcia
    So I'm beginning to learn how to use Cocoa. I think I've pretty much got it but I'm hung up on creating and switching views. I'm rewriting a game I made a little bit ago for practice. All I want is one window (preferably not resizable) and I want to be able to switch out views for different screens in the game. First, I have the main menu (Start Game, High Scores, Exit). Then I need a window for each screen (Gameplay screen, Highscore screen). What I'm getting confused with is how to design this. I looked up NSViewController thinking it manages views but it doesn't. It only manages one view by loading it really. I don't understand why I'd need to use NSViewController then. Couldn't I just have a window class that contains multiple subclasses of NSView and load them like that? I'm not sure I understand the purpose of the ViewController. Does my Window Class really need to subclass NSWindowController? I was trying to follow the example of Apple's ViewController example and it has a window controller class that's a subclass of NSWindowController. I don't see what the purpose was of subclassing that. All NSWindowController seems to add is - initWithPath:(NSString *)newPath but I fail to see the use in that either when I can just edit the plist file to open the window on start up. Apple's example also has an NSView variable and an NSViewController variable. Don't you only need one variable to store the current view? Thanks in advance guys, I'm really confused as to how this works.

    Read the article

  • How to redirect a user to a new webpage after a Javascript Alert/confrim box

    - by David Maldonado
    I have a client who wishes to have an alert/confirm box pop up when a user leaves the site, then based on what they choose, they will either stay on the page or go to a new page (would love if it would work in all browsers). I have been twiddling all day and have got this piece of code, but doesn't work too well. <script> window.onbeforeonload = function exitLeave(){var answer = confirm("You have not filled out your questionnaire yet") if (answer){ window.location = "http://www.google.com/"; } else{ alert("Cancel it !") } } </script> Any help would be greatly appreciated.

    Read the article

  • Has jQuery core development been slowing down?

    - by David Murdoch
    So, I regularly head over to jQuery's Commit History on GitHub just to read through the new code committed to jQuery core. But there hasn't been anything new committed since April 24th. I've already read through jQuery core a few times and I'm pretty familiar with it which is why I like reading the commits. I just like to see what changed, why it was changed, etc. Why has there been a slow down in jQuery commits on GitHub? Anyone else have some recommendations for where I can go to view good javascript code being developed? My motive for reading jQuery's commit history is similar to the reasons I browse through accepted answers here on stackoverflow - to learn from people smarter than me. With that said, I am interested in the answer to this questions title, but I am more interested in finding a substitute to reading the jQuery commits.

    Read the article

  • Refresh index of full text search

    - by David
    Hi, in SQL Server 2008, when setting up a full text search, it gives me an option to choose a time/day for it to re-populate the index, can I do this from code instead like C# code? if so how would I do it? Would I need to execute SQL code from C# to refresh the index? Also, say if I DONT re-populate the index and add some new records, by using the FTS query will the new records still come up? But slower? Or will they not come up at all unless i reindex?

    Read the article

  • Storing a jpa entity where only the timestamp changes results in updates rather than inserts (desire

    - by David Schlenk
    I have a JPA entity that stores a fk id, a boolean and a timestamp: @Entity public class ChannelInUse implements Serializable { @Id @GeneratedValue private Long id; @ManyToOne @JoinColumn(nullable = false) private Channel channel; private boolean inUse = false; @Temporal(TemporalType.TIMESTAMP) private Date inUseAt = new Date(); ... } I want every new instance of this entity to result in a new row in the table. For whatever reason no matter what I do it always results in the row getting updated with a new timestamp value rather than creating a new row. Even tried to just use a native query to run an insert but channel's ID wasn't populated yet so I gave up on that. I've tried using an embedded id class consisting of channel.getId and inUseAt. My equals and hashcode for are: public boolean equals(Object obj){ if(this == obj) return true; if(!(obj instanceof ChannelInUse)) return false; ChannelInUse ciu = (ChannelInUse) obj; return ( (this.inUseAt == null ? ciu.inUseAt == null : this.inUseAt.equals(ciu.inUseAt)) && (this.inUse == ciu.inUse) && (this.channel == null ? ciu.channel == null : this.channel.equals(ciu.channel)) ); } /** * hashcode generated from at, channel and inUse properties. */ public int hashCode(){ int hash = 1; hash = hash * 31 + (this.inUseAt == null ? 0 : this.inUseAt.hashCode()); hash = hash * 31 + (this.channel == null ? 0 : this.channel.hashCode()); if(inUse) hash = hash * 31 + 1; else hash = hash * 31 + 0; return hash; } } I've tried using hibernate's Entity annotation with mutable=false. I'm probably just not understanding what makes an entity unique or something. Hit the google pretty hard but can't figure this one out.

    Read the article

  • What is this: main:for(...){...} doing?

    - by David Murdoch
    I pulled up the NWmatcher source code for some light morning reading and noticed this odd bit of code I'd never seen in javascript before: main:for(/*irrelevant loop stuff*/){/*...*/} This snippet can be found in the compileGroup method on line 441 (nwmatcher-1.1.1) return new Function('c,s,d,h', 'var k,e,r,n,C,N,T,X=0,x=0;main:for(k=0,r=[];e=N=c[k];k++){' + SKIP_COMMENTS + source + '}return r;' ); Now I figured out what main: is doing on my own. If you have a loop within a loop and want to skip to the next iteration of the outer loop (without completing the inner OR the outer loop) you can execute continue main. Example: // This is obviously not the optimal way to find primes... function getPrimes(max) { var primes = [2], //seed sqrt = Math.sqrt, i = 3, j, s; outer: for (; i <= max; s = sqrt(i += 2)) { j = 3; while (j <= s) { if (i % j === 0) { // if we get here j += 2 and primes.push(i) are // not executed for the current iteration of i continue outer; } j += 2; } primes.push(i); } return primes; } What is this called? Are there any browsers that don't support it? Are there other uses for it other than continue?

    Read the article

  • How to permanently leave a CALayer rotated at its final location?

    - by David
    Hello, I am trying to rotate a CALayer to a specific angle however, once the animation is done, the layer jumps back to its original position. How would I rotate the layer properly so that it stays at its final destination? Here is the code that I am using CABasicAnimation *rotationAnimation =[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; //Rotate about z-axis [rotationAnimation setFromValue:[NSNumber numberWithFloat:fromDegree]]; [rotationAnimation setToValue:[NSNumber numberWithFloat:toDegree]]; [rotationAnimation setDuration:0.2]; [rotationAnimation setRemovedOnCompletion:YES]; [rotationAnimation setFillMode:kCAFillModeForwards]; Any suggestions? Thank you.

    Read the article

  • How do I add a fullscreen view in Cocoa touch?

    - by David
    Hello :) Inside the titleView of a UINavigationBar, there is a button. Clicking it should slide in a view from the top of the screen. Where do I have to place the view so it's displayed fullscreen and not only inside the current UIViewController's contentView? Is there a function for adding fullscreen views?

    Read the article

  • Google Charts - Adding Tooltip to Colorized Column Chart

    - by David K
    I created a column chart with google charts that has a different color assigned to each column using the following posting: Assign different color to each bar in a google chart But now I'm trying to figure out how to customize the tooltips for each column to also include the number of users in addition to the percent, so "raw_data[i][1]" I would like it to look like "70% (80 Users)" I understand that there is "data.addColumn({type:'number',role:'tooltip'});" but I'm having trouble understanding how to implement it for this use-case. function drawAccountsChart() { var data = new google.visualization.DataTable(); var raw_data = [ ['Parents', 80, 160], ['Students', 94, 128], ['Teachers', 78, 90], ['Admins', 68, 120], ['Staff', 97, 111] ]; data.addColumn('string', 'Columns'); for (var i = 0; i < raw_data.length; ++i) { data.addColumn('number', raw_data[i][0]); } data.addRows(1); for (var i = 0; i < raw_data.length; ++i) { data.setValue(0, i+1, raw_data[i][1]/raw_data[i][2]*100); } var options = { height:220, chartArea: { left:30, width: "70%", height: "70%" }, backgroundColor: { fill:"transparent" }, tooltop:{ textStyle: {fontSize: "12px",}}, vAxis: {minValue: 0} }; var formatter = new google.visualization.NumberFormat({ suffix: '%', fractionDigits: 1 }); formatter.format(data, 1); formatter.format(data, 2); formatter.format(data, 3); formatter.format(data, 4); formatter.format(data, 5); var chart = new google.visualization.ColumnChart(document.getElementById('emailAccountsChart')); chart.draw(data, options); }

    Read the article

  • PHP / javascript live chat using too much bandwidth

    - by David
    So I am learning about javascript, so I am making a live chat system with PHP and javascript. I have it so the javascript refreshes the log (each message gets logged in a file on the server), and it refreshes every second. Im using firebug to monitor the resource usage, and I see under the net tab each times its updated, and the bytes add up really fast. I know I can change it to update less, but is there a way that when a user on the other end I'm talking to, when the send a message, it gets sent to the server, then an alert gets sent to me saying that the chatlog needs to update somehow. That way it only updates when the log is updated. let me know, thanks

    Read the article

< Previous Page | 91 92 93 94 95 96 97 98 99 100 101 102  | Next Page >