Daily Archives

Articles indexed Friday April 16 2010

Page 8/120 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Does "Value Restriction" mean that there is no higher order functional programming?

    - by Sadache
    Does "Value Restriction" mean that there is no higher order functional programming? I have a problem that each time I try to do a bit of HOP I get caught by a VR error. Example: let simple (s:string)= fun rq->1 let oops= simple "" type 'a SimpleType= F of (int ->'a-> 'a) let get a = F(fun req -> id) let oops2= get "" and I would like to know whether it is a problem of a prticular implementation of VR or it is a general problem that has no solution in a mutable type-infered language that doesn't include mutation in the type system.

    Read the article

  • How to test localized winforms application?

    - by Sun
    Background: I have created sample windows application for learning to implement localization. My each form has two RESX file. One for Bulgaria and one for French(Belgium). It has default culture English(XX) To test locally currently I am programmatically changing UICulture i.e. Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-BE"); And it works fine. Problem: How can I test without forcing the UI Culture programatically? I have tried changing Control Panel Regional Options Standard and Formats to French(Belgium). That made changes to DatePickerControl and now it display the dates French. However I can still see the Button text in English, where as if I test by injecting CultureInfo programmatically it changes to french. If I am able to change the standard and formats to French do I still need to Install Multilingual User Interface Pack (MUI)?

    Read the article

  • How to get C# Enum description from value?

    - by davekaro
    I have an enum with Description attributes like this: public enum MyEnum { Name1 = 1, [Description("Here is another")] HereIsAnother = 2, [Description("Last one")] LastOne = 3 } I found this bit of code for retrieving the description based on an Enum public static string GetEnumDescription(Enum value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes( typeof(DescriptionAttribute), false); if (attributes != null && attributes.Length > 0) return attributes[0].Description; else return value.ToString(); } This allows me to write code like: var myEnumDescriptions = from MyEnum n in Enum.GetValues(typeof(MyEnum)) select new { ID = (int)n, Name = Enumerations.GetEnumDescription(n) }; What I want to do is if I know the enum value (e.g. 1) - how can I retrieve the description? In other words, how can I convert an integer into an "Enum value" to pass to my GetDescription method?

    Read the article

  • how to Use JAXWS/JAXB rename the parameter

    - by shrimpy
    I use CXF(2.2.3) to compile the Amazon Web Service WSDL (http://s3.amazonaws.com/ec2-downloads/2009-07-15.ec2.wsdl) But got error as below. Parameter: snapshotSet already exists for method describeSnapshots but of type com.amazonaws.ec2.doc._2009_07_15.DescribeSnapshotsSetType instead of com.amazonaws.ec2.doc._2009_07_15.DescribeSnapshotsSetResponseType. Use a JAXWS/JAXB binding customization to rename the parameter. The conflict was due to the data type show below: <xs:complexType name="DescribeSnapshotsType"> <xs:sequence> <xs:element name="snapshotSet" type="tns:DescribeSnapshotsSetType"/> </xs:sequence> </xs:complexType> <xs:complexType name="DescribeSnapshotsResponseType"> <xs:sequence> <xs:element name="requestId" type="xs:string"/> <xs:element name="snapshotSet" type="tns:DescribeSnapshotsSetResponseType"/> </xs:sequence> </xs:complexType> I create a binding file try to address the issue...but it didn`t do the job <jaxws:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" wsdlLocation="EC2_2009-07-15.wsdl" xmlns="http://java.sun.com/xml/ns/jaxws" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"> <enableWrapperStyle>false</enableWrapperStyle> <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://ec2.amazonaws.com/doc/2009-07-15/']"> <jxb:bindings node="xs:complexType[@name='tns:DescribeSnapshotsType']//xs:element[@name='snapshotSet']"> <jxb:property name="snapshotRequestSet"/> </jxb:bindings> <jxb:bindings node="xs:complexType[@name='DescribeSnapshotsResponseType']//xs:element[@name='snapshotSet']"> <jxb:property name="snapshotResponseSet"/> </jxb:bindings> </jaxws:bindings> </jaxws:bindings> And the command i used, was like below <wsdlOptions> <wsdlOption> <wsdl>${basedir}/src/main/resources/wsdl/EC2_2009-07-15.wsdl</wsdl> <extraargs> <extraarg>-b</extraarg> <extraarg>${basedir}/src/main/resources/wsdl/Bindings_EC2_2009-07-15.xml</extraarg> </extraargs> </wsdlOption> </wsdlOptions> What is wrong with my code???? And you can check out my project by using svn.... svn co http://shrimpysprojects.googlecode.com/svn/trunk/smartcrc/AWSAgent/

    Read the article

  • Device driver with generic communication media layer

    - by Tom
    Greetings all, I'm trying to implement driver for an embedded device with generic communication media layer. Not sure what is the best way to do it so I'm seeking an advice from more experienced stackoverflow users:). Basically we've got devices around the country communicating with our head office. Usual form of communication is over TCP/IP, but could be also using usb, RF dongle, IR, etc. The plan is to have object corresponding with each of these devices, handling the proprietary protocol on one side and requests/responses from other internal systems on the other. The thing is how create something generic in between the media and the handling objects. I had a play around with the TCP dispatcher using boost.asio but trying to create something generic seems like a nightmare :). Anybody tried to do something like that? What is the best way how to do it? Cheers, Tom

    Read the article

  • How can I use django.core.files.File

    - by Jake
    The docs for django.core.files.File imply I can do this: print File(open(path)).url but the File object has no attribute 'url' However, django.db.models.fields.files.FieldFile extends File and does have all the attributes described in the docs for File, but I can't create one without giving it a model field. All I want it something that does what the docs for django.core.files.File (link above) say it does, take a python file and give it attributes like 'url' and 'path' and 'name', can anyone help? Cheers, Jake

    Read the article

  • UIPopoverController. Is there way to use Interface Builder to layout the VC and View it Contains?

    - by dugla
    Since UIPopoverController is often a container for a non-trivial amount of view hierarchy, it would be nice to do the layout of the VC and View it contains in Interface Builder rather then programmatically. Has anyone found a good work flow for do this? For example I want to embed a UIScrollView in a UIPopoverController and I am not excited about having to do it all programmatically. Thanks in advance. Cheers, Doug

    Read the article

  • htaccess password protection error

    - by nute
    I have an HTACCESS as follows: AuthUserFile /home/nasht00/.htmydomain AuthName "EnterPassword" AuthType Basic Require valid-user When I try it, the password pop-up appears. Whatever I enter in it, I get a 500 Internal Server Error. My password file is under /home/nasht00/.htmydomain . Its owner is nasht00:www-data (nasht00 is my user, www-data is the group that apache2 belongs to). File permissions on that file is 775. What am I missing? If I try without the htaccess it works fine of course. I have Ubuntu 9.10 with apache2.

    Read the article

  • FTP server returned 500 error with ASP.NET C#

    - by ffffff
    I 'm developing FTP exe ASP.NET?C#2.0 . but I FTP server returned 500 error FtpWebRequest myReq; FtpWebResponse myRes; myReq = (FtpWebRequest)WebRequest.Create("ftp://test/aaa.txt"); myReq.Credentials = new NetworkCredential("xxxx", "xxxx"); myReq.Method = WebRequestMethods.Ftp.DownloadFile; myRes = (FtpWebResponse)myReq.GetResponse(); // here error occured What's wrong?

    Read the article

  • How Can I create different selectors for accepting new connection in java NIO

    - by Deepak
    I want to write java tcp socket programming using java NIO. Its working fine. But I am using the same selector for accepting reading from and writing to the clients. How Can I create different selectors for accepting new connection in java NIO, reading and writing. Is there any online help. Actually when I am busy in reading or writing my selector uses more iterator. So If more number of clients are connected then performance of accepting new coneection became slow. But I donot want the accepting clients to be slow // Create a selector and register two socket channels Selector selector = null; try { // Create the selector selector = Selector.open(); // Create two non-blocking sockets. This method is implemented in // e173 Creating a Non-Blocking Socket. SocketChannel sChannel1 = createSocketChannel("hostname.com", 80); SocketChannel sChannel2 = createSocketChannel("hostname.com", 80); // Register the channel with selector, listening for all events sChannel1.register(selector, sChannel1.validOps()); sChannel2.register(selector, sChannel1.validOps()); } catch (IOException e) { } // Wait for events while (true) { try { // Wait for an event selector.select(); } catch (IOException e) { // Handle error with selector break; } // Get list of selection keys with pending events Iterator it = selector.selectedKeys().iterator(); // Process each key at a time while (it.hasNext()) { // Get the selection key SelectionKey selKey = (SelectionKey)it.next(); // Remove it from the list to indicate that it is being processed it.remove(); try { processSelectionKey(selKey); } catch (IOException e) { // Handle error with channel and unregister selKey.cancel(); } } } public void processSelectionKey(SelectionKey selKey) throws IOException { // Since the ready operations are cumulative, // need to check readiness for each operation if (selKey.isValid() && selKey.isConnectable()) { // Get channel with connection request SocketChannel sChannel = (SocketChannel)selKey.channel(); boolean success = sChannel.finishConnect(); if (!success) { // An error occurred; handle it // Unregister the channel with this selector selKey.cancel(); } } if (selKey.isValid() && selKey.isReadable()) { // Get channel with bytes to read SocketChannel sChannel = (SocketChannel)selKey.channel(); // See e174 Reading from a SocketChannel } if (selKey.isValid() && selKey.isWritable()) { // Get channel that's ready for more bytes SocketChannel sChannel = (SocketChannel)selKey.channel(); } } Thanks Deepak

    Read the article

  • When are ASP.NET Expression Builders most useful?

    - by SkippyFire
    I saw an example of using Expression Builders, and creating your own Custom Expression Builder Classes here: http://aspnet.4guysfromrolla.com/articles/022509-1.aspx However, I fail to see the value in using this approach. It doesn't seem much easier than programmatically setting values in your code behind. As far as I can tell, the only thing you can do with them is set properties. Maybe they would be useful for setting defaults on certain controls? Can anyone shed light on where this ASP.NET feature becomes powerful?

    Read the article

  • Codeigniter directory_map()

    - by aeran
    Hi all, I'm trying to use the directory_map('source directory',false) function to scan through user uploaded folders/files. It works and spit out the result in a multilevel array format. I wouldn't know how deep is the multi level array would be. How do I iterate the array and display it in a readable format (e.g. in tags)?

    Read the article

  • Using hash to check if page with $_POST values was refreshed

    - by Dieseltime
    When posting a form to the same PHP page, what is the correct method to find if the page was accidentally refreshed instead of submitted again? Here's what I'm using right now: $tmp = implode('',$_POST); $myHash = md5($tmp); if(isset($_SESSION["myHash"]) && $_SESSION["myHash"] == $myHash) { header("Location: index.php"); // page refreshed, send user somewhere else die(); } else { $_SESSION["myHash"] = $myHash; } // continue processing... Is there anything wrong with this solution?

    Read the article

  • ASP.NET MVC 2 DisplayFor()

    - by ZombieSheep
    I'm looking at the new version of ASP.NET MVC (see here for more details if you haven't seen it already) and I'm having some pretty basic trouble displaying the content of an object. In my control I have an object of type "Person", which I am passing to the view in ViewData.Model. All is well so far, and I can extact the object in the view ready for display. What I don't get, though, is how I need to call the Html.DisplayFor() method in order to get the data to screen. I've tried the following... <% MVC2test.Models.Person p = ViewData.Model as MVC2test.Models.Person; %> // snip <%= Html.DisplayFor(p => p) %> but I get the following message: CS0136: A local variable named 'p' cannot be declared in this scope because it would give a different meaning to 'p', which is already used in a 'parent or current' scope to denote something else I know this is not what I should be doing - I know that redefining a variable will producte this error, but I don't know how to access the object from the controller. So my question is, how do I pass the object to the view in order to display its properties? (I should add that I am reading up on this in my limited spare time, so it is entirely possible I have missed something fundamental) TIA

    Read the article

  • jquery sortable item cached? #sortable items: '.class1' filter is not working when class is changed

    - by liz
    hello everyone, i came across a weird problem today: i created a sortable list of divs. each div has a class="class1" and items is set to 'class1' (see below simplified code). each div has an a href link that calls a function toggleLock. this function replaces class="class1" with class="locked" for that div. for example: will become the problem is: even though #sortable is set to "make" only items with class="class1" sortable, replacing the class still allows to be sortable. seems like item class is cached at some point. i've tried to refresh #sortable ($('#sortable').sortable("refreshPosition") and $('#sortable').sortable("");), but that didn't work. i've tried both ways of replacing the class: attr('class','lock') and removeClass(), then addClass(). still is sortable. if class is not changed dynamically, but loads into DOM as , then it's not sortable as expected. why wouldn't replacement of the class from class1 to locked prevent that div from being sortable? am i missing something? sample code: <div id="sortable"> <div class="class1" id="1"> <div class="sortHandle">....</div> <href="javascript:void(null);" onclick="toggleLock($(this).attr('id').replace('R',''));" id="R1">lock</a> <p>This is item 1</p> </div> <div class="class1" id="2"> <div class="sortHandle"></div> <href="javascript:void(null);" onclick="toggleLock($(this).attr('id').replace('R',''));" id="R2">lock</a> <p>This is item 2</p> </div> <div class="class1" id="3"> <div class="sortHandle"></div> <href="javascript:void(null);" onclick="toggleLock($(this).attr('id').replace('R',''));" id="R3">lock</a> <p>This is item 3</p> </div> </div> js: $(function() { $("#sortable").sortable({ items: '.class1', handle: '.sortHandle', cursor: 'move', start: function(e,ui) { el = e.target; startPos = ui.item.prevAll().length+1; }, update: function(event, ui) { data = $('.class1').sortable('toArray'); newPos = ui.item.prevAll().length+1; alert("position: "+startPos+"; newposition: "+newPos); } }).disableSelection(); });

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >