Friday, April 29, 2011

WPF/Silverlight XAML template for a glass button

It seems like a simple thing - but...

I want to create a WPF/Silverlight XAML template for a glass button that contains an image and a label - both the image and the label use template binding so that different images and labels can be specified for each button instance.

Any help would be appreciated.

David Roh

From stackoverflow

php and email interaction

I am working on a futur projects that will get information to a private website not from interface but from email. After some research, posterous.com is doing something interesting, posting on personal blog from email. flickr is doing the same thing with photo attached from email and post it n the server to show off

My question. Where on the net I can find proof of concept or already made script that do

  1. read pop email account at specific interval (each 5 minutes)
  2. extract subject and content of the mail
  3. get attachment photos
  4. save that specific information to file on server

all that can be done with php, but my qualification is not good enough to do that myself, but i can adapt some script for sure !.

From stackoverflow

How do I tell if a win32 application uses the .NET runtime

How do I tell if an executable is a .NET application?

I prefer not to have to install Visual Studio. But if I have to I will. A commandline program is preferred.

From stackoverflow
  • Drop it into Reflector and it will be de-compiled.

  • An application is a .NET executable if it requires mscoree.dll to run. You can check for this using the Dependency Walker, but in general any tool that gives you the list of required DLL's to run will do.

    If you want to know if a running process is a .NET process, I can only recommend Process Explorer. This tool will give you a lot of information about the process, including some .NET properties.

  • PEVerify will do that :)

  • Or simpler : use the Process Explorer. Free download here

  • Process Explorer colors dotNet applications using yelow color by default. That should be enough :)

  • If it runs really slow but looks like a standard Windows app, it's .NET.

    If it runs really, really slow and looks ugly too, it's Java.

    If it's fast and looks good, it's Delphi.

    If it's just fast, it's C/C++.

    :-)

    j0rd4n : +1 just because it gave me a good morning laugh
    majkinetor : Nice explanation :D
    Mehrdad Afshari : -1 for bitching .net. It's not really slow.
    Pondidum : you mixed up .net and delphi :p
  • You could use ILDasm.exe whitch is installed by default together with installing the .Net Framework SDK on your machine (look in C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin) Just open ildasm.exe en drop de the assembly in it, if it's dissambled it's a .net, if you receive an error it's not.

  • "I prefer not to have to install Visual Studio. But if I have to I will. A commandline program is preferred."

    You don't have to install Visual Studio just to run a .NET application - just the .NET framework which you can download on it's own.

    But, if you want to determine whether it's a .NET application, you can download and use .NET Reflector or use ILDasm, which comes with the .NET framework SDK.

    Dave Van den Eynde : ILDasm comes from the .NET Framework SDK, which is downloadable freely and doesn't require Visual Studio.
  • Simpler yet:

    1. Open the properties, look at the tab "Version", if under "Other information" you see a property called "Assembly version" then it is likely a .NET application.

    2. Open the EXE or DLL with notepad or similar app and look for the text "mscorlib" (without the quotes). If you find it, it will most likely be a .NET application.

Repository and Immutable objects?

I may be doomed by an impedence mismatch, but I'm trying to reconcile examples I've seen for IRepository and immutable objects.

I'm working on a cataloging application where hundrds of web requests operate on a 'working set' of products - a subset of the whole catalog tends to be in play at any given time.

At the same time, our data teams constantly update product data - new images, updated pricing, descriptions, etc. etc.

It seems to me that for performance I'm better off considering a product as immutable. They are loaded and cached by a repository and many threads can be accessing the same product object at the same time.

But this idea seems broken with many of the IRepository examples I've seen with Update/Delete methods - as soon as a thread can write to a product it seems like I open myself up to races and other nastiness.

So I envisioned an 'editor' model where changes to an entity are made via a companion 'editor' object that then persists the changes and forces the product in question to be reloaded for everyone to use. Products are never changed - only 'edited' externally and reloaded.

Does this make any sense? Can this work with a repository as I've seen them described?

Thanks for your time!

From stackoverflow
  • Are there such high concurrency or performance requirements that you can't do simple locking, either exclusive/pessimistic or optimistic?

  • A repository is only responsible for data retrieval/storage. A factory is responsible for creating new objects.

    In your case, immutable objects are ok. However you need some method to invalidate superseeded products and remove them from the repository cache. Any dangling references can be neglected in most cases, as they were valid at retrieval time.

    In case of a product update you need to make sure that you create a new product via the factory. Your repository would only include three operation kinds: Retrieve (or Find), Save and Supersede. Where Save stores a new product, which is not changed. And Supersede would store the new product, invalidate the old and purge it from the cache.

    In terms of a C# signature I could imagine the two storage methods to take the following appearance:

    void Save(Product product);
    
    void Supersede(Product oldProduct, Product newProduct);
    

    I hope this helps.

    n8wrl : Perhaps this with an 'edit lock' as suggested by Michael Haren is the way to go - thanks so much!
    __grover : I'm not sure if I would really update the database record for the product. If you need to keep a product history, it may make more sense to replace.

How to install a second JVM?

Hello, I am working on a Linux Ubuntu 8.10 and I would like to install a second JVM. I am currently working with Java 1.6, but I want to install Java 1.4 and afterwards, set the 1.4 JVM as my default JVM, to work with. How could I do that? Thanks in advance!

From stackoverflow
  • Just install the package you want. After that you're able to switch java implementations using update-java-alternatives

    See Help pages for more.

  • With Linux, you can install multiple JVMs without conflict (unlike Windows, where the registry is updated).

    Your "default" JVM is controlled in two ways: if you're executing java from the command line, it's the PATH environment variable. That is described in any Unix reference.

    The other way is the file ${HOME}/.java/deployment/deployment.properties, which is used by Java Webstart and the Java Browser Plugin. You'll find several configuration variables in this file that refer to the version. Your safest approach is to rename the .java directory before installing an earlier version.

High performance machine executes SQL queries slower than a normal one?

We have an 8 CPU 2.5GHz machine with 8 GB of RAM than executes SQL quries in slower fashion than a dual core 2.19 GHz with 4GB of RAM?

Why is this the case, given that Microsoft SQL server 2000 is installed on both machines

From stackoverflow
  • Just check these links to indicate where the bottleneck is situated

    http://www.brentozar.com/sql/

    I think the disk layout and the location where which SQL server database files are causing the trouble.

  • Also, you may have different settings of SQL Server (memory assignments and AWE memory, threads, maximum query memory, processor affinity, priority boost).

  • Check the execution plans for the same query on both machines and, if possible, post it here.

    Most probably it will be the case.

  • Our solution for multicore servers (our app executes many very complex queries, which tend to create many threads and these start to interlock and even deadlock sometimes):

    sp_configure 'show advanced options', 1
    reconfigure
    go
    sp_configure 'max degree of parallelism', 1
    reconfigure
    

    This is not ideal solution, but we haven't noticed any performance loss for other actions.

    Of course you should optimize disk layout too and sometimes limit SQL server memory for 64bit server.

    Darrel Miller : I have to agree. We had all sorts of problems with parallel queries. Turning them off as suggested has improved the situation.
  • Keep in mind that just be cause one machine has more CPUs running at a higher clock speed and memory than another, it's not necessarily going to solve a given problem faster than another.

    Though you don't provide details, it's possible that the 8-CPU machine has 8 sockets, each with a single-core CPU (say, a P4-era Xeon) and 1 GB of local (say RDRAM) RAM. The second machine is a modern Core 2 Duo with 4GB of DDR2 RAM.

    While each CPU in machine #1 has a higher individual frequency, the netburst architecture is much slower clock-for-clock than the Core 2 architecture. Additionally, if you have a light CPU load, but memory-intensive load that doesn't fit in the 1GB local to the CPU on the first machine, your memory accesses may be much more expensive on the first machine (as they have to happen via the other CPUs). Additionally, the DDR2 on the Core 2 machine is much quicker than the RDRAM in the Xeon.

    CPU frequency and total memory aren't everything -- the CPU architecture, Memory types, and CPU and memory hierarchy also matter.

    Of course, it may be a much simpler answer as the other answers suggest -- SQL Server tripping over itself trying to parallelize the query.

flex compiler error (warning) message in flex ant task

I have following warnings if I compile our flex project with the ant task from the flex sdk. Does anyone have an idea where this comes from and why this happens and if I can safely ignore it? (The swf file itself seems to get created without an actual error)

[mxmlc] The args attribute is deprecated. Please use nested arg elements.
[mxmlc] Loading configuration file /home/jrose/SDKs/flex_sdk_3-1/frameworks/flex-config.xml
[mxmlc] Locking assertion failure.  Backtrace:
[mxmlc] #0 /usr/lib/libxcb-xlib.so.0 [0x786057c7]
[mxmlc] #1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_unlock+0x31) [0x78605891]
[mxmlc] #2 /usr/lib/libX11.so.6(_XReply+0x254) [0x77053494]
[mxmlc] #3 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so [0x77e6ddce]
[mxmlc] #4 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so [0x77e57d77]
[mxmlc] #5 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so [0x77e57ef3]
[mxmlc] #6 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so(Java_sun_awt_X11GraphicsEnvironment_initDisplay+0x26) [0x77e58136]
[mxmlc] #7 [0xb1411008]
[mxmlc] #8 [0xb140ab6b]
[mxmlc] #9 [0xb140ab6b]
[mxmlc] #10 [0xb1408236]
[mxmlc] #11 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so [0xb76a3eec]
[mxmlc] #12 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so [0xb7873ae8]
[mxmlc] #13 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so [0xb76a3d1f]
[mxmlc] #14 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so(JVM_DoPrivileged+0x32d) [0xb770182d]
[mxmlc] #15 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/libjava.so(Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2+0x3d) [0xb73a730d]
[mxmlc] #16 [0xb1410898]
[mxmlc] #17 [0xb140aa94]
[mxmlc] #18 [0xb1408236]
[mxmlc] #19 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so [0xb76a3eec]
[mxmlc] Locking assertion failure.  Backtrace:
[mxmlc] #0 /usr/lib/libxcb-xlib.so.0 [0x786057c7]
[mxmlc] #1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_lock+0x2e) [0x7860596e]
[mxmlc] #2 /usr/lib/libX11.so.6 [0x77052619]
[mxmlc] #3 /usr/lib/libX11.so.6(XGetVisualInfo+0x26) [0x77048666]
[mxmlc] #4 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so [0x77e570b9]
[mxmlc] #5 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so [0x77e57303]
[mxmlc] #6 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so [0x77e57fa1]
[mxmlc] #7 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/xawt/libmawt.so(Java_sun_awt_X11GraphicsEnvironment_initDisplay+0x26) [0x77e58136]
[mxmlc] #8 [0xb1411008]
[mxmlc] #9 [0xb140ab6b]
[mxmlc] #10 [0xb140ab6b]
[mxmlc] #11 [0xb1408236]
[mxmlc] #12 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so [0xb76a3eec]
[mxmlc] #13 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so [0xb7873ae8]
[mxmlc] #14 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so [0xb76a3d1f]
[mxmlc] #15 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/server/libjvm.so(JVM_DoPrivileged+0x32d) [0xb770182d]
[mxmlc] #16 /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre/lib/i386/libjava.so(Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2+0x3d) [0xb73a730d]
[mxmlc] #17 [0xb1410898]
[mxmlc] #18 [0xb140aa94]
[mxmlc] #19 [0xb1408236]

Ant target

<target name="compile-flex-swf" description="creates swf file">
    <mxmlc file="${basedir}/flex_src/company_gui.mxml" 
        keep-generated-actionscript="false" 
        output="${basedir}/target/${ant.project.name}.swf" 
        fork="true" 
        debug="${flex.debug}" 
        services="${basedir}/WebContent/WEB-INF/flex/services-config.xml" 
        actionscript-file-encoding="UTF-8" 
        optimize="true">

        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
        <context-root>company</context-root>
        <compiler.library-path dir="${LCDS_HOME}/resources/frameworks" append="true">
            <include name="libs/fds.swc" />
        </compiler.library-path>
        <compiler.library-path dir="../company_flex/target" append="true">
            <include name="*.swc" />
        </compiler.library-path>
    </mxmlc>
</target>
From stackoverflow
  • Those backtraces really have nothing to do with flex or ant. It really is just an interaction between AWT and XCB. You can find more information with the sun bug 6532373 or the Xlib bug 11390. There are workarounds, but I don't think they are necessary (other than removing those nasty messages).

    Mauli : I think thats it. I actually found the same errors in another build recently.