Thursday, April 21, 2011

Is this a bug in XSD implementation? Why doesn't this work?

Hi,

I have one xsd file I'd rather not modify (Exceptions.xsd):

<xs:schema 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns="http://me.com/Exceptions.xsd" 
     targetNamespace="http://me.com/Exceptions.xsd" 
     elementFormDefault="qualified" 
     attributeFormDefault="unqualified"
>
    <xs:element name="Exception" type="ExceptionType" />

    <xs:complexType name="ExceptionType">
     <xs:sequence>
      <xs:element name="Code" type="xs:string" minOccurs="0"/>
      <xs:element name="Message" type="xs:string"/>
      <xs:element name="TimeStamp" type="xs:dateTime"/>
     </xs:sequence>
    </xs:complexType>
</xs:schema>

I want to create a new element with an other name that implements that ExceptionType (ExceptionsExtensions.xsd - Alternative 1).

<xs:schema 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns="http://me.com/Exceptions.xsd" 
     targetNamespace="http://me.com/Exceptions.xsd" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation=
       " 
       http://me.com/Exceptions.xsd Exceptions.xsd
       "
     elementFormDefault="qualified" 
     attributeFormDefault="unqualified">

    <xs:element name="SpecificException" type="ExceptionType" />
</xs:schema>

I get the error message: Type 'http://me.com/Exceptions.xsd%3AExceptionType' is not declared.

However, if I would do this (ExceptionExtensions.xsd - Alternative 2):

<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns="http://me.com/Exceptions.xsd" 
    targetNamespace="http://me.com/Exceptions.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=
            " 
            http://me.com/Exceptions.xsd Exceptions.xsd
            "
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified">

    <xs:element name="SpecificException">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="innerException">
        <xs:complexType>
         <xs:sequence>
          <xs:any namespace="http://me.com/Exceptions.xsd" />       
         </xs:sequence>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
     </xs:complexType>
    </xs:element>

I can validate

<?xml version="1.0" encoding="utf-8"?>
<SpecificException xmlns="http://me.com/Exceptions.xsd">
    <innerException>
     <Exception>
      <Code>12</Code>
      <Message>Message</Message>
      <TimeStamp>2009-08-27T11:30:00</TimeStamp>
     </Exception>
    </innerException>
</SpecificException>

So in Alternative 1 it CANNOT find the ExceptionType which is declared in Exceptions.xsd, but in Alternative 2 it CAN find the Exception-element which is declared in Exceptions.xsd.

Why doesn't Alternative 1 work?

Kind regards, Guillaume Hanique

From stackoverflow
  • In your "Alternative 1", you're referencing "ExceptionType" - but it's not declared anywhere in that file.

    Just because two files share the same namespace doesn't mean File A can depends on stuff in File B - you will need to connect the two!

    Add an <xsd:include> to your second file:

    <xs:schema 
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns="http://me.com/Exceptions.xsd" 
        targetNamespace="http://me.com/Exceptions.xsd" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://me.com/Exceptions.xsd Exceptions.xsd"
        elementFormDefault="qualified" 
        attributeFormDefault="unqualified">
    
      <xs:include schemaLocation="exceptiontype.xsd"/>
    
      <xs:element name="SpecificException" type="ExceptionType" />
    </xs:schema>
    

    That should do the trick!

    Marc

    Guillaume Hanique : That's it, thanks!
  • Check this question.

    http://stackoverflow.com/questions/332792/can-i-have-one-xml-schema-xsd-include-another-xml-schema/489385#489385

    Here is another link which clearly explains the differences between xsd:include & xsd:import.

    Hope this helps

Why is video in WPF MediaElement taking so long to repeat?

Here's my Xaml for a MediaElement:

        <MediaElement x:Name="mediaElement" Width="400" Height="300" Stretch="UniformToFill" IsMuted="True">
            <MediaElement.Triggers>
                <EventTrigger RoutedEvent="MediaElement.Loaded">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <MediaTimeline Source="temp.wmv" Storyboard.TargetName="mediaElement" RepeatBehavior="Forever" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </MediaElement.Triggers>
        </MediaElement>

the video temp.wmv is about 10 megs and 2 minutes long... it's not terribly high def either, I think it's below DVD quality. I expected the Storyboard to make the video start from the beginning immediately after it finishes, but for some reason it takes a long time, sometimes minutes, for the video to start back up. Is there anything that could be effecting the time it takes for the video to repeat?

From stackoverflow
  • For any others looking at this - the MediaElement in WPF 3.5 sp1 is horribly buggy and will receive many fixes in 4.0 that aren't in beta 1. Try Jeremiah Morrill's open source WPF MediaKit here http://wpfmediakit.codeplex.com and use the MediaUriElement with Loop=true for a good looping media experience.

wpf Mouseclick on textbox

how to set the command and command parameter on mouseclick on textbox in xaml?

From stackoverflow
  • TextBoxes don't extend from ButtonBase and therefore don't work with Commands. What you're trying to do is wrong. You should ask another question that states your requirements and asks how best to go about achieving them.

  • You can use attached command behaviors.

    HTH, Kent

  • Use the PreviewMouseDown of textbox.

  • As Ortis Mallum answered, the PreviewMouseDown event does work.

having and conditional count() in linq query

I want to create this query:

select Something, count(Something) as "Num_Of_Times"
from tbl_results
group by Something
having count(Something)>5

I started with this:

tempResults.GroupBy(dataRow => dataRow.Field<string>("Something"))
   .Count() //(.......what comes here , to make Count()>5?)
From stackoverflow
  • from item in tbl_results
    group item by item.Something into groupedItems
    let count = groupedItems.Count()
    where count > 5
    select new { Something = groupedItems.Key, Num_Of_Times = count };
    


    UPDATE : This would give you the result as an IQueryable<DataRow> :

    DataTable dt= new DataTable();
    dt.Columns.Add("Something", typeof(int));
    dt.Columns.Add("Num_Of_Times", typeof(int));
    
    var results =   (from item in tbl_results
                     group item by item.Something into groupedItems
                     let count = groupedItems.Count()
                     where count > 2
                     select dt.Rows.Add(groupedItems.Key, count)).AsQueryable();
    

    (note that it also fills the dt table)

    Rodniko : Thank you very much, i need the result as IQueryable, Is there a way to create the 'select' result as a IQueryable? or do i need to create the rows manually?
    Thomas Levesque : see updated answer
    Rodniko : Thank you very much :)
  • Thanks! it helped me a lot.

How to delete all records in a table using SubSonic 3

I am a little stuck at the moment trying to delete all the records from a table using this approach:

new Delete<Contact>().Execute();

This statement fails with a NullReferenceException in BuildDeleteStatement method at line:

sb.Append(query.FromTables[0].QualifiedName);

because, although FromTables has one entry, it is set to null. I also tried this but it didn't worked either:

var provider = ProviderFactory.GetProvider("MonitorData");
new Delete<Contact>(provider).Execute();

What am I doing wrong? Please help. Thanks.

PS: I am using ActiveRecord with SS v3.0.0.3.

From stackoverflow
  • You can do this with the repo DeleteMany method:

    SubSonicRepository<Contact> repo = new SubSonicRepository<Contact>(new YourDB());
    repo.DeleteMany(contact => true);
    

    The lambda I'm using is just to ensure all records are selected (thanks dangph).

    Yogesh : Thanks. It did the trick.
    dangph : repo.DeleteMany(c => true);
    Yogesh : You mean "repo.DeleteMany(c => true);" ?

WPF Format DateTime in TextBlock?

I have a TextBlock thats bound to a DateTime property how do i configurate the format of the date?

From stackoverflow
  • There is a string format property available when you are declaring the binding:

    <Textbox Text={Binding Path=DateTimeValue, StringFormat=dd-MM-yyyy} />
    

    (You need to be on .NET 3.5 SP1 for this property to exist)

twitter status is not decoding #

Hello,

I am using the following to share something on twitter from my site..

<a target="_blank" href="http://www.twitter.com/home?status=<?=$res?>" name="share" ><img src="images/referral_twitter.jpg" alt="Share On twitter" /></a>

where $res=Track SunGlass Up for #share #barter at http://su.pr/2UBgEg - #ihave

but if i urlencode this and send, it is only identifying the space not the #..# appears as %23..any idea how to show # as is it?? Pls help...

From stackoverflow
  • I have the same problem. Have you figured it out? Thanks!

    Joe Philllips : Put comments where they belong, not as answers.

ASP.NET MVC: Redirecting to an Action on a different application.

I have a copule of MVC apps. I'd like to be able to redirect from one to another? Do I just post to the specific app I'm trying to hit? Is there a way to Html.RedirectToAction on a different app?

From stackoverflow
  • you can use RedirectResult:

    public ActionResult SomeAction()
    {
        // do stuff...
        return Redirect("http://myurl.com");
    }
    
  • What's stopping you from doing the following inside your action?

    return Redirect("http://www.otherapp.com/product/category");
    

    If you don't want to hard code the http://www.otherapp.com then you could put a configuration setting inside your web.config file for it...?

Checking if a username already exists asynchronously - ASP.NET

I have seen several websites nowadays that asynchronoulsy checks if the user name you are typing is available or not. It appears that they use AJAX for this (and capture the textbox on changed event and maybe call a server side method that does a DB call?)

For a ASP.NET/C# site, how would I go about doing this? I would really appreciate specific answers (and hopefully point me to an open source code that I could use to analyze the architecture of a website that does stuff like this?)

From stackoverflow
  • Steps:

    1. Create a simple service to check availability of a username.

    2. Wire javascript to call the service when the text in the textbox on your page has changed.

    3. Call your simple service with the text in the textbox.

    4. Parse the result of your service call and render the alert on the page.

    : So, it appears that these websites use a service oriented architecture where most of the business logic is stored on a webservice?
    Justin Niessner : The presence of a web service doesn't mean the site uses a Service Oriented Architecture. In the case of StackOverflow, the site uses an MVC architecture and probably has a few web services for simple AJAX operations.
    : So, does that mean any of the logic associated with the AJAX operation should be in the webservice? Generally, if there was a button that said "Check availability", I could write the logic in the code behind page (and can have access to viewstate and other control info). If the logic is in a WS, I don't have access to any of this stuff right?

How can I add a contact to Blackberry web application using JavaScript (if possible)?

I need to develop an application, which adds telephone numbers to existing or new contacts in Blackberry. The application is preferrably a web application. Is it possible to add and read contact information on Blacberry devices using JavaScript? If yes, a code sample would be appreciated.

From stackoverflow
  • Do you mean directly into the BlackBerry address book? I'm almost positive that's impossible and would be a gigantic security risk if they did allow it (which only furthers my belief that it's impossible). Generate and link to a vcard instead. Then you just need a link like "Click Here to add to address book" and the BB Browser handles the rest.

Flash - Continue Script despite Running Slow Warning

My program requires multiple random recursions, and I have to manually let the script continue past a warning that keeps popping up:

"A script in this movie is causing flash player to run slowly."

Is it possible to automatically continue past this warning?

From stackoverflow
  • You can set the script timeout in the Flash Authoring tools publish settings (CTRL+SHIFT+F12), it's the last setting on the Flash tab. If you're using mxmlc to compile, check out the -default-script-limits parameter.

    It is however a better idea to split your calculation up over multiple frames, users will very likely think your app is frozen if it's unresponsive for several seconds.

    stringo0 : Thank you! Didn't know it existed :P

Firebird .NET interoperation

Has anyone had experience with using Firebird in interoperating with the .NET framework and if so, how did it go?

From stackoverflow
  • I've used firebird in a commercial desktop application.

    Its performance is fine, until you deal with queries that return large result sets. In those cases we found that the .net provider for firebird was performing in an inefficient way. You may find that this isn't a problem for you -- if queries are specific enough they don't return large result sets.

    For us, the performance remained passable.

    It was certainly feature complete, in the sense that it could do everything we wanted it do. The tooling is also sufficient to help with troubleshooting, table design etc.

    As a sql-server dev i found firebird's sql syntax close enough that we handled problems through general googling and without needing to ask for help from stackoverflow.

  • Take a look at SinĂ¡tica Monitor. It's a firebird monitoring tool and it's written in C# with .net 2.
    Also check out the Firebird .Net Data Provider.

Verifying file digests

Say I have 'n' number of files, for each of which I have CRC32, MD5 and SHA1 digests

Now these 'n' number of files are actually split files/archives of single large file.

When these smaller files are recombined/joined into the larger file, we can compute the digest of this larger file too.

My question is : Is there a way to verify whether the combination of the digests of these smaller files equal the digest of the large file?

For example, say I have a file split into 4 parts with digests 0xDE, 0xAD, 0xBE, 0xEF

Say, after joining, the larger file has digest 0xC0

Is there any way to verify that join(0xDE, 0xAD, 0xBE, 0xEF) == 0xC0, where 'join' is the magical operation/formula/algorthm I am looking for?

From stackoverflow
  • Don't think so, sorry
    It would make it rather easy to crack an MD5 if this was possible

    edit. If you mean can I compute the MD5 of the sum from the MD5 of the parts = no.
    But if you just want to confirm that the parts are correct you can always calculate the MD5 of each individual part and then the MD5 of the set of those MD5s.
    Obviously to verify it you need to perform the same sequence, so someone who only has the complete file would have to split it to do the same check.

    PoorLuzer : crack an MD5 .. how so?
    Martin Beckett : it would allow you to build dictionaries of blocks with known MD5, then if you wished to generate a certain digest for a fake message you would have a library of arbitrary padding blocks to add.
    skaffman : MD5 shouldn't be used for secure hashes any more, it's been demonstrated as insecure for some years now.
    Martin Beckett : It's been demonstrated that it is easier to find collisions than you would like. If you don't accept arbitrary binary files it is still pretty good. Your chances of creating an email with legible text that collides with another text email are rather small.
  • If you won't to join the files, you can pass them one by one to hash algorithm using TransformBlock method. With calling TransformFinalBlock that gives you the result.

Topology diagram in silverlight

I have a web application which lets users create entities, and define relationships and associations between the entities. I'd like to use silverlight to visually show a topology diagram of the entities. Hopefully it would be able to have some smarts to figure out initial positions of each entity, and then potentially allow the user to move then entities around however they see fit. Similar to how the database diagramming works in sql 2000 enterprise explorer. Has this been done in silverlight, maybe something I can just re-use, or use as a sample to get me going. Or even something I can port might be helpfull.

From stackoverflow
  • You could try save the topology (using on of the many tools to do so) as an image server side, the showing the image on the page. This wouldn't require silverlight though.

create net.tcp binding wcf service object in silverlight

Hello

i have develop a silverlight application with wcf net.tcp binding. i want create an object of service in sliverlight. how it is possible. please help me.

Thanks

From stackoverflow
  • No, as far as I know, up to and including Silverlight 3, it supports only the basicHttpBinding (and possibly the webHttpBinding as well?). NetTCP is not supported, sorry.

    Here's a blog post by Yavor Georgiev (Program Manager, Silverlight Web Services Team) where he explains what's new in web services with Silverlight 3 - unfortunately, no mention of netTCP :-(

    Marc

  • Version Update,

    Silverlight 4 now has the net.tcp binding

  • Silverlight 4 supports tcp binding. Some extended info: http://tomasz.janczuk.org/2009/11/wcf-nettcp-protocol-in-silverlight-4.html

Mixing MDX Drillthrough statement and SQL joins

I want to use an MDX drill through command but i also want to join it to some SQL tables as well.

that is there will be an Id in the fact table and not a lot of other data I want to join this on to another table or view and produce a report based on those ID's returned in the drill down.

Ideas?

From stackoverflow
  • MDX won't do this directly. The only way I can think of doing this would be to retrieve the recordset from the drillthrough (which can be done with ADO), load it into a temporary table and join it against whatever else you want in a query.

    The other option is to widen the drillthrough (if the dimensions have the data you need) and get the fields from that. Note that SSAS2005+ can support multiple drillthrough actions.

    This MSDN article has some code snippets that demonstrate working with record sets returned from a drillthrough.

Text in Title Bar

How can we move text in the Title Bar of a form in C#.net using VS 2008?

From stackoverflow
  • If you want to scroll the text in the title bar (as in news tickers) you will need to update the title bar manually every second or so. You can use the Timer control for that.

    Having said that, I personally find it VERY annoying to see such applications. You must have a good reason to do that.

    baeltazor : nice one hemant, +1
    rahul : +1 for pointing out that it is very 'annoying'.

Default.png no longer exists

I've searched for the answer to this question but I can't seem to find it, and logically this process makes no sense to me...

I added a default.png to my app and I didn't like the fact that it didn't show long enough, so I removed it and was going to add a splash screen instead.

The problem is that the default.png still shows on load. I've completely removed it from the Xcode project and from the computer.

I've deleted the installed app from the simulator, and rebuilt the project but it still shows up. I've even exited Xcode and relaunched. Does this value get saved anywhere that I'm missing? How do I get rid of this image?

Any help will be appreciated.

Thank you in advance, BWC

From stackoverflow
  • Have you tried doing a Clean first? I've had some resources stick around before with Xcode... the clean operation deletes all the build artifacts.

Does Pony support SSL/TLS for GMail (Yes!)

Does the Pony gem support e-mail with SSL/TLS? I'm trying to (easily) send e-mail with Google Apps on Heroku.

Thanks!

After jumping through several hoops, I found a combination of solutions that worked for me: http://417east.com/thoughts/2009/austin/heroku-gmail-sinatra.

From stackoverflow

Office 2003 PIAs with Office 2007

Is it possible to target Outlook 2003 in a vb.net 2008 Windows application when working on a system that only has Office 2007 installed on it? I downloaded the 2003 PIAs, but they wont install without Office 2003 installed first. The point is, I don't want Office 2003 installed on my development machine.
Thanks

From stackoverflow
  • You can do it, but you have to browse to the PIAs directly when adding the reference.

rails: specify the HTTP verb in a redirect_to

Hi

Here's a basic overview of my domain:

  • a user has a list of courses
  • the user can "select" a course. The corresponding action is invoked with the PUT verb, stores the course_id in a session variable and redirects to the "show" action of the selected course.
  • when the user has only 1 course available, I want to redirect him directly to the only course available (and invoke the "select" method before, of course).

From there, i see 2 options:

  1. Keep the "select" action when the user clicks the link and add a new action for when the selection is automatic... but that doesn't look very DRY (even if I could refactor some code)
  2. call the PUT action from the controller itself... but I haven't found how (is it even possible)?

Any alternative is welcome :)

Thanks for your help.

P.

From stackoverflow
  • In the courses controller:

    def index
      @courses = Course.all
      if @courses.length == 1 #if only one course
        @course = @courses[0] #get that course
        session[:course_id] = @course.id #set the session
        redirect_to :action => "show", :param => "#{@course.id}" #redirect
      end
      respond_to do |format|
        format.html
        format.xml  { render :xml => @line_items }
      end
    end
    
    Pierre : Hi, thanks for the suggestion. I wanted to avoid duplicating the session[] part, but if there's no other choice, i think it will be a necessary evil. I'll perhaps make it a standalone method. Thanks! P.
    iano : Pierre, try: def show @course = Course.find(session[:course_id] instead of def show @course = Course.find(params[:id]) and you should be able to get rid of the param in the redirect_to line

Adding action to a delete event in jQuery

How can you add the class red to the class question_body when the question is removed?

JS in HEAD

jQuery('a.delete_question').live('click', function(){

    jQuery.post('/codes/handlers/delete_a_question.php', 
        { question_id: jQuery(this).attr('rel') }, 
        function(){
            $(.question_body).addClass("red");       // problem here
            alert ("Question was removed");
        })
});

The following URL generated by PHP should activate the action

    echo ("<a href='#'"
            . "class='dulete_question'"
            . " rel='" . $answer_id . "'>flag</a>"
        );

The problem is similar as this one. It suggests me that addClass -command should be correct and that the problem is in the use of it inside the function.

From stackoverflow
  • Change this:

     $(.question_body).addClass("red");
    

    To this:

     $(".question_body").addClass("red");
    

    Also make sure you have a CSS class called "red" defined.

    You can test this by moving the alert to before the addClass line, rather than after it.

    Masi : **Thank you very much for your answer!**

Sharepoint Web Service GetListItems not returning all rows

I am using the GetListItems web service and it is only returning about 50% of the results stored. Is there a limit to how much data can be returned? Is there anyway round this?

From stackoverflow

VB2008 with MySQLConnector .net 6.1

I have the following code:

Imports MySql.Data.MySqlClient Imports MySql.Data.Types

Public Class FormMain

Private Sub FormMain_Load ...

  ' Open Database
  Dim objMySQL As New MySqlConnection

End Sub

End Class

I get the compiler error message: error BC30560: "MySqlConnection" ist im Namespace "MySql.Data.MySqlClient" nicht eindeutig. in English (I think): "MySqlConnection" is not unique in Namespace "MySql.Data.MySqlClient".

From stackoverflow

Can't refresh iphone sqlite3 database

I've created an sqlite3 database from the command line and inserted several records. My app retrieves all of them and shows them just fine. I then go back and insert a few more records via the sqlite3 cli, erase the db file out of the simulator's documents directory so that it will be recopied from the main bundle, and the run the app again only to find that it only displays the original records I inserted. The new records do not show. I verified that the new db file was copied to the simulators documents directory, and when I point the sqlite3 cli at it, I can do a select * and see all the records.

What could be going on here? It almost seems as if the previous version of the db file is being cached somewhere and used instead of my updated version.

//Scott

From stackoverflow
  • I haven't verified his answer, but Stephan Burlot said:

    Sqlite uses a cache for requests. Close & reopen the database from time to release cache memory.

    (I don't think it's true that every SQLite instance caches requests, but that might be the case on the iPhone.)

    Obviously you aren't concerned with memory, but if it is caching requests, maybe just a close and reopen is all you need.

    If that isn't the case, my next guess would be that your app is not pointing to the file you think it is pointing to -- did you have it pointing to a database with a different name at one point and forget to update the app? You could verify this by updating the db from within your app, then checking for those updates with the CLI. You might just find that they are not looking at the same db.

  • every time you rebuild and run an app in xcode, it creates a new folder under the iphone simulator's applications folder. If your sqlite db is being included from xcode the old db could be put in the new folder while the one your editing is in the old and now unused folder.

    skantner : Where is xcode putting these new folders? I am only aware of projectname/build/Debug-iphonesimulator/projectname.app
    skantner : I found it: /Users/username/Library/Application Support/iPhone Simulator/User/Applications/

[alert] (22)Invalid argument: FastCGI: process manager exiting, setgid() failed

I am trying to start the Apache server and I am going to use Fast CGI. When I try to start it, I get following error message in error_log.

[alert] (22)Invalid argument: FastCGI: process manager exiting, setgid(4294967295) failed

So it looks like it is setting the group id and at that time it gave this alert message.

Any idea about this alert message?

From stackoverflow
  • It sounds like the group you have configured Apache to run under (often www-data) doesn't exist. Can you verify what group Apache is running as and that the group exists on your system?

    This link might help you: http://httpd.apache.org/docs/1.3/misc/FAQ.html#setgid

WSAGetLastError

Hello,

I am getting this error as

WSAGetLastError() returned 10061, Connection refused

can anyone please advise me the reason and where to look for the cause of this error?

From stackoverflow
  • That's the WinSock API telling you that a connection to a remote server was refused. (The server is up, but isn't accepting connections on the port you want). Who exactly tried to establish this connection is entirely application-dependent.

  • You're trying to connect to a server using a port number on which the server is not listening.

    For example, you're trying to connect to port 80 but the remote machine isn't running a web server.

  • For this error and any future Winsock errors, MSDN provides a comprehensive list of the error codes along with a brief description of what each means:

  • As Dmitry correctly pointed out, this error happens when the remote machine exists, but is not accepting connections on the specified port. Alternatively it could be caused by firewall blocking the connection. I recommend using a tool like Wireshark to see the low-level TCP/IP packets that are exchanged.

  • Thank you all, IMail server wasn't up so I was getting these errors. FIXED

Setting a dependency property's default value at design time in a Windows Workflow Foundation Custom Activity

Hi, I'm implementing a Custom Workflow and Activities to be reused in multiple projects and trying to get them to be as easy to use as possible. In this workflow I have a Property whose name is 'UserID' which I'd like to bind to a dependencyproperty in one of my activities. I can currently bind it at design time searching explicitly for the property each time I add one of these activities to the workflow, but I'd like for this activity to be binded automatically.

As far as i know (correct me if I'm wrong), to bind a dependency property at design time I need to specify a string of the form "Activity=NameOfWorkflow, Path=UserID" to the DefaultBindingProperty metadata tag, and I'd like the name of the workflow to be completed in some way. Any way of doing this?

Thanks

From stackoverflow
  • I finally managed to achieve this by attaching an ActivityToolboxItem to the Activity, and overriding a method in it that creates the instance shown in the designer. I used an ActivityBind object to bind the dependencyproperty to the workflow's property. To get the instance of the workflow, I just searched for an ancestor to my activity by calling act.Parent until the activity had no parent (and thus was the StateMachineWorkflowActivity itself)

Running a JavaScript command from MATLAB to fetch a PDF file

I'm currently writing some MATLAB code to interact with my company's internal reports database. So far I can access the HTML abstract page using code which looks like this:

import com.mathworks.mde.desk.*;
wb=com.mathworks.mde.webbrowser.WebBrowser.createBrowser;
wb.setCurrentLocation(ReportURL(8:end));
pause(1);

s={};
while isempty(s)
    s=char(wb.getHtmlText);
    pause(.1);
end
desk=MLDesktop.getInstance;
desk.removeClient(wb);

I can extract out various bits of information from the HTML text which ends up in the variable s, however the PDF of the report is accessed via what I believe is a JavaScript command (onClick="gotoFulltext('','[Report Number]')").

Any ideas as to how I execute this JavaScript command and get the contents of the PDF file into a MATLAB variable?

(MATLAB sits on top of Java, so I believe a Java solution would work...)

From stackoverflow
  • I think you should take a look at the JavaScript that is being called and see what the final request to the webserver looks like.

    You can do this quite easily in Firefox using the FireBug plugin.

    https://addons.mozilla.org/en-US/firefox/addon/1843

    Once you have found the real server request then you can just request this URL or post to this URL instead of trying to run the JavaScript.

    NickFitz : pjp's is the only sensible approach. You should also have the developer of the web interface to the internal database taken out and shot - or at least tell them to learn about progressive enhancement ;-)
    Ian Hopkinson : This looks a very promising route - I now have a URL which gets me the PDF - all I need to do now is work out how to get it into a variable... Firebug is rather handy!
    pjp : Yes it's pretty nice.
  • Once you have gotten the correct URL (a la the answer from pjp), your next problem is to "get the contents of the PDF file into a MATLAB variable". Whether or not this is possible may depend on what you mean by "contents"...


    If you want to get the raw data in the PDF file, I don't think there is a way currently to do this in MATLAB. The URLREAD function was the first thing I thought of to read content from a URL into a string, but it has this note in the documentation:

    s = urlread('url') reads the content at a URL into the string s. If the server returns binary data, s will be unreadable.

    Indeed, if you try to read a PDF as in the following example, s contains some text intermingled with mostly garbage:

    s = urlread('http://samplepdf.com/sample.pdf');
    


    If you want to get the text from the PDF file, you have some options. First, you can use URLWRITE to save the contents of the URL to a file:

    urlwrite('http://samplepdf.com/sample.pdf','temp.pdf');
    

    Then you should be able to use one of two submissions on The MathWorks File Exchange to extract the text from the PDF:

    If you simply want to view the PDF, you can just open it in Adobe Acrobat with the OPEN function:

    open('temp.pdf');
    
    Ian Hopkinson : My problem at the moment is that the URL requires authentication to access the contents, and I can't work out how to provide it via urlread. I believe there might be a route using a Java URL object. Using the webbrowser method above I can *see* the pdf document on screen, which is frustratingly close to what I want. The text from PDF functions look useful...
    gnovice : The `URLREAD` and `URLWRITE` functions allow for optional parameters to be passed to them. You would have to find out what the parameter names are for the authentication, then pass them along with the parameter values as a cell array. An example appears on this documentation page: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f5-136137.html#f5-136158
    Ian Hopkinson : Dimitri Shvorob's solution for converting the PDF file to text works nicely
    gnovice : @Ian: As expected... Dimitri is a well-respected contributor to the File Exchange. =)

Animate Expander in WPF

How to animate the expanded and collapsed actions of a Wpf expander control?

From stackoverflow

How to use nify javascript to make round corner box? Im using but not working

How to make round corners with Nifty technique. I included niftycube.js and then called the function Nifty("div.firstblock");. But its not working. Whether i have to include any other JavaScript or CSS??. Help

From stackoverflow
  • You need to include the niftyCorners.css as well.

  • Please stop, it's not worth your time. Firefox, Safari, Chrome and Konqueror all support their own form of the CSS3 style, border-radius, so put this in your CSS and be done with it:

    .myDiv {
        -moz-border-radius: 5px;
        -webkit-border-radius: 5px;
        -khtml-border-radius: 5px;
        border-radius: 5px;
    }
    

    Giving your divs rounded corners is just a visual nicety and one that can be saved for people with modern browsers. If IE users don't get a rounded border, so what?

    masato-san : Thanks for this, I was getting really mad cuz nifty never worked for me and border-radius works like a charm!

How can I solve "world writable" issues with modules uploaded to PAUSE (CPAN) from Win32?

Does anyone one know how not to get the "world writables" fail message from PAUSE when I upload a module to PAUSE?

I packed it with make dist on Windows. I haven't got access to a Linux box at work and I need to work it out on Windows.

From stackoverflow
  • As noted in GNU Tar manpage , you can use the TAR_OPTIONS environment variable to pass arguments to the tar command. One of them is --mode= . Read the man page for more information.

  • There is a script on PerlMonks that fixes things up. The URL is http://www.perlmonks.org/?node%5Fid=731935

  • If you use Module::Build for your dist building, you can install the latest version, accompanied with Archive::Tar and it will be fixed for you. No mess, no fuss.

How do I configure WWW::Mechanize to work through a proxy?

I sit behind a proxy and have HTTP and WWW::Mechanize working OK locally.

But advice || pointers as to how to get through a proxy please.

Regards Ian

From stackoverflow
  • WWW::Mechanize is an extension of LWP::UserAgent:

    WWW::Mechanize is a proper subclass of LWP::UserAgent and you can also use any of LWP::UserAgent's methods.

    So you can just use ->env_proxy, or ->proxy — as described in the manual.

  • Excellent clue depesz||cjm.

    It was actually a matter of "rtfm". Forgot the need for the environment variable "HTTP_PROXY". Do not get old you guys !!

    Ian