Saturday, February 19, 2011

Server Error in '/DNNTest' Application

Parser Error Message: The entry 'SiteSqlServer' has already been added.

Source Error:

Line 23: providerName="System.Data.SqlClient"/> -->

Line 24: < ! -- Connection String for SQL Server 2000/2005 -->

Line 25: <add name="SiteSqlServer" connectionString="Server=(local);

abase=DotNetNuke2; uid=nukeuser;pwd=dotnetnuke;" providerName="System.Data.SqlClient" / >

Line 26: </connectionStrings>

Line 27: <appSettings>

Does anyone know the work around???

From stackoverflow
  • It seems there are two connection strings named "SiteSqlServer" in your web.config file. Can you post the complete section of the config file?

    Samiksha : no, i checked... there is only one
  • Maybe this post in the dotnetnuke forums helps:

    The entry 'SiteSqlServer' has already been added

  • Here is the work around which i followed yesterday to solve my problem:

    If there is an application at the root of the site that already defines the 'SiteSqlServer' key, then that is why you are getting the error.

    You could try and change the connectionString section to look like this:

    <connectionStrings>
    
    <remove name="SiteSqlServer" />
    
    <add name="SiteSqlServer" connectionString="server=(local);uid=;pwd=;Trusted_Connection=yes;database=communityserver" />
    
    </connectionStrings>
    

    Remove the old key, then add the new one.

    you can try to clear the connection strings on the first line in the same section in web.config.

    <connectionStrings>
    <clear />
    

    ...

    This effectively prevents inherited connections.

Optimally assigning tasks to workers

I've been working on a comprehensive build system that performs distributed builds on multiple machines for quite some time now. It correctly handles dependencies and seemed to scale reasonably well, so we've added more projects and more machines, but it looks like it could perform better.

The problem I have is one of resource allocation. I have a list of available machines and a list of projects I'd like to build, also each machine lists what software, OS, compiler version, etc... is installed and each project lists what it requires. When work needs to be assigned, I can run a database query that lists the possible assignments. Now I need to perform those assignments as effectively as possible.

The smallest example is two projects 1 and 2 with two machines A and B. Machine A can build either project but machine B can only build project 1. So I end up with a list of pairs (A,1), (A,2), (B,1). If I process the assignments in order, machine A builds project 1 and I have to wait until it finishes before I can build project 2. It perhaps would have been better to assign machine A to project 2 and machine B to project 1. But... machine A may be much faster than machine B, and not using machine B at all may be the right answer.

I'm sure this is the sort of 'operational research' problem that's been addressed many times before. I don't necessarily need an optimal solution... just an attempt at something better than I have - it seems I often end up with tasks queued and machines idle which a better allocation could have avoided. Any suggestions most welcome.

From stackoverflow
  • At first thought, I'd recommend running a Windows Service on each machine, where one machine also runs the Master service to coordinate the assignments. The Master Service polls each machine for whether or not it is processing an assignment, and if it is not, then begin processing whichever assignment is in the queue that it is capable of processing.

    derobert : You didn't answer the question...
    hmcclungiii : From the last paragraph of his post - I don't necessarily need an optimal solution... just an attempt at something better than I have - it seems I often end up with tasks queued and machines idle which a better allocation could have avoided. Any suggestions most welcome. - I made an attempt.
    Chris : Much appreciated. I've currently got a good way to assign 'a' task, but I do have some choice over which to assign - at the moment I am just as likely to make a good choice as a bad one.
  • To get started, my preference is a "pull" model.

    Each machine pulls tasks from the central server when it's idle.

    The central server provides a kind of priority queue, with the packages in dependency order. Each machine makes a request from the central server and is allocated some work to do.

    You have a kind of pooling model, where you have task classifications, and pools of machines that have matching classifications. Machines in pool 1, for example, can build certain things. Machines in pool 2 can build anything. Think of them as "skills" and you'll see how this is a kind of project management issue.

    if you have really slow machines, you have to hand optimize them into a separate pool so they only get small branch things which have no dependencies.

    That may be all you need. However, if you want further optimization, here's your next step.

    After you have run it a few times -- and have some expectations for performance -- you can then write a module which attempts to keep each machine as busy as possible. This scheduling is precisely what things like Microsoft Project do.

    Given tasks, with durations and dependencies, you are attempts to do "resource leveling". You want each resource (compile client in your case) as busy as possible consistent with each client's skill set and productivity.

    Chris : Thanks for the ideas! I've flipped between pull and push a couple of times - either way, I end up with good machines taking trivial jobs while bad machines get the bottlenecks. "Keep each machine as busy as possible" is an easy metric to add. I'll give it a try - thanks!
  • The problem you are trying to solve is equivalent to the classic Job Shop Scheduling problem. Finding an optimal schedule is NP-hard.

    People have invented lots of heuristics to generate schedules, but which ones are good is highly problem-dependent.

    A couple of common heuristics are:

    • Schedule the shortest task first.
    • Schedule the most highly constrained task first, e.g., pick the task that can run on the fewest machines first.
    derobert : I'd additionally suggest scheduling the machine(s) with the most unique abilities last.
    leppie : NP hard and managerially impossible :)
    Chris : I expected NP-hard, so perhaps it's fortunate I don't have to schedule the whole job shop (I might get new machines or jobs). I think I can try both heuristics reasonably quickly, thank you for the suggestions!
    Chris : @derobert: "most unique abilities last" sounds like it contradicts "most highly constrained task first"... I'll try both.
    derobert : They don't contradict. It just means if you can dispatch job 7 to machine A/B/C (identical) or D (special), don't pick D.
    Chris : @derobert: Gotcha - that makes sense! Two ways of looking at the question, either "find a machine to run this job" or "find work for the machine to do".

Is the iPhone "cron-able"?

Note - I have not delved very deeply into Apple's iPhone SDK yet.

However, based on another question asked recently, I'm wondering if, since the iPhone is running some stripped-down edition of Mac OS X if it doesn't have a crontab feature.

If so, how would you access it?

Thanks.

From stackoverflow
  • http://hackint0sh.org/forum/showthread.php?t=31658

    Seems that cron runs by default on the iPhone, you just need to be able to edit the crontab file - either the root one or the user one but not the user one apparently.

    There are issues with sleep and cron, but there's a good discussion at that link.

    Kristopher Johnson : Is there any way to access crontab on an un-jailbroken iPhone?
    JeeBee : I don't believe so. Here's hoping that Apple will put timers and scheduled tasks into a future version of the iPhone OS / SDK, but for tasks that are network polling I think they will want you to use the push notifications feature in the next release.
  • The iPhone does run cron - but you won't be able to use it in any application developed solely with the SDK. There is absolutely no support for background process or background launching via alarms or timers (e.g. crontab).

  • You can't use cron on an un-jailbroken iPhone.

    Maybe you could take advantage of the Push Notification service: Have cron (or some other scheduler) running on another machine which sends notifications to the phone at the appropriate time.

    Epsilon Prime : And hope that you don't have an application like one I shelved that requires waking up every minute!

How do I Reference an Embedded Resource in Silverlight 2

I have the following simple button with an image as the template. The problem is that I want to change the image to a resource, instead of a content reference. I want to do this so I can share the DLL as a re-usable library, and it doesn't work well when I do that.

How do I tell the Image object to use an embedded resource in a declarative way?

<Button x:Name="LogoutButton" Click="Button_Click">
  <Button.Template>
    <ControlTemplate>
      <Image Source="Resources/logout.png" />
    </ControlTemplate>
  </Button.Template>
</Button>
From stackoverflow
  • Ok, I figured it out:

    1. Don't make it an embedded resource. Make it a Resource/Do Not Copy

    That is all there is to it. Reference it like you would a content path, and it works.

How do I resolve: "error C2039: '{ctor}' : is not a member of" in Visual Studio 2005?

I am extending a template class using C++ in Visual Studio 2005. It is giving me an error when I try to extend the template base class with:

template <class K, class D>
class RedBlackTreeOGL : public RedBlackTree<K, D>::RedBlackTree  // Error 1
{
 public:
  RedBlackTreeOGL();
  ~RedBlackTreeOGL();

and a second error when I try to instantiate the object:

RedBlackTreeOGL<double, std::string> *tree = new RedBlackTreeOGL<double, std::string>; // error 2

Error 1:

**redblacktreeopengl.hpp(27) : error C2039: '{ctor}' : is not a member of 'RedBlackTree' with [ K=double, D=std::string ] **

Error 2:

main.cpp(50) : see reference to class template instantiation 'RedBlackTreeOGL' being compiled

From stackoverflow
  • Does RedBlackTree<K, D>::RedBlackTree have a default constructor? C++ doesnt define a default constructor by itself if you have other parameterized constructors (ctors).

  • @SDX2000:

    Yes, I have defined a constructor in RedBlackTree::RedBlackTree:

    template <class K, class D>
    class RedBlackTree
        {
        public:
            RedBlackTree();
            // Deleting a storage object clears all remaining nodes
            ~RedBlackTree();
    

    I have also implemented a body for the constuctor and destructor for RedBlackTree class

  • The code is trying to inherit a constructor, not a class :-)

    The start of the class declaration should be

    template <class K, class D>
    class RedBlackTreeOGL : public RedBlackTree<K, D>
    
  • OMG, I feel so silly..... been looking at my own code for far too long!

    Thats a pretty basic thing and I dont know how i missed it!

    Thank you James (and SDX2000) this worked by taking the "constructor" off the end of the declaration to what James said.

    Thank you :)

    SDX2000 : Hey stuff happens! I thought RedBlackTree was an inner class but missed the fact that the outer class had the same name as the inner class which is not possible hence the second RedBlackTree was the ctor.

Multiline tooltipText

I am trying to have a tooltip on multiple lines. how do i do this?

From stackoverflow

asp.net mvc: How to handle situation when error happens during posting form from view user control?

I have a view user control that can post form. This control can be used on multiple views. If user enters invalid data i add errors to ModelState - as simple as that. The problem is that i don't know which view/actionresult to return since i don't know from where user post form. Ok, i can get urlreferer - but that does not look nice for me. Any idea?

From stackoverflow
  • Pass the info from your parent page to the controller.

    <% RenderPartial("MyUserControl", new MyUserControlViewData()
    {
        // pass parent page info here for user control to redirect to such as
        Controller = "Home",
        Action = "Index"
    
       // or even better
       ParentPath = ((WebFormView)this.ViewContext.View).ViewPath
    });
    
    michal zygula : thanks - great answer...

F# winforms MenuStrip problem: Not sure how to get a handle on DropDownItems

I have recently started learning F#, and this is the first time I've ever used WinForms. Here is my code.

#light
open System
open System.Windows.Forms
let form =
    let temp = new Form()
    let ms = new MenuStrip()
    let file = new ToolStripDropDownButton("File")
    ignore(ms.Items.Add(file))
    ignore(file.DropDownItems.Add("TestItem")) \\Code of importance
    let things _ _ = ignore(MessageBox.Show("Hai"))
    let handle = new EventHandler(things)
    ignore(file.Click.AddHandler(handle))
    let stuff _ _ = ignore(MessageBox.Show("Hai thar."))
    let handler = new EventHandler(stuff)
    let myButton = new Button(Text = "My button :>", Left = 8, Top = 100, Width = 80)
    myButton.Click.AddHandler(handler)
    let dc c = (c :> Control)
    temp.Controls.AddRange([| dc myButton; dc ms |]);
    temp
do Application.Run(form)

What the problem is, I can't seem to figure out how I would get a handle on the DropDownItems item so that I could use it. I'm sure it's something simple, but I haven't been using F# for that long. Thanks for any help.

edit: I'd also like to point out that I know there are alot of ugly syntax in that block of code, but the whole thing is just a test form I've been using.

From stackoverflow
  • I think you just need to

    let ddi = file.DropDownItems.Add("TestItem") //Code of importance
    

    The problem is that you are ignoring the result of the Add() call, which returns the added item.

    Note also that it's more idiomatic to say

    yadda |> ignore
    

    rather than

    ignore(yadda)
    
    Rayne : Thank you for the answer, sorry for not besting it sooner. I was so tired that day I wasn't even thinking. Sorry for such a stupid question.

Webapp development tools for Blackberry

I am looking for a good Environment (GUI based Editor) for blackberry webapps. e.g., is there a Eclipse plugin out there ?

From stackoverflow
  • The Blackberry Applications are developed in Java and RIM provides the needed tools and simulators here: http://na.blackberry.com/eng/developers/resources/devtools.jsp

  • In my opinion, and experience, using a GUI based editor for any kind of web development is a Very Bad Idea. Get to know HTML and CSS, write your own JavaScript. There isn't a WYSIWYG editor out there that can generate markup as good as I can by hand.

    Of course, the part were tools come in is testing. And getting to know the paricular inconsistencies of your platform. In that instance, check out:

    You'll also want to test, test and test. For that, grab yourself the full range of BlackBerry emualtors.

  • From my experience it seems that many BlackBerries have CSS and JS turned off by default, and quality of CSS and JS support (before 4.6 software) is just appalling.

    You're stuck with very basic HTML forms and linear layout. There's nothing that visual editors can do with this.

How do you remove obsolete publications in the Replication Monitor?

Through some bungling in creating and removing publications, I was left with a lot of obsolete publications which for some reason still remains in the Replication Monitor.

How do you remove these publications? It doesn't seem to have a clear way to remove them.

From stackoverflow
  • This is an old question of mine, but then again at least I found a way to resolve it.

    I was able to remove the publications is by creating a new publication with the same name, then delete the publication again. This time the publication will no longer appear in the Replication Monitor. I did not remember if the publication has to be the same type as the obsoleted one, but it works.

    UPDATE: Okay, the publication type and database name is important, otherwise the newly created publication will be considered as a different publication. Kinda obvious, but now I'm sure of it.

Soap Web Service Calls from SQL Server

I'm not entirely sure if this is possible, but does anyone know how, or if you can make calls to a SOAP web service from SQL Server? Seems like it might be good performance-wise in the area of data sync applications. I feel like this might be a long shot though.

Thanks.

From stackoverflow
  • If you're using SQL Server 2005 or higher, you can call a Web service by creating a CLR Procedure that does the task.

  • Creating a CLR based call is pretty tedious and not really recommended. why do you want to do this? maybe we can provide another option.

    Wes P : I don't think there is another option. I'm basically looking into it because a client of ours said they wanted to use our web service and they don't know anything of .NET programming, all they know is SQL Server. I was seeing if it was even possible to achieve.
  • You may want to refer to this stackoverflow question: SQL Server - Using CLR integration to consume a Web Service

How to Intercept connection requests?

Hello, I'm working on an app that needs to intercept when a program tries to connect to an specified IP address and redirects it to another IP.

Is this possible?

I'm using .net for this.

thanks!

From stackoverflow
  • Your best bet is to use EasyHook project to hook the connect function.

  • It might not fit the bill, but you could use the "hosts" file. ("hosts" file will only work for this purpose if the program is not connecting by IP address, but a host name)

Castle ActiveRecord - Determining connectionstrings during runtime

When using Castle ActiveRecord, is it possible to determine during runtime which connection string to use?

As I understand it, ActiveRecord has to be initialized only once during the application's lifetime and this means that database connection strings have to be configured prior to initialization.

However, is it still possible to determine connection strings during run time - i.e. what if the web app does not know which database to use until after the user has logged in?

From stackoverflow
  • Check out DifferentDatabaseScope

    Mauricio Scheffer : ActiveRecord FAQ: http://using.castleproject.org/display/AR/FAQ

PHP: exec() error responses?

Below is the command I tried executing, without success:

exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess');

When you add a die() at the end, it catches that there's an error:

exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess') or die('what?!');

For the above exec() statement, a permissions problem is causing the error, but PHP isn't displaying it. How do you display from PHP what error is occurring?

From stackoverflow
  • You can receive the output result of the exec function by passing an optional second parameter:

    exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess',$output);
    var_dump($output);
    

parsing a line in bash

Hi could you please help me parse the following in bash.

i have a file that has one entry per line, and each line has the following format.

 "group:permissions:users"

where permissions and users could have more than one value separated by comas... like this

 "grp1:create,delete:yo,el,ella"

what i want is to return the following

yo
el
ella

i came up with this..

cat file | grep grp1 -w | cut -f3 -d: | cut -d "," -f 2

This returns "yo,el.ella", any ideas how can i make it return one value per line?

Thanks

From stackoverflow
  • You can use awk, with the -F option to use : as the field separator:

    [user@host]$ echo "grp1:create,delete:yo,el,ella" | awk -F ':' '{print $3}'
    yo,el,ella
    

    That will get you just the users string, separated by commas. Then you can do whatever you want with that string. If you want to literally print each user one per line, you could use tr to replace the commas with newlines:

    [user@host]$ echo "grp1:create,delete:yo,el,ella" | awk -F ':' '{print $3}' | tr ',' '\n'
    yo
    el
    ella
    
    Alan FL : thank you that will do. it never crossed my ming to use awk.... thanks again
    Jay : sure thing...it's probably doable with *just* awk, but my awk-fu is severely limited ;)
    Johannes Schaub - litb : haha exactly what i would have answered too. +1
  • Here's one way to do it entirely in a shell script. You just need to change IFS to get it to break "words" on the right characters. Note: This will not handle escapes (e.g. "\:" in some file formats) at all.

    This is written to allow you to do:

    cat file | name-of-script
    

    The script:

    #!/bin/bash
    while IFS=: read group permissions users; do
      if [ "$group" = "grp1" ]; then
        IFS=,
        set -- $users
        while [ $# -ne 0 ]; do
          echo $1
          shift
        done
      fi
    done
    

how to access div tags of user control in master page

Can we access div tags of user control in Master page? I am trying to change the background color for each one of the div tags on some event.

From stackoverflow
  • The best way is to make a public property in the user control that you can then set directly from the masterpage.

    alice7 : I am trying to set the property from master page but nothing is happening to back ground color of div tag
  • Something like this should work (in C#):

    Control myControl = this.Page.Master.FindControl("[Your name here]");

    then you can do whatever you would like to the control. If it's a Panel control (for the div) you can cast it that way, or if you are using an HTML server side control, you can cast it that way.

  • this totally looks like yet another job for jQuery

How do you compute the XOR Remainder used in CRC?

I'm trying to remember how the math is worked out to compute the remainder of an XOR algorithm in Cyclical Redundancy Checks to verify the remainder bits of a network message.

I shouldn't have tossed that text book.

This is easily done in code, but how is it worked out by hand?

I know it looks something like a standard division algorithm, but I can't remember where to go from there to get the remainder.

      ___________
1010 | 101101000

Note: I did google it, but wasn't able to find a place where they mapped the steps in figuring the remainder.

From stackoverflow
  • It is long division by binary 11. There is an example on Wikipedia.

Filter services when calling Get-Service

Hi,

I did this in the past, and can't remember the correct command (I think I was using instring or soemthign?)

I want to list all the windows services running that have the word 'sql' in them.

Listing all the windows services is:

Get-Service

Is there a instring function that does this?

From stackoverflow
  • Get-Service -Name *sql*
    

    A longer alternative would be:

    Get-Service | where-object {$_.name -like '*sql*'}
    

    Many cmdlets offer built in filtering and support wildcards. If you check the help files (Get-Help Get-Service -full), you will see

     -name <string[]>
         Specifies the service names of services to be retrieved. Wildcards are
         permitted. By default, Get-Service gets all of the services on the comp
         uter.
    
         Required?                    false
         Position?                    1
         Default value                *
         Accept pipeline input?       true (ByValue, ByPropertyName)
         Accept wildcard characters?  true
    

    Usually if filtering is built in to the cmdlet, that is the preferred way to go, since it is often faster and more efficient.
    In this case, there might not be too much of a performance benefit, but in V2, where you could be pulling services from a remote computer and filtering there would be the preferred method (less data to send back to the calling computer).

How to find unclosed connection? Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

I've had this problem before and found that basically I've got a connection that I'm not closing quickly enough (leaving connections open and waiting for garbage collection isn't really a best practice).

Now I'm getting it again but I can't seem to find where I'm leaving my connections open. By the time is see the error the database has cleared out the old connections so I can't see all the locked up connections last command (very helpful last time I had this issue).

Any idea how I could instrument my code or database to track what's going on so I can find my offending piece of code?

From stackoverflow
  • The error you are providing doesnt really point to a connection that is left open; it is more likely that there is a query that is taking longer than the application expects. you can increase the time it waits for a response, and you could use Sql to find which queries are the most taxing.

  • Hopefully you have one data access layer class, instead of a whole bunch of classes, each one creating its own connection, right? What language are you using? If your using C#, the biggest cause of this problem is DataReaders and returning these objects to the upper layers. Most likely some client class is not closing the DataReader it received from your DAL class, leaving the connection open/locked for who knows how long. Track down the DataReaders you're returning and make sure your client classes are closing/disposing of them properly.

    I'd also start thinking about redesigning your data access layer by implementing Disposable pattern and possibly returning POCOs instead of Data (...Tables, ...Sets, ...Readers) objects.

  • Unfortunately I don't have my Data Access Layer and my business objects neatly sorted.

    I do always use DataAdapters to dump my data directly into a DataTable, then manipulate from there.

    The reason I know this because I have connections left open is that when I look at the stack trace for the error it's occurring when attempting to open a new connection.

    Is there anyway to track connections in SQL server? Is my only solution doing a find all on .Open() to see where I might have forgotten a .Close() or to add error handling to close the connection on an exception?

Response.Flush not working ASP.NET

I have an aspx page where i am Processing a large number of records from a table and doing some manipulation.after each manipuation,(each record),I have a Response.Write("Record : "+rec); Response.Flush()

I have set Response.Buffer property to false. It is working fine But If i want to render the output as a table row,its not working as of Response.Write After fininshing all the records in the loop only , the table is getting printed

How to solve this ?

From stackoverflow
  • Most browsers will not render tables until the table is complete. You can try making the table fixed format, css table-layout: fixed, along with specifying column sizes.

  • I will add to Darryl answer that you can close the table as soon as posible and then fill the rest of the table using JQuery or similar.

  • I would guess that the table doesn't exist from the browser's perspective until you write out the end table tag.

    You could write out a bunch of divs with a stylesheet controlling their width.

    .column1 { width: 40px; }
    .column2 { width: 40px; }
    
    Response.Write("<div id=\"column1\">some text</div><div id=\"column2\">some text</div>");
    Response.Flush();
    

    Or you could write out an entire table for each row...?

    Response.Write("<table><tr><td>some text</td></tr></table>");
    Response.Flush();
    
  • Definately the table. To prove this to yourself, change your table-markup-oriented response.Write()s to just plain text. you'll see it accumulate. If the table has to be this big and you want to render it from the server, you should fix the column sizes and break the table up into one-per-row or some other subset so content appears gradually as you want.

  • For anyone else having this problem...

    Be aware that if your IIS server is compressing the output with GZIP, then it will seem to ignore all Response.Flush calls. This is turned on by default in IIS7 and on Windows 7.

    And, if you are testing with Fiddler, be sure to turn on "Streaming" mode, or Fiddler will collect the flushed HTML and hold it until the connection is completed.

Advanced Search Form Validation in asp.net

I'm looking to make validation for a page in which one or more fields have a value in them. I have an advanced search form in asp.net and I'm trying to pop up an error and not post back if all the fields are empty. I've looked into required fields validators but I'm not sure how to make them work together in a AND type fashion instead of the OR fashion that a validation group of required field validators would imply. I hope this makes sense. Thanks for the help.

From stackoverflow
  • You could just write the javascript validation function yourself to handle this case and attach it to your search button.

  • i had to do something similar years ago and i was using 1.1 then. what we ended up doing was creating required field validators but disabling them. then onload we would loop through the validator dictionary, enable them and check if they passed. if any of them passed we broke off the loop and we continued execution, otherwise, if all of them failed then we displayed a warning. Unfortunately, this would require a postback.

    If you want to accomplish this on the client-side then you could write a simple javascript function to take care of it before postback. for every control, place an onBlur event. javascript will check if there is a value in the field and maintain a flag. then before submission you would check the flag and either allow submission or show warning.

    Cptcecil : Thanks alot, that was really bugging me. That will help me on alot of projects I think.

Resize Encrypted Windows Partition

Recently my company forced a roll out of SafeBoot. The problem is that I was using Ubuntu under Wubi. Since the whole drive is encrypted now, I can't boot into Ubuntu. I was hoping to create a new partition for Ubuntu so I could still use it. I know there are partition tools available, but I've never used one on an encrypted disk. Are programs like Partition Magic or a free one like EASEUS safe to use on an encrypted HDD?

From stackoverflow
  • No, a partition resizer must actually modify the underlying file system. Because the drive is encrypted, you would need a 'SafeBoot' aware partition resizer. I don't know of any.

  • I have the exact same situation. After a long search I found its not possible to resize an encrypted partition.

    I am using an external harddisk / Flash Drive for ubuntu. After changing the boot sequence in the bios its possible now to dual boot ubuntu and windows.

    Running from Thumb drive, Ubuntu's Speed is not very bad either.

Network Drive label

Hello, I'm trying to get the label of some network resources mapped as drives. When I use DriveInfo.GetDrives(), local volumes have the VolumeLabel filled parameter as expected, but in network drives it is an empty string. How can I get those labels?

From stackoverflow

string to binary[]

I have a string I need to feed to a com object that has a LoadFromStream method accepting "object Data". I'm guessing this should be a byte[].

Rather basic question: I got my MemoryStream all filled and ready to go. What's the best way to convert it to binary[]? Should I manually read it into the array one by one or is there an easy built in way?

From stackoverflow
  • MemoryStream has a ToArray() method which returns a byte[].

    borisCallens : Doh, once again I miss the obvious :P

How can we combine images and get image object from this two images in iphone apps

Hi,

How can we combine two images means i have two images and one small and another is big one. i want to combine small image into big one image at a specific CGPoint and i need object of UIImage. I have tried with CGCreateImageFromMask like that thats spread small image to whole portion of big image.

Plsssss anyone help me.....

Thanks.

From stackoverflow
  • You'll want to use UIGraphicsBeginImageContext() to generate a CGContextRef, then use UIGraphicsGetCurrentContext() to get a reference to it. Now draw your current images into the context. When you're done, use UIGraphicsGetImageFromCurrentContext() to generate an UIImage from that context, and UIGraphicsEndImageContext() to clean up.

    See Apple's UIKit Function Reference doc.

  • Have a look at this question stitch-picture-in-iphone

Searching phrases in Lucene

Could somebody point me to an example how to search for phrases with Lucene.net?

Let's say I have in my index a document with field "name", value "Jon Skeet". Now I want to be able to find that document when searching for "jon skeet".

From stackoverflow
  • You can use a proximity search to find terms within a certain distance of each other. The Lucene query syntax looks like this "jon skeet"~3, meaning find "jon" and "skeet" within three words of each other. With this syntax, relative order doesn't matter; "jon q. skeet", "skeet, q. jon", and "jon skeet" would all match.

    If you have a list of phrases that you want to treat as a single token, you need to take care of that in your analyzer. For instance, you want to treat "near east", "middle east", and "far east" as individual tokens. You need to write an analyzer with some lookahead, so that it can treat these phrases as if they were one word. This analyzer is used both in the indexer, and against user input in the search application.

lptstr to char*

Would anyone hapen to know how to convert a LPTSTR to a char* in c++?

Thanks in advance, workinprogress.

From stackoverflow
  • Here are a lot of ways to do this. MFC or ATL's CString, ATL macros, or Win32 API.

    LPTSTR szString = _T("Testing");
    char* pBuffer;
    

    You can use ATL macros to convert:

    USES_CONVERSION;
    pBuffer = T2A(szString);
    

    CString:

    CStringA cstrText(szString);
    

    or the Win32 API WideCharToMultiByte if UNICODE is defined.

  • Depends if it is Unicode or not it appears. LPTSTR is char* if not Unicode, or w_char* if so.

    Discussed better here (accepted answer worth reading)

  • char * pCopy = NULL;
    if (sizeof(TCHAR) == sizeof(char))
    {
        size_t size = strlen(pOriginal);
        pCopy = new char[size + 1];
        strcpy(pCopy, pOriginal);
    }
    else
    {
        size_t size = wcstombs(NULL, pOriginal, 0);
        pCopy = new char[size + 1];
        wcstombs(pCopy, pOriginal, size + 1);
    }
    
  • Thanks for the help!

Access VBA:To generate a report of result of update query

hi,

Is it possibel to get a report of the records that are updated using a update query.I mean without using recordset. suppose sqltext = update table employees set bonus = 0 where salary > 50000 DoCmd.RunSQL sqltext

now after theis query runs is it possible to get the name of th eemployees for whom this update query was performed.

Thanks

From stackoverflow
  • I don't see any way at this time to get the information after the update query has run unless you have another distinguishing field (maybe an updated date field). Why not run a select query for it and run a report off of that data, THEN run the update query to change the values for 'bonus'.

    Let me know if this helps! JFV

    tksy : i am not sure about this method as there are chances updates on certain records may fail to haapen but they may be picked up by the select query
    JFV : As long as the data is not highly volatile, the 'Select' and the 'Update' should return the same records. If the 'Update' fails, then you might have some other issues with the data.
    Patrick Cuff : You can open the Access database for exclusive access to run the select and update, just to make sure nobody got in and changed data on you between queries.
  • It's never a good idea to use DoCmd.RunSQL as it generates a prompt (which you have to turn off if you don't want it), and it completes the updates even if errors occur, and doesn't report the errors. Much better is to replace it with a function that executes the same SQL:

    Public Function SQLRun(strSQL As String) As Boolean
    On Error GoTo errHandler
    
      CurrentDB.Execute strSQL, dbFailOnError
      SQLRun= True
    
    exitRoutine:
      Exit Function
    
    errHandler:
      MsgBox err.Number & ": " & err.Description, vbExclamation, "Error in SQLRun()"
      Resume exitRoutine
    End Function
    

    Once you've placed this in a public module, you can easily do a global search and replace for "DoCmd.RunSQL" to replace it with "SQLRun".

    EDIT: Another version of this function that returns the number of records affected is here:

    http://stackoverflow.com/questions/343396/acess-vba-to-get-value-from-update-query-prompt/348453#348453

multiple CComboBox sharing the same data.

I have a MFC dialog with 32 CComboBoxes on it that all have the same data in the listbox. Its taking a while to come up, and it looks like part of the delay is the time I need to spend using InsertString() to add all the data to the 32 controls. How can I subclass CComboBox so that the 32 instances share the same data?

From stackoverflow
  • Turn off window redrawing when filling the combos. e.g.:

    m_wndCombo.SetRedraw(FALSE);
    // Fill combo here
    ...
    m_wndCombo.SetRedraw(TRUE);
    m_wndCombo.Invalidate();
    

    This might help.

    grepsedawk : I think you will need to make sure you call Invalidate after doing this.
    Rob : Not if calling from WM_INITDIALOG IIRC, but well spotted. :)
    baash05 : fixing the symptom but not answering the question.
  • The first thing I would try is calling "InitStorage" to preallocate the internal memory for the strings. From MSDN:

    // Initialize the storage of the combo box to be 256 strings with // about 10 characters per string, performance improvement.

    int n = pmyComboBox->InitStorage(256, 10);

  • In addition to what has already been said, you might also turn off sorting in your combo box and presort the data before you insert it.

  • One way along the lines of your request would be to go owner drawn - you will be writing a fair chunk of code, but you won't have to add the data to all of them. "CComboBox::DrawItem"

    Support.microsoft have this article on subclassing a Combo box which might also be of interest "How to subclass CListBox and Cedit inside of CComboBox"

    Really one has to ask if it is worth the effort, and alot of that depends things like

    • number of entries in the list
    • number of times the dialog will show
    • variability of the combo content
    • optomising elsewhere
      • not drawing until the screen is complete
      • only building the dialog once and re showing it.
      • using the one combo but showing it in different locations at different times

Should we introduce BizTalk/ESB?

My company are about to implement a new architecture in which we have proposed BizTalk (we are a Microsoft shop) as the Enterprise Service Bus (ESB) in a SOA (please don't quote Service Oriented Ambiguity) environment.

Our business is to take Orders through our new Order Capture GUI which must connect to our Customers Database, Product Catalogue, Ordering System and some other ancillary systems each of which will be exposed as WCF services, orders are then passed to our Order Management and other downstream systems for fulfilment and finally to our Billing system for invoicing. Currently each system has its own GUI and uses manual process to pass information between them, in an effort to automate and integrate the natural thought was to introduce an ESB to connect them.

Some of my rationale for an ESB is, the bus will worry about how to connect the systems (each system is agnostic and knows nothing of any other system) and how to format/translate the information. It is highly likely that in the future some of the existing systems will be swapped out for new systems or systems within our family of companies.

This seems to make sense to me but I am now being met with some resistance as to why introduce it when a Point-to-Point solution could suffice.

Unfortunately in the company history (prior to my appointment) an initial attempt to introduce BizTalk failed, but I am confident that it has a place and I can deliver it.

My question is perhaps not so much about BizTalk but whether an ESB is a good idea in my scenario described, when does it make sense to introduce an ESB?

From stackoverflow
  • I think it makes sense to have a data broker based on the requirements you described, but I personally don't think that BizTalk would be the best choice in your situation. For the type of integration you've described, I would look at a hardware data broker appliance. Some that I've seen work well are IBM DataPower, Vordel's appliance, and Layer7's appliance. For the type of calls you'll be using this for, an appliance is ideal. They provide routing, transformation, and translation, plus they'll protect against things like schema poisoning. They'll also handle authorization, authentication, and auditing by linking it to your user store (I'm guessing you have an Active Directory user store based on the environment you described, but it will also work with LDAP)

    An appliance will be BizTalk or any other software solution in terms of cost of ownership (no support costs), and the performance of any appliance will likely beat BizTalk by an order of magnitude.

  • Okay. ESB Guidance on Biztalk from the presrciptive architechture group - http://msdn.microsoft.com/en-us/library/cc487894.aspx

    We use BizTalk where I work to do a lot of things. He have some simple point intgerations. We have some more complicated point integrations with hihgly customized adpaters and pipelines. We have divisional enterprise system integrations for customer master, product info and price and quote to order. These are all seperate BizTalk applications. Some quite small and some quite large. We mainly have used BizTalk to do point to point/many point slutions without using an ESB pattern. The implementation of an ESB implies a level of governance of the bus itself and the enterpise message standars that will be permitted on the bus. If you will be interfacing with a large number of systems with a large number of different formats - ESB makes a lot of sense. If the integrations you want to achieve are less ambitious, an ESB may be overkill. That being said, it's a clean and extensible architechture. You'll have to make the cost value decision.

    BizTalk is also a complicated beast but with allof the moving parts comes a level of flexibility that is wonderful. But be prepared for a learning curve or some consultant costs.

  • I tend to avoid the ESB term as I believe it is grossly overloaded; at the end of the day, in all the various descriptions I've heared, it is just a pattern, once which BizTalk supports very well.

    So - do I think BizTalk will fit what you wish to do? categorically yes. Do I think you're right to avoid point to point connections - also yes, but, like with any refactoring exercise for reuse, including any SOA initiative, you must consider how much change and now much re-use you expect to decide how far you're taking you're "decoupling" exercise.

  • It's a very distinct pattern. Typically when you are sending amessage from System A to System B, you do a direct conversion from the format of System A to the format System B wants. When you have an ESB, You convert System A's Message to the ESB Format (ie., generic PO, Order, etc.) and then into the Format required by System B. It's a two conversion versus 1 and also, the bus pattern requires every messag eto have a verb (ie. add, delete, update, etc.). This is a real important distinction and is what makes ESB very useful in integrations with lots of participating systems.

  • You need to talk about latency and throughput. Everything else is just bla-bla.

  • I just got asked this same question by a colleague and this is what I said to him:

    In most integration scenarios you can go quite far before using something like BizTalk. I would make sure that I couldn’t do the integration more simply before going with BizTalk.

    Only if it seems that the integration solution needs to scale to high volumes with low latency (it’s got a fantastic asynchronous publish-subscribe mechanism), and you need fault tolerance (it’s got redundancy, scaling and message retry features) and governance over the solution (it’s got Business Activity Monitoring) would you really have strong arguments to consider using BizTalk. And if you know that there are multiple future integrations that will be needed then it gets really compelling to use BizTalk.

    On the other hand you need to make sure the skills are available to operate the thing. It takes a while to learn and a paradigm shift for the developers of the systems. However its built from the ground up in .NET and SQL Server so there is quite a lot of familiarity in the tooling and concepts.

    I think the key thing is to get the conceptual architecture of a solution right taking into account the non-functional requirements like performance, availability, extensibility, resilience, robustness, and scalability and making sure they are properly addressed by the technical design. You may find its cheaper to pay the 35k$ per CPU license for what BizTalk gives you out the box than to develop for all these NFRs.

    Also I've recently implemented the new ESB Toolkit 2.0 at a client and am very happy with it. The Itinerary (see the Routing Slip pattern http://www.enterpriseintegrationpatterns.com/RoutingTable.html) processing functionality really makes composing web services easy, flexibly and fast.