Daily Archives

Articles indexed Friday November 9 2012

Page 14/19 | < Previous Page | 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Why is the C# SerializedAttribute is sealed?

    - by ahmet alp balkan
    I was trying to create an attribute that implies [Serializable] but I noticed that this SerializableAttribute class is sealed. In Java it was possible to create an interface (say, MyInterface) that is inherited from Serializable interface and so all the subclasses of MyInterface would also be serializable, even its sub-sub classes would be so. Let's say I am creating an ORM and I want customers to annotate their entity classes as [DatabaseEntity] but in order to make sure that entities are serializable, I also need to ask them to attribute their classes with extra [Serializable] which does not look quite compact and neat. I am wondering why SerializableAttribute class is sealed and why has Inherited=false which implies that subclasses of serializable class will not be serializable unless it is explicitly stated. What motives are behind these design choices?

    Read the article

  • Perl kill(0, $pid) in Windows always returning 1

    - by banshee_walk_sly
    I'm trying to make a Perl script that will run a set of other programs in Windows. I need to be able to capture the stdout, stderr, and exit code of the process, and I need to be able to see if a process exceeds it's allotted execution time. Right now, the pertinent part of my code looks like: ... $pid = open3($wtr, $stdout, $stderr, $command); if($time < 0){ waitpid($pid, 0); $return = $? >> 8; $death_sig = $? & 127; $core_dump = $? & 128; } else{ # Do timeout stuff, currently not working as planned print "pid: $pid\n"; my $elapsed = 0; #THIS LOOP ONLY TERMINATES WHEN $time > $elapsed ...? while(kill 0, $pid and $time > $elapsed){ Time::HiRes::usleep(1000); # sleep for milliseconds $elapsed += 1; $return = $? >> 8; $death_sig = $? & 127; $core_dump = $? & 128; } if($elapsed >= $time){ $status = "FAIL"; print $log "TIME LIMIT EXCEEDED\n"; } } #these lines are needed to grab the stdout and stderr in arrays so # I may reuse them in multiple logs if(fileno $stdout){ @stdout = <$stdout>; } if(fileno $stderr){ @stderr = <$stderr>; } ... Everything is working correctly if $time = -1 (no timeout is needed), but the system thinks that kill 0, $pid is always 1. This makes my loop run for the entirety of the time allowed. Some extra details just for clarity: This is being run on Windows. I know my process does terminate because I have get all the expected output. Perl version: This is perl, v5.10.1 built for MSWin32-x86-multi-thread (with 2 registered patches, see perl -V for more detail) Copyright 1987-2009, Larry Wall Binary build 1007 [291969] provided by ActiveState http://www.ActiveState.com Built Jan 26 2010 23:15:11 I appreciate your help :D For that future person who may have a similar issue I got the code to work, here is the modified code sections: $pid = open3($wtr, $stdout, $stderr, $command); close($wtr); if($time < 0){ waitpid($pid, 0); } else{ print "pid: $pid\n"; my $elapsed = 0; while(waitpid($pid, WNOHANG) <= 0 and $time > $elapsed){ Time::HiRes::usleep(1000); # sleep for milliseconds $elapsed += 1; } if($elapsed >= $time){ $status = "FAIL"; print $log "TIME LIMIT EXCEEDED\n"; } } $return = $? >> 8; $death_sig = $? & 127; $core_dump = $? & 128; if(fileno $stdout){ @stdout = <$stdout>; } if(fileno $stderr){ @stderr = <$stderr>; } close($stdout); close($stderr);

    Read the article

  • Quickest way to compute the number of shared elements between two vectors

    - by shn
    Suppose I have two vectors of the same size vector< pair<float, NodeDataID> > v1, v2; I want to compute how many elements from both v1 and v2 have the same NodeDataID. For example if v1 = {<3.7, 22>, <2.22, 64>, <1.9, 29>, <0.8, 7>}, and v2 = {<1.66, 7>, <0.03, 9>, <5.65, 64>, <4.9, 11>}, then I want to return 2 because there are two elements from v1 and v2 that share the same NodeDataIDs: 7 and 64. What is the quickest way to do that in C++ ? Just for information, note that the type NodeDataIDs is defined as I use boost as: typedef adjacency_list<setS, setS, undirectedS, NodeData, EdgeData> myGraph; typedef myGraph::vertex_descriptor NodeDataID; But it is not important since we can compare two NodeDataID using the operator == (that is, possible to do v1[i].second == v2[j].second)

    Read the article

  • Better code for accessing fields in a matlab structure array?

    - by John
    I have a matlab structure array Modles1 of size (1x180) that has fields a, b, c, ..., z. I want to understand how many distinct values there are in each of the fields. i.e. max(grp2idx([foo(:).a])) The above works if the field a is a double. {foo(:).a} needs to be used in the case where the field a is a string/char. Here's my current code for doing this. I hate having to use the eval, and what is essentially a switch statement. Is there a better way? names = fieldnames(Models1); for ix = 1 : numel(names) className = eval(['class(Models1(1).',names{ix},')']); if strcmp('double', className) || strcmp('logical',className) eval([' values = [Models1(:).',names{ix},'];']); elseif strcmp('char', className) eval([' values = {Models1(:).',names{ix},'};']); else disp(['Unrecognized class: ', className]); end % this line requires the statistics toolbox. [g, gn, gl] = grp2idx(values); fprintf('%30s : %4d\n',names{ix},max(g)); end

    Read the article

  • Jquery Knob animate and change color

    - by user1468116
    I'd like to create a knob that switch color at some point. For example, at 35 is red, at 70 is yellow and 100 is green. I also would like to make it animate. this is my fiddle: http://jsfiddle.net/Tropicalista/jUELj/6/ My code is: enter code here $(document).ready(function() { $('.dial').val(13).trigger('change').delay(2000); $(".dial").knob({ 'min':0, 'max':100, 'readOnly': true, 'width': 120, 'height': 120, 'fgColor': '#b9e672', 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin':'tron' }) });

    Read the article

  • Setup for games animation: How do I know JFrame is finished setting itself up?

    - by Jokkel
    I'm using javax.swing.JFrame to draw game animations using double buffer strategy. First, I set up the frame. JFrame frame = new JFrame(); frame.setVisible(true); Now, I draw an object (let it be a circle, doesn't matter) like this. frame.createBufferStrategy(2); bufferStrategy = frame.getBufferStrategy(); Graphics g = bufferStrategy.getDrawGraphics(); circle.draw(g); bufferStrategy.show(); The problem is that the frame is not always fully set-up when the drawing takes place. Seems like JFrame needs up to three steps in resizing itself, until it reaches it's final size. That makes the drawing slide out of frame or hinders it to appear completely from time to time. I already managed to delay things using SwingUtilities.invokeLater(). While this improved the result, there are still times when the drawing slides away / looks prematurely draw. Any idea / strategy? Thanks in advance. EDIT: Ok thanks so far. I didn't mention that I write a little Pong game in the first place. Sorry for the confusion What I actually looked for was the right setup for accelerated game animations done in Java. While reading through the suggestions I found my question answered (though indirectly) here and this example made things clear for me. A resume for this might be that for animating game graphics in Java, the first step is to get rid of the GUI logic overhead.

    Read the article

  • two scp and ssh processes with single authentication

    - by Tomek Wyderka
    I need to scp and then ssh to the same host. Is it possible to authenticate just one time? Is it possible to input password once, then scp file, then ssh on that host and work interactively? Update I get HOSTNAME and SSH_PASSWORD. I never log in on that machine before. I need to send some files (probably using scp) and then log in using ssh and work on that HOST interactively. I want to save time and input password just once. I have lots of such hosts...

    Read the article

  • java serialization problems with different JVMs

    - by Alberto
    I am having trouble using serialization in Java. I've searched the web for a solution but haven't found an answer yet. The problem is this - I have a Java library (I have the code and I export it to an archive prior to executing the code) which I need to use with two differents JVMs. One JVM is on the server (Ubuntu, running Java(TM) JRE SE Runtime Environment (build 1.7.0_09-b05)) and the other on Android 2.3.3. I compiled the library in Java 1.6. Now, I am trying to import to the client, an object exported from the server, but I receive this error: java.io.InvalidClassException: [Lweka.classifiers.functions.MultilayerPerceptron$NeuralEnd;; Incompatible class (SUID): [Lweka.classifiers.functions.MultilayerPerceptron$NeuralEnd;: static final long serialVersionUID =-359311387972759020L; but expected [Lweka.classifiers.functions.MultilayerPerceptron$NeuralEnd;: static final long serialVersionUID =1920571045915494592L; I do have an explicit serial version UID declared on the class MultilayerPerceptron$NeuralEnd, like this: protected class NeuralEnd extends NeuralConnection { private static final long serialVersionUID = 7305185603191183338L; } Where NeuralConnection implements the java.io.Serializable interface. If I do a serialver on MultilayerPerceptron$NeuralEnd I receive the serialVersionUID which I declared. So, why have both JVMs changed this value? Can you help me? Thanks, Alberto

    Read the article

  • Storing tree data in Javascript

    - by Ozh
    I need to store data to represent this: Water + Fire = Steam Water + Earth = Mud Mud + Fire = Rock The goal is the following: I have draggable HTML divs, and when <div id="Fire"> and <div id="Mud"> overlap, I add <div id="Rock"> to the screen. Ever played Alchemy on iPhone or Android? Same stuff Right now, the way I'm doing this is a JS object : var stuff = { 'Steam' : { needs: [ 'Water', 'Fire'] }, 'Mud' : { needs: [ 'Water', 'Earth'] }, 'Rock' : { needs: [ 'Mud', 'Fire'] }, // etc... }; and every time a div overlaps with another one, I traverse the object keys and check the 'needs' array. I can deal with that structure but I was wondering if I could do any better? Edit: I should add that I also need to store a few other things, like a short description or an icon name. So typicall I have Steam: { needs: [ array ], desc: "short desc", icon:"steam.png"},

    Read the article

  • Cannot read configuration file due to insufficient permissions

    - by mike
    Okay, I realize there are many questions relating to this error, I have read several questions and answers without resolving my problem. I have a MVC site that I'm trying to debug on local IIS web server. I check the option to use local IIS in the project properties and I've created a virtual directory in IIS. The error I get in Visual Studio is: Unable to start debugging on web server. In IIS i try browse the site but get the error: Cannot read configuration file due to insufficient permissions Config File \?\C:\Users\Mike\Documents\Visual Studio 2010\Projects\MvcApplication1\MvcApplication1\web.config I've set permissions for the pool identity on the web.config and whole project folder. I've tried localsystem identity, no luck! Please help me resolve this. I've spent several hours trying to fix this.

    Read the article

  • More elegant way to parse inline variables in strings

    - by Tom
    Currently I have this: function parse_string($string, $variables){ extract($variables); return eval('return "'. addcslashes($string, '"') .'";'); } So I can input this string: 'Hi {$name}, my name is {$own_name}' Together with this array: array('name' => 'John', 'own_name' => 'Tom') And get this back: 'Hi John, my name is Tom'   I've never liked this eval() approach but it works and it's fast (faster than regex at least). Question: Is there a more elegant way to do this (faster than using regex) in PHP5?

    Read the article

  • In the JSON spec, what does "Since the first two characters of a JSON text will always be ASCII characters" mean?

    - by dan gibson
    The spec is http://www.ietf.org/rfc/rfc4627.txt?number=4627 It contains this: Encoding JSON text SHALL be encoded in Unicode. The default encoding is UTF-8. Since the first two characters of a JSON text will always be ASCII characters [RFC0020], it is possible to determine whether an octet stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the pattern of nulls in the first four octets. What does it mean "Since the first two characters of a JSON text will always be ASCII characters [RFC0020]"? I've looked at RFC0020 but couldn't find anything about it. JSON could be {" or { " (ie whitespace before the quote.

    Read the article

  • Facebook API - Get comments

    - by Simon R
    Our business has a Facebook Fan Page. The fan page doesn't seem to generate any emails to us when updates are made to the page, whether someone adds a new status or someone comments on one of the statuses etc. Currently, we are running a very crude script to grab the content of the page and then use regular expressions to get the information we require. Obviously this is not fool proof and I'm looking into alternatives to this method. I've been looking at the facebook API and wonder if the rest server might be an option. I cannot, however, seem to find out how to return information of fan page statuses and their comments. Is anyone able to direct me how to use the API to retrieve this information. I am an admin of the fan page. The programming language I'm using is PHP. Many thanks.

    Read the article

  • Using JSON Data to Populate a Google Map with Database Objects

    - by MikeH
    I'm revising this question after reading the resources mentioned in the original answers and working through implementing it. I'm using the google maps api to integrate a map into my Rails site. I have a markets model with the following columns: ID, name, address, lat, lng. On my markets/index view, I want to populate a map with all the markets in my markets table. I'm trying to output @markets as json data, and that's where I'm running into problems. I have the basic map displaying, but right now it's just a blank map. I'm following the tutorials very closely, but I can't get the markers to generate dynamically from the json. Any help is much appreciated! Here's my setup: Markets Controller: def index @markets = Market.filter_city(params[:filter]) respond_to do |format| format.html # index.html.erb format.json { render :json => @market} format.xml { render :xml => @market } end end Markets/index view: <head> <script type="text/javascript" src="http://www.google.com/jsapi?key=GOOGLE KEY REDACTED, BUT IT'S THERE" > </script> <script type="text/javascript"> var markets = <%= @markets.to_json %>; </script> <script type="text/javascript" charset="utf-8"> google.load("maps", "2.x"); google.load("jquery", "1.3.2"); </script> </head> <body> <div id="map" style="width:400px; height:300px;"></div> </body> Public/javascripts/application.js: function initialize() { if (GBrowserIsCompatible() && typeof markets != 'undefined') { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(40.7371, -73.9903), 13); map.addControl(new GLargeMapControl()); function createMarker(latlng, market) { var marker = new GMarker(latlng); var html="<strong>"+market.name+"</strong><br />"+market.address; GEvent.addListener(marker,"click", function() { map.openInfoWindowHtml(latlng, html); }); return marker; } var bounds = new GLatLngBounds; for (var i = 0; i < markets.length; i++) { var latlng=new GLatLng(markets[i].lat,markets[i].lng) bounds.extend(latlng); map.addOverlay(createMarker(latlng, markets[i])); } } } window.onload=initialize; window.onunload=GUnload;

    Read the article

  • Crawler do not create custom crawled properties

    - by user173739
    These days i have faced with very strange problem. I have development environment with MOSS 2007 SP 2 and WS 2008, i have search configured and everything works great. I have started to configuring staging environment (MOSS 2007 SP2 with June CU) and create new farm and new SSP. I have deployed my changes with package (wsp) and manually create site collections, sub webs, pages and so on. When fill crawl finishes, i see in Crawl log that all my pages have been successfully crawled and when i use some test tools to query search, my pages have been found. In crawl log there is few errors like http://mysite/sites/de/pages "The crawler could not communicate with the server. Check that the server is available and that the firewall access is configured correctly..", but all pages in this Page library were indexed. The problem is that i use custom managed properties (mapped to custom crawled properties) in search queries, but crawler didn't create crawled properties for all my new site columns. For example for site column IsAccent the crawler didn't create cralwed property ows_isAccesnt. I'm sure that i have created pages for specific content type and all my crawl categories have checked "Automatically discover new properties when a crawl takes place ". In site settings - Searchable columns i haven't got any column selected as Nocrowl. I tried to export my managed and crawled properties from dev environment to stage evironment but all my managed properties were empty, after that i recreated SSP...the result was the same... I checked specific page with tools like Sharepoint Manager 2007 and U2U Caml Query Builder 2007 that content type is correct, and i can see values of my custom site collumns.... Using U2U Caml Query Builder 2007 agains some Page library in Result tab i can see ows_IsAccent (my site collumn is IsAccent) and others site columns, but i can't find them in Crawled properties. Any idias?

    Read the article

  • Google+ Platform Office Hours: A Movember of Metro-style Apps!

    Google+ Platform Office Hours: A Movember of Metro-style Apps! This week join Google+ Developer Relations team members Joanna Smith, Jonathan Beri, Silvano Luciani, and Gus Class for a special Movember GDL. We'll share updates for Google+, demonstrate Google+ Metro style apps integration in C#, and answer any questions you ask in the event and live YouTube comments. From: GoogleDevelopers Views: 0 0 ratings Time: 30:00 More in Science & Technology

    Read the article

  • Apps Script Office Hours - November 9, 2012

    Apps Script Office Hours - November 9, 2012 In this episode Ikai and Eric ... - Plugged the upcoming hackathon in Los Angeles. - Covered the release notes from the past week, which included some great enchancements to the Gmail and Drive services. - Discussed the new Google Cloud SQL integration in Apps Script. - Hyped the upcoming special episode with the creator of the "Google Analytics Report Automation (Magic)" script. - Answered questions about integrating Apps Script with Google Docs and Forms. The schedule of future episodes can be found at: developers.google.com From: GoogleDevelopers Views: 61 2 ratings Time: 31:24 More in Science & Technology

    Read the article

  • GDL Italy 20121107 - Unconvential webapp con GWT/Elemental, WebRCT e WebGL

    GDL Italy 20121107 - Unconvential webapp con GWT/Elemental, WebRCT e WebGL In questo video Alberto Mancini del GDG Firenze ci spiega come realizzare applicazioni web con GWT ed Elemental, capaci di acquisire il flusso video di una webcam sfruttando le nuove API WebRTC ed in grado di aggiungere effetti 3D grazie a WebGL. From: GoogleDevelopers Views: 39 3 ratings Time: 23:01 More in Science & Technology

    Read the article

  • Google Chrome Loses ASP.NET Sessions - Need FavIcon

    - by nannette
    I had programmed a brilliant web page in ASP.NET 4.0 and lo and behold, this one page lost its sessions in Google Chrome. I could run it locally in debug and could not reproduce the issues in Chrome. Didn't happen in IE or Firefox, only Chrome on the published server. I finally found in a forum where someone mentioned that Google Chrome looks for favicons and if it doesn't find one it will throw a 302 redirect and kill the session. http://stackoverflow.com/questions/8247842/session-data-lost-in-chrome...(read more)

    Read the article

  • How to exclude copy local referenced assemblies from a VSIX

    - by Daniel Cazzulino
    When you add library references to project that are not reference assemblies or installed in the GAC, Visual Studio defaults to setting Copy Local to True: If, however, those dependencies are distributed by some other means (i.e. another extension, or are part of VS private assemblies, or whatever) and you want to avoid including them in your VSIX, you can add the following property to the project file: &lt;PropertyGroup&gt; ... &lt;IncludeCopyLocalReferencesInVSIXContainer&gt;false&lt;/IncludeCopyLocalReferencesInVSIXContainer&gt;Read full article

    Read the article

  • Connect Team Foundation Service/TFS 2012 with Visual Studio 2010 &amp; Visual Studio 2008

    - by Vishal
    Hello, Microsoft finally released the Team Foundation Service in late October 2012 after its long time in the preview phase. I was already using the TFS Preview which was free but I was happy to see Microsoft releasing the Team Foundation Service also FREE for upto 5 users. Isn't that great news? I know there are bunch of other free source control repositories (Github, Bitbucket, SVN etc.) out there but I somehow like TFS better. Also the other good thing about the final release was that I didn’t had to do any kind of migration of my code from preview to final release version. Just changed the TFS connection URL and it worked like a charm. Anyways, if you are a startup with small team and need some awesome Source Control along with all the good Project Management, Continuous Integration (Build, Test, Deploy), Team Collaboration, Agile/Scrum planning etc. features than Team Foundation Service is your answer. Microsoft has not yet released their pricing for more than 5 users and will be releasing it sometime in early 2013. What if as of now you have a team more than 5 users and you want to use Team Foundation Service, the good news is you can use it for FREE but when they release the final pricing, you will have to transition to the paid plan. Lot of story, getting to the point, connecting to Team Foundation Service with Visual Studio 2012 is straight forward and would work out of the box but it wont for previous versions of Visual Studio. You will have to upgrade to the latest service pack first and than install the forward compatibility pack. (1st : Service Packs & 2nd: Forward Compatibility packs) For Visual Studio 2010: Visual Studio 2010 Service Pack 1. Visual Studio 2010 forward compatibility for TFS 2012 and Team Foundation Service.         For Visual Studio 2008: Visual Studio 2008 Service Pack 1. Visual Studio 2008 forward compatibility for TFS 2012 & Team Foundation Service. Restart your system. Visual Studio 2008 will not work if you only put https://xxx.visualstudio.com. You will have to put your collection name too as shown below.       By the way, it doesn’t matter if you are an Apple Application Developer or Android App Developer, you can still use Team Foundation Service as your source control. Below are few links to connect to Team Foundation Service with other IDEs: Connect Eclipse to Team Foundation Service. Connect XCode to Team Foundation Service. Happy coding. Vishal Mody

    Read the article

  • Alias one set of Subdomains to another

    - by Schneems
    I have to domains that I want to effectively mirror one another on select subdomains. Let's say they are pirates.com and ninjas.com and i want ninjas to mirror the content on pirates. When I visit foo.ninjas.com I want to see the content on foo.pirates.com. Due to app restrictions I need to do this in DNS for an undefined number of subdomains. I was under the impression i could do this with a CNAME, but it appears that setting a CNAME for * subdomain of the ninjas.com domain to point to pirates.com will make any subdomain of ninjas.com point at pirates.com instead of the associated subdomain. I.e. foo.ninjas.com would reference pirates.com instead of foo.pirates.com. Is there a way to do this using DNS? Am I missing something basic?

    Read the article

  • Windows Server 2008 R2 Upgrade via Remote Desktop

    - by Marko
    Is it possible to do an in-place upgrade of Windows Server 2008 R2 to Windows Server 2012 using only Remote Desktop? My plan is to extract WS 2012 installation iso file to C:\WS2012 and run the setup. After restart Remote Desktop connection will be lost, but will it be restored later? Is setup going to automatically install everything, restart, run WS 2012 and start listening for RDP connections? Server is rented and I would like to save the KVM fee. I read here that it's possible to upgrade WS 2008 to WS 2008 R2 like that. Thanks!

    Read the article

  • Path erased in Debian

    - by Lyon83
    I'm trying to deploy a rails app in Debian, using Apache/Passenger. I was trying to fox a problem with some GEMs and in the process I put executed this in console: export PATH=/var/lib/gems/1.8/bin/:${vendor/cache} Now my path environmental variable is gone, or at least its content. My server is running under Debian 6. Is there a way to recover my path info? Or at least can someone point me where to find the file where that variable i s stored? Some help please. This is a BIG problem for me. Thanks in advance!

    Read the article

  • Transferring Postfix install to new computer

    - by mlissner
    I have postfix installed on one computer, with DKIM and SPF working properly. What I'd like to do is start using a different computer instead, with the minimal amount of fuss. Mail servers have a way of baffling me, but I know there are things with cryptography going on here that I don't fully understand (and I don't really care to - I figured it out when I set up the last computer about a year ago, and am happy not to delve into it again). Right now, I'm working on the early steps of this process -- installing postfix on the new machine, and getting it going. Are there specific steps I could take to move the correct configs and key files and such to the new computer?

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19  | Next Page >