instruction stringlengths 0 30k ⌀ |
|---|
I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process. (Executing os.getcwd() returns the original starting script's filepath not the current file's.) |
I am trying to implement an "out of proc" COM server written in C#. How do I do this?
I need the C# code to be "out of proc" from my main C++ application, because I cannot load the .NET runtime into my main process space. |
I am trying to implement an "out of proc" COM server written in C#. How do I do this?
I need the C# code to be "out of proc" from my main C++ application, because I cannot load the .NET runtime into my main process space (WHY?: My C++ code is in a DLL that is loaded into many different customer EXE's, some of which use different versions of the .NET runtime. Since there can only be one runtime loaded into a single process, my best bet seems to be to put my C# code into another process.) |
Try this (XSLT 2.0):
<xsl:template match="/STORIES/STORY">
<component>
<xsl:if test="boolean(ARTICLEBODY)">
<xsl:call-template name="insert_paras">
<xsl:with-param name="text" select="ARTICLEBODY/text()"/>
</xsl:call-template>
</xsl:if>
</component>
</xsl:template>
<xsl:template name="insert_paras">
<xsl:param name="text" />
<xsl:variable name="regex">
<xsl:text> ( |\s)*</xsl:text>
</xsl:variable>
<xsl:variable name="tokenized-text" select="tokenize($text, $regex)"/>
<xsl:for-each select="$tokenized-text">
<p>
<xsl:value-of select="."/>
</p>
</xsl:for-each>
</xsl:template>
It's generally a bad idea to use literal strings to put in XML markup, since you can't guarantee that the results are balanced.
|
Broadcast like UDP with the reliability of TCP |
|.net|networking|tcp|udp| |
I'm working on a .net solution that is run completely inside a single network. When users make a change to the system, I want to launch an announcement and have everyone else hear it and act accordingly. Is there a way that we can broadcast out messages like this (like UDP will let you do) while keeping guaranteed delivery (like TCP)?
This is on a small network (30ish clients), if that would make a difference. |
answered in question. |
Note: single quotes (even no quotes, if the value doesn't contain a space) is valid according to [the W3C HTML spec][1]. Quote:
> By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39)... In certain cases, authors may specify the value of an attribute without any quotation marks.
Also, don't forget that the order of attributes can be reversed and that other attributes can appear in the tag.
[1]: http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.2 |
Using Virtual PC for Web Development with Oracle |
|virtual-pc|performance| |
I'm new to the Virtual PC party. I was recently introduced to it while working on a small WinForms application and it has been wonderful. I would love to use it when I go back to my real job, which is far more resource intensive. Namely, maintaining and extending multiple very large websites, in Visual Studio 2003 and 2005, each of which connects to its own fairly large Oracle database.
I have thoroughly enjoyed using WinForms because Visual Studio is so much more performant than with WebForms, and also there is not that horrendous delay when you bring a form up after a recompile. Anything that slows things down even more is not going to be helpful.
Thanks,
Mike |
I'm assuming that you're referring to IIS 6.
Instead of disabling shutdown altogether, maybe you can just increase the amount of time it waits before killing the process. The server is essentially conserving resources - if your server can stand the resource allocation for a process that mostly sits around doing nothing, then there isn't any harm in letting it be.
As you mentioned, setting the auto-recycling of the process on a memory limit would be a good idea, if the possibility of a memory leak is there. |
If you like ASP, and want to move to ASP.NET, skip Webforms and learn MVC. |
One way you could do that is to wire up an Application.Load handler in Application.Init, then have that handler unbind itself after running:
Sys.Application.add_init(AppInit);
function AppInit() {
Sys.Application.add_load(RunOnce);
}
function RunOnce() {
// This will only happen once per GET request to the page.
Sys.Application.remove_load(RunOnce);
}
That will execute after Application.Init. It should be the last thing before pageLoad is called. |
Performance, scalability, and a framework that provides a much better foundation for the stateless world of web applications, for a start.
[Wikipedia's ASP.Net page has a full section][1] on the differences.
[1]: http://en.wikipedia.org/wiki/ASP.NET#ASP.NET_compared_to_ASP_classic |
Performance, scalability, and a framework that provides a much better foundation for the stateless world of web applications, for a start.
[Wikipedia's ASP.Net page has a section][1] on the differences.
[1]: http://en.wikipedia.org/wiki/ASP.NET#ASP.NET_compared_to_ASP_classic |
I think Henk nailed it with the "no sttatic access to the type system" thing
Another option is that there is no order to types where as numerics and strings can be. Thus a type switch would can't build a binary search tree, just a linear search. |
The biggest issue for me is that I create applications, not websites...The UI is a minor part of the problem, the big part is writing the business logic layer, and various enterprise communication components (Connecting to SAP using SOAP? No Problem!).
The .NET Toolkit allows me to program in a wonderful object oriented language (C#) and has a robust framework to help out.
VbScript is a godawful language to try and write a business application in.
However, if all you do is a simple little webform, then sure, use VbScript.
As far as your link, it basically boils down:
* WaaWaa, I don't like Visual Studio
* WaaWaa, I want to edit production code on the production server like an idiot.
* WaaWaa, I don't know that deploying a single compiled DLL is all that a small site needs to deploy a asp.net app.
Basicly, its ignorance in a nutshell.
|
I have seen this a lot, some of our modules link in excess of a 100 libraries of our code plus system & 3rd party libs.
Depending on different linkers HP/Intel/GCC/SUN/SGI/IBM/etc you can get unresolved functions/variables etc, on some platforms you have to list libraries twice.
For the most part we use structured hierarchy of libraries, core, platform, different layers of abstraction, but for some systems you still have to play with the order in the link command.
Once you hit upon a solution document it so the next developer does not have to work it out again.
My old lecture used to say, "*high cohesion & low coupling*", it’s still true today.
|
In Python, how do I get the path and name of the file that is currently executing? |
|python|file|scripting| |
I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process.
For example, let's say I have three files. Using 'execfile', script_1.py calls script_2.py. In turn, script_2.py calls script_3.py. How can I get the file name and path of **script_3.py** without having to pass it as args from script_2.py?
(Executing os.getcwd() returns the original starting script's filepath not the current file's.) |
I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process.
For example, let's say I have three files. Using 'execfile', script_1.py calls script_2.py. In turn, script_2.py calls script_3.py. How can I get the file name and path of **script_3.py** *from code within script_3.py* without having to pass that info as args from script_2.py?
(Executing os.getcwd() returns the original starting script's filepath not the current file's.) |
Other ways to encrypt WCF Connections |
|c#|security|wcf| |
I'm currently working on a project that requires encrypted data be passed between WCF hosts. As I understand it there are only 2 ways to ensure that data passed over WCF is secure.
1. Using Certificates
2. Using a Domain (or having the same username and password on every machine on the network)
Using certificates can be expensive and complicated to manage and since we're not guaranteed to have a server class machine at every deployment a Domain is also out of the question. Having every machine use the same username and password is also problematic if that password ever needs to be changed.
Currently we use OpenSSH to tunnel our connections between hosts. Is there another option built into the framework that I'm unaware of? |
I would think carefully about this since it may not be a necessary feature.
Why not just use a text field and let users type in an address?
Remember the [KISS principle][1] (Keep It Simple, Stupid).
[1]: http://en.wikipedia.org/wiki/KISS_principle
|
Use a hard-coded key to encrypt the generated key before writing it out. Then you can write it anywhere.
Yes you can find the hard-coded key, but so long as you're assuming it's OK to store a symmetric key *anywhere*, it's not less secure. |
How do you initialize a 2 dimensional array when you do not know the size |
|c#|array-initialize| |
I have a two dimensional array that I need to load data into. I know the width of the data (22 values) but I do not know the height.
I have it declared as follows:
float[,] _calibrationSet;
....
int calibrationRow = 0;
While (recordsToRead)
{
for (int i = 0; i < SensorCount; i++)
{
_calibrationSet[calibrationRow, i] = calibrationArrayView.ReadFloat();
}
calibrationRow++;
}
This causes a NullReferenceException, so when I try to initialize it like this:
_calibrationSet = new float[,];
I get an "Array creation must have array size or array initializer."
Thank you,
Keith |
The garbage collector runs the finalizer of the object at some indeterminate time.
You could implement the IDisposable interface and call the Dispose() method before the object looses Scope - or let the using statement do that for you.
see <http://msdn.microsoft.com/en-us/library/system.idisposable.aspx> and <http://msdn.microsoft.com/en-us/library/yh598w02.aspx> |
The garbage collector runs the finalizer of the object at some indeterminate time.
You could implement the IDisposable interface and call the Dispose() method before the object looses Scope - or let the using statement do that for you.
see <http://msdn.microsoft.com/en-us/library/system.idisposable.aspx> and <http://msdn.microsoft.com/en-us/library/yh598w02.aspx>
edit: works fine for me
<pre>
using System;
using System.Net.Sockets;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
class ClassA : IDisposable
{
protected Socket s;
public ClassA()
{
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Bind(new IPEndPoint(IPAddress.Any, 5678));
}
public void Dispose()
{
s.Close();
}
}
static void Main(string[] args)
{
using(ClassA a=new ClassA()) {
}
using (ClassA b = new ClassA())
{
}
}
}
}
</pre> |
In addition to that omer van kloeten's points.
The open source licence is MIT (comparable to BSD licence) this means that if you need make changes to the library you don't have to open-source the changes. (this might be a problem with some companies). For GPL-type licences this can be a problem. |
Sprint velocity calculations |
|project-management|agile|scrum|methodology| |
Need some advice on working out the team velocity for a sprint.
Our team normally consists of about 4 developers and 2 testers. The scrum master insists that every team member should contribute equally to the velocity calculation i.e. we should not distinguish between developers and testers when working out how much we can do in a sprint. The is correct according to Scrum, but here's the problem.
Despite suggestions to the contrary, testers never help with non-test tasks and developers never help with non-dev tasks, so we are not cross functional team members at all. Also, despite various suggestions, testers normally spend the first few days of each sprint waiting for something to test.
The end result is that typically we take on far more dev work than we actually have capacity for in the sprint. For example, the developers might contribute 20 days to the velocity calculation and the testers 10 days. If you add up the tasks after sprint planning though, dev tasks add up to 25 days and test tasks add up to 5 days.
How do you guys deal with this sort of situation? |
If cross platform support is important then I would second the suggestion to look at Qt. It supports Windows, Linux and the Mac. For free software it is free (there is a GPL version on Unix but not for Windows) but for comercial software it is not particulary cheap. There are now several books on Programming with Qt.
It does come with a large number of extra libraries for networking, parsing XML etc. It also has integration with Visual Studio on Windows.
One downside with Qt is that there are not as many add on libraries as with some other GUI frameworks. Ot will depend on the type of applications that you wish to write whether this is important to you or not. |
For my current PHP project we use the idea of rails migrations and we have a migrations directory in which we keep files title "migration_XX.sql" where XX is the number of the migration. Currently these files are created by hand as updates are made, but their creation could be easily modified.
Then we have a script called "Migration_watcher" which, as we are in pre-alpha, currently runs on every page load and checks whether there is a new migration_XX.sql file where XX is larger than the current migration version. If so it runs all migration_XX.sql files up to the largest number against the database and voila! schema changes are automated.
If you require the ability to revert the system would require a lot of tweaking, but it's simple and has been working very well for our fairly small team thus far. |
Yes your ideas will help.
Lean on option 1 if there are no reads happening while your loading.
Lean on option 2 if you destination table is being queried during your processing. |
Yes your ideas will help.
Lean on option 1 if there are no reads happening while your loading.
Lean on option 2 if you destination table is being queried during your processing.
@Andrew
Question. Your inserting in chunks of 300. What is the total amount your inserting? SQL server should be able to handle 300 plain old inserts very fast. |
“rusage” statistics |
|c++|unix|profiling| |
|c++|unix|time|profiling| |
I'm trying to use “rusage” statistics in my program to get data similar to that of the [time](http://en.wikipedia.org/wiki/Time_%28Unix%29) tool. However, I'm pretty sure that I'm doing something wrong. The values seem about right but can be a bit weird at times. I didn't find good resources online. Does somebody know how to do it better?
Sorry for the long code.
class StopWatch {
public:
void start() {
getrusage(RUSAGE_SELF, &m_begin);
gettimeofday(&m_tmbegin, 0);
}
void stop() {
getrusage(RUSAGE_SELF, &m_end);
gettimeofday(&m_tmend, 0);
timeval_sub(m_end.ru_utime, m_begin.ru_utime, m_diff.ru_utime);
timeval_sub(m_end.ru_stime, m_begin.ru_stime, m_diff.ru_stime);
timeval_sub(m_tmend, m_tmbegin, m_tmdiff);
}
void printf(std::ostream& out) const {
using namespace std;
timeval const& utime = m_diff.ru_utime;
timeval const& stime = m_diff.ru_stime;
format_time(out, utime);
out << "u ";
format_time(out, stime);
out << "s ";
format_time(out, m_tmdiff);
}
private:
rusage m_begin;
rusage m_end;
rusage m_diff;
timeval m_tmbegin;
timeval m_tmend;
timeval m_tmdiff;
static void timeval_add(timeval const& a, timeval const& b, timeval& ret) {
ret.tv_usec = a.tv_usec + b.tv_usec;
ret.tv_sec = a.tv_sec + b.tv_sec;
if (ret.tv_usec > 999999) {
ret.tv_usec -= 1000000;
++ret.tv_sec;
}
}
static void timeval_sub(timeval const& a, timeval const& b, timeval& ret) {
ret.tv_usec = a.tv_usec - b.tv_usec;
ret.tv_sec = a.tv_sec - b.tv_sec;
if (a.tv_usec < b.tv_usec) {
ret.tv_usec += 1000000;
--ret.tv_sec;
}
}
static void format_time(std::ostream& out, timeval const& tv) {
using namespace std;
long usec = tv.tv_usec;
while (usec >= 1000)
usec /= 10;
out << tv.tv_sec << '.' << setw(3) << setfill('0') << usec;
}
}; // class StopWatch
|
Is anyone using Virtual PC to maintain multiple large .NET 1.1 and 2.0 websites? Are there any lessons learned? I used Virtual PC recently with a small WinForms app and it worked great, but then everything works great with WinForms. ASP.NET development hogs way more resources, requires IIS to be running, requires a ridiculously long wait after recompilations, etc., so I'm a little concerned. And I'll also be using Oracle, if that makes any difference.
Also, is there any real reason to use VM Ware instead of Virtual PC.
Thanks,
Mike |
|performance|virtual-pc| |
Is anyone using Virtual PC to maintain multiple large .NET 1.1 and 2.0 websites? Are there any lessons learned? I used Virtual PC recently with a small WinForms app and it worked great, but then everything works great with WinForms. ASP.NET development hogs way more resources, requires IIS to be running, requires a ridiculously long wait after recompilations, etc., so I'm a little concerned. And I'll also be using Oracle, if that makes any difference.
Also, is there any real reason to use VM Ware instead of Virtual PC?
Thanks,
Mike |
Is your type not public, if so, call the overload that takes in a boolean:
Activator.CreateInstance(type, true);
Also, in your first example, see if o is null and if not, print out o.GetType().Name to see what it really is. |
Combining several third-party libraries into one could create more problems for you--for instance, if two of those libraries define a common symbol which your program doesn't use. Now you've got to extract all (or all-but-one) of the instances of the common symbol before you combine the libraries.
|
What you can do is that after the broadcast have the **clients** initiate the tcp connections. Otherwise you just have to keep a list of all clients and initiate the connections to each client yourself. |
Entity diagrams in ASP.NET MVC |
|.net-3.5|asp.net-mvc|graphics|diagram| |
What's the best way/tool to display nice diagrams with entity relationships in ASP MVC views? I.e. servers and and applications, or servers with other servers.
Are there any third party tools out there that can do this? I've been searching around things like Telerik, but it's really hard to google for this! |
|asp.net|asp.net-mvc|.net-3.5|graphics|diagram| |
How scalable is System.Threading.Timer? |
|c#|.net|multithreading|timer| |
I'm writing an app that will need to make use of `Timer`s, but potentially very many of them. How scalable is the `System.Threading.Timer` class? The documentation merely say it's "lightweight", but doesn't explain further. Do these timers get sucked into a single thread (or very small threadpool) that processes all the callbacks on behalf of a `Timer`, or does each `Timer` have it's own thread?
I guess another way to rephrase the question is: How is `System.Threading.Timer` implemented? |
This is best handled by DirectShow.
DirectShow is currently a part of the platform SDK.
HRESULT extractFriendlyName( IMoniker* pMk, std::wstring& str )
{
assert( pMk != 0 );
IPropertyBag* pBag = 0;
HRESULT hr = pMk->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag );
if( FAILED( hr ) || pBag == 0 )
{
return hr;
}
VARIANT var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL);
if( SUCCEEDED( hr ) && var.bstrVal != 0 )
{
str = reinterpret_cast<wchar_t*>( var.bstrVal );
SysFreeString(var.bstrVal);
}
pBag->Release();
return hr;
}
HRESULT enumerateDShowFilterList( const CLSID& category )
{
HRESULT rval = S_OK;
HRESULT hr;
ICreateDevEnum* pCreateDevEnum = 0; // volatile, will be destroyed at the end
hr = ::CoCreateInstance( CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, reinterpret_cast<void**>( &pCreateDevEnum ) );
assert( SUCCEEDED( hr ) && pCreateDevEnum != 0 );
if( FAILED( hr ) || pCreateDevEnum == 0 )
{
return hr;
}
IEnumMoniker* pEm = 0;
hr = pCreateDevEnum->CreateClassEnumerator( category, &pEm, 0 );
// If hr == S_FALSE, no error is occured. In this case pEm is NULL, because
// a filter does not exist e.g no video capture devives are connected to
// the computer or no codecs are installed.
assert( SUCCEEDED( hr ) && ((hr == S_OK && pEm != 0 ) || hr == S_FALSE) );
if( FAILED( hr ) )
{
pCreateDevEnum->Release();
return hr;
}
if( hr == S_OK && pEm != 0 ) // In this case pEm is != NULL
{
pEm->Reset();
ULONG cFetched;
IMoniker* pM = 0;
while( pEm->Next(1, &pM, &cFetched) == S_OK && pM != 0 )
{
std::wstring str;
if( SUCCEEDED( extractFriendlyName( pM, str ) )
{
// str contains the friendly name of the filter
// pM->BindToObject creates the filter
std::wcout << str << std::endl;
}
pM->Release();
}
pEm->Release();
}
pCreateDevEnum->Release();
return rval;
}
The following call enumerates all video compressors to the console :
enumerateDShowFilterList( CLSID_VideoCompressorCategory );
The MSDN page [Filter Categories][1] lists all other 'official' categories.
I hope that is a good starting point for you.
[1]: http://msdn.microsoft.com/en-us/library/ms783347(VS.85).aspx |
[Qt Window Geometry](http://doc.trolltech.com/4.3/geometry.html)
Call the move(x, y) method on the child window before show(). The default values for x and y are 0 so that's why it appears in the upper left-hand corner.
You can also use the position of the parent window to compute a relative position for the child.
|
The difference between using an interface and an abstract class has more to do with code organization for me, than enforcement by the language itself. I use them a lot when preparing code for other developers to work with so that they stay within the intended design patterns. Interfaces are a kind of "design by contract" whereby your code is agreeing to respond to a prescribed set of API calls that may be coming from code you do not have aceess to.
While inheritance from abstract class is a "is a" relation, that isn't always what you want, and implementing an interface is more of a "acts like a" relation. This difference can be quite significant in certain contexts.
For example, let us say you have an abstract class Account from which many other classes extend (types of accounts and so forth). It has a particular set of methods that are only applicable to that type group. However, some of these account subclasses implement Versionable, or Listable, or Editable so that they can be thrown into controllers that expect to use those APIs. The controller does not care what type of object it is
By contrast, I can also create an object that does not extend from Account, say a User abstract class, and still implement Listable and Editable, but not Versionable, which doesn't make sense here.
In this way, I am saying that FooUser subclass is NOT an account, but DOES act like an Editable object. Likewise BarAccount extends from Account, but is not a User subclass, but implements Editable, Listable and also Versionable.
Adding all of these APIs for Editable, Listable and Versionable into the abstract classes itself would not only be cluttered and ugly, but would either duplicate the common interfaces in Account and User, or force my User object to implement Versionable, probably just to throw an exception.
|
Check out [phc: the PHP compiler][1]
If you just want to run it like a script, you may not need to compile it per say, but just run it via the command line. [Read running PHP via the command line.][2]
[1]: http://www.phpcompiler.org/
[2]: http://www.php.net/features.commandline |
The [Eclipse Web Tools Platform Project][1] includes a JSP debugger. I have only ever needed to use it with Tomcat so I cannot say how well it works with other servlet containers.
[1]: http://wiki.eclipse.org/Category:Eclipse_Web_Tools_Platform_Project |
Something I bookmarked long ago, but never got to test so far: http://www.schillmania.com/projects/soundmanager2/ |
.Net 3.5 silent installer? |
|.net|.net-3.5|installation|redistributable| |
Is there a redistributable .Net 3.5 installation package that is a silent installer?
Or alternatively, is there a switch that can be passed to the main redistributable .Net 3.5 installer to make it silent?
|
FogBugz uses EBS ([Evidence Based Scheduling][1]) to create a probability curve of when you will ship a given project based on existing performance data and estimates.
I guess you could do the same thing with this, just you would need to enter for the testers: "Browsing Internet waiting for developers (1 week)"
[1]: http://www.fogcreek.com/FogBugz/docs/60/topics/schedules/Evidence-BasedScheduling.html |
BEA seems to have a free one [BEA JSP plugin][1] - not used it, so not sure how good it is.
[1]: http://commerce.bea.com/products/workshop/workshop_prod_fam.jsp |
dotnetfx35setup.exe /q /norestart
see the .net deployment guide at:
http://msdn.microsoft.com/en-us/library/cc160716.aspx |
There seems to be a few examples out there that are far better than [what I was going to send you.][1]
See [http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html][2].
I'd agree with Stu, however. If you can find a way to get what you want using some command-line tools (and run them using [Commons-Exec][3]), you might have a better overall solution than depending on what is essentially the Sanskrit of Java extensions.
[1]: http://code.google.com/p/vitalopensource/source/browse/trunk/src/com/vtls/opensource/image/VideoImageSource.java
[2]: http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html
[3]: http://commons.apache.org/exec/ |
Using nUnit with TFS isn't too difficult. There's even a project on codeplex to implement this: http://www.codeplex.com/nunit4teambuild which even "publishes" the results to the warehouse.
I haven't tried it - but I would advise clients who have a large investment (or who have a strong preference for it over the MSTest tool) in nUnit who are interested in implementing TFS to continue with nUnit as opposed to trying convert all their existing tests. |
@Matthew
Your query's a start, but it might not work when you have multiple schemas. For example, if I log into our instance as myself, I have read access to all our tables. But if I don't qualify the table name with the schema I'll get an ORA-00942 for tables without synonyms:
<pre>
SQL> select * from tools;
select * from tools
*
ERROR at line 1:
ORA-00942: table or view does not exist
</pre>
The table still shows up in all_tables though:
<pre>
SQL> select owner, table_name from all_tables where table_name = 'TOOLS';
OWNER TABLE_NAME
------------------------------ ------------------------------
APPLICATION TOOLS
</pre>
@erikson
Sorry that doesn't help much. I'm with Mark - I used TOAD.
|
Set based queries are (usually) faster because:
1. They have more information for the query optimizer to optimize
2. They can batch reads from disk
3. There's less logging involved for rollbacks, transaction logs, etc.
4. Less locks are taken, which decreases overhead
5. Set based logic is the focus of RDBMSs, so they've been heavily optimized for it (often, at the expense of procedural performance)
Pulling data out to the middle tier to process it can be useful, though, because it removes the processing overhead off the DB server (which is the hardest thing to scale, and is normally doing other things as well). Also, you normally don't have the same overheads (or benefits) in the middle tier. Things like transactional logging, built-in locking and blocking, etc. - sometimes these are necessary and useful, other times they're just a waste of resources.
A simple cursor with procedural logic vs. set based example (T-SQL) that will assign an area code based on the telephone exchange:
--Cursor
DECLARE @phoneNumber char(7)
DECLARE c CURSOR LOCAL FAST_FORWARD FOR
SELECT PhoneNumber FROM Customer WHERE AreaCode IS NULL
OPEN c
FETCH NEXT FROM c INTO @phoneNumber
WHILE @@FETCH_STATUS = 0 BEGIN
DECLARE @exchange char(3), @areaCode char(3)
SELECT @exchange = LEFT(@phoneNumber, 3)
SELECT @areaCode = AreaCode
FROM AreaCode_Exchange
WHERE Exchange = @exchange
IF @areaCode IS NOT NULL BEGIN
UPDATE Customer SET AreaCode = @areaCode
WHERE CURRENT OF c
END
FETCH NEXT FROM c INTO @phoneNumber
END
CLOSE c
DEALLOCATE c
END
--Set
UPDATE Customer SET
AreaCode = AreaCode_Exchange.AreaCode
FROM Customer
JOIN AreaCode_Exchange ON
LEFT(Customer.PhoneNumber, 3) = AreaCode_Exchange.Exchange
WHERE
Customer.AreaCode IS NULL |
Have you tried using transactions?
From what you describe, having the server committing 100% of the time to disk, it seems you are sending each row of data in an atomic SQL sentence thus forcing the server to commit (write to disk) every single row.
If you used transactions instead, the server would only commit *once* at the end of the transaction.
For further help: What method are you using for inserting data to the server? Updating a DataTable using a DataAdapter, or executing each sentence using a string? |
If you're like me, and like videos of presentations, than this is a good tutorial:
**A Taste of Haskell**
- [Part 1][1]
- [Part 2][2]
- [Slides][3]
It's a three-hour tutorial, that uses [xmonad][4] as a running example to explain Haskell to experienced (imperative) programmers.
The presentation is given by Simon Peyton-Jones who, besides being one of the top Haskell designers, is also a great speaker.
[1]: http://blip.tv/file/324976 "Part 1"
[2]: http://blip.tv/file/325646 "Part 2"
[3]: http://research.microsoft.com/~simonpj/papers/haskell-tutorial/TasteOfHaskell.pdf "Slides"
[4]: http://xmonad.org/ "xmonad" |
How to encrypt connection string in WinForms 1.1 app.config? |
|database|winforms| |
Just looking for the first step basic solution here that keeps the honest people out.
Thanks,
Mike
P.S. When I typed this question into the title box, a set of related questions were automatically listed for me. None answered my question in this case, but this is a really sweet feature! |
select
timefield
from
entries
where
rand() = .01 --will return 1% of rows adjust as needed.
--not a mysql expert so I'm not sure how rand() operates in this environment. |
What do you want to achieve?
Is this a question how video container types are structured?
See for example : [http://www.daubnet.com/formats/AVI.html][1]
That is a description how avi files are structured. Google may help you in finding other container file formats.
[1]: http://www.daubnet.com/formats/AVI.html |
What do you want to achieve?
Is this a question how video container types are structured?
See for example : [http://www.daubnet.com/formats/AVI.html][1]
That is a description how avi files are structured. Google may help you in finding other container file formats.
[1]: http://www.daubnet.com/formats/AVI.html
When you record a video, it is normally composed of individual frames, think of individual bitmap files in a directory.
To only have 1 file of a video, this stream of frames is put in a container, which has a header describing the contents and a certain layout in which the frames are stored sequentially in the file.
Simple example for my own simple container :
{
struct header
{
unsigned int frametype;
unsigned int framesize;
};
byte* readFrame( header* pHdr, int frameNum )
{
byte* pFirstFrame = ((byte*) pHdr) + sizeof( header );
return pFristFrame + frameNum * pHdr->framesize;
}
}
There are several other container types. Avi is one of these container types.
To get to the individual frames you must interpret the header in the file and then based on that information calculate the position of the frame you want to parse.
I posted you a link to the definition of the avi file format. There are other places where you can get information on the mpeg/mkv/ogm file formats.
You need this information to get your program to work.
On a side note, compressed formats do not safe all individual frames independently. They safe an individual frame and then several intermediate frames, which only contain the information on how the current frame differs from the last complete frame. So you cannot extract complete frames at every frame number. |
What do you want to achieve?
Is this a question how video container types are structured?
See for example : [http://www.daubnet.com/formats/AVI.html][1]
That is a description how avi files are structured. Google may help you in finding other container file formats.
[1]: http://www.daubnet.com/formats/AVI.html
When you record a video, it is normally composed of individual frames, think of individual bitmap files in a directory.
To only have 1 file of a video, this stream of frames is put in a container, which has a header describing the contents and a certain layout in which the frames are stored sequentially in the file.
Simple example for my own container :
{
struct header
{
unsigned int frametype;
unsigned int framesize;
};
byte* readFrame( header* pHdr, int frameNum )
{
byte* pFirstFrame = ((byte*) pHdr) + sizeof( header );
return pFristFrame + frameNum * pHdr->framesize;
}
}
There are several other container types. AVI is only one of these container types.
To get to the individual frames you must interpret the header in the file and then based on that information calculate the position of the frame you want to parse.
I posted you a link to the definition of the avi file format. There are other places where you can get information on the mpeg/mkv/ogm file formats.
You need this information to get your program to work.
On a side note, compressed formats do not safe all individual frames independently. They safe an individual frame and then several intermediate frames, which only contain the information on how the current frame differs from the last complete frame. So you cannot extract complete frames at every frame number. |
> Sergio del Amo:
>
>> However, I am not getting the pages without tags. I guess i need to write my query with left outer joins.
SELECT pagetag.id, page.name, group_concat(tag.name) FROM
(page LEFT JOIN pagetag on page.id = pagetag.pageid)
LEFT JOIN tag on pagetag.tagid = tag.id
group by page.id;
Not a very pretty query, but should give you what you want - pagetag.id and group_concat(tag.name) will be null for page 4 in the example you've posted above, but the page shall appear in the results. |
Add the following to the virtual directory's web.config file:
<httpModules>
<remove name="ChartStreamHandler"/>
</httpModules> |
@Rob#37760:
select top N points from users order by points desc
This query will only select 3 rows if N is 3, see the question. "Top 3" should return 5 rows. |
<http://regexlib.com/REDetails.aspx?regexp_id=610>
> ^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
>
----------
> This RE validates both dates and/or
> times patterns. Days in Feb. are also
> validated for Leap years. Dates: in
> dd/mm/yyyy or d/m/yy format between
> 1/1/1600 - 31/12/9999. Leading zeroes
> are optional. Date separators can be
> either matching dashes(-), slashes(/)
> or periods(.) Times: in the hh:MM:ss
> AM/PM 12 hour format (12:00 AM -
> 11:59:59 PM) or hh:MM:ss military time
> format (00:00:00 - 23:59:59). The 12
> hour time format: 1) may have a
> leading zero for the hour. 2) Minutes
> and seconds are optional for the 12
> hour format 3) AM or PM is required
> and case sensitive. Military time 1)
> must have a leading zero for all hours
> less than 10. 2) Minutes are
> manditory. 3) seconds are optional.
> Datetimes: combination of the above
> formats. A date first then a time
> separated by a space. ex) dd/mm/yyyy
> hh:MM:ss |
<http://regexlib.com/REDetails.aspx?regexp_id=610>
> ^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
>
> Blockquote
----------
> This RE validates both dates and/or
> times patterns. Days in Feb. are also
> validated for Leap years. Dates: in
> dd/mm/yyyy or d/m/yy format between
> 1/1/1600 - 31/12/9999. Leading zeroes
> are optional. Date separators can be
> either matching dashes(-), slashes(/)
> or periods(.) Times: in the hh:MM:ss
> AM/PM 12 hour format (12:00 AM -
> 11:59:59 PM) or hh:MM:ss military time
> format (00:00:00 - 23:59:59). The 12
> hour time format: 1) may have a
> leading zero for the hour. 2) Minutes
> and seconds are optional for the 12
> hour format 3) AM or PM is required
> and case sensitive. Military time 1)
> must have a leading zero for all hours
> less than 10. 2) Minutes are
> manditory. 3) seconds are optional.
> Datetimes: combination of the above
> formats. A date first then a time
> separated by a space. ex) dd/mm/yyyy
> hh:MM:ss
----------
**Edit**: Make sure you copy the RegEx from the regexlib.com website as StackOverflow sometimes removes/destroys special chars. |
At work our code base is C++ and Perl and we talk to a MySQL database. For our interface we have some fairly thin custom classes wrapped around the basic MySQL client libraries for our C++ code and the DBI module for our Perl scripts. |
As a shot in the dark:
Is it a slash issue? I vaguely remember MSBuild forcibly requiring a trailing slash on some of its properties. |
SubSonic and LINQ to SQL, hopefully one day soon LINQ to SubSonic though! |
I'm not sure whether it will suit your particular case, you didn't mention what platform you're working in, but I've had great success with [Castle Windsor's IOC framework][1]. The dependencies are setup in the config file (it's a .NET framework)
[1]: http://www.castleproject.org/container/index.html |
Using a [min-heap](http://en.wikipedia.org/wiki/Heap_(data_structure)) is the best way.
It is tailor made for this application. |
Using a min-heap is the best way.
http://en.wikipedia.org/wiki/Heap_(data_structure)
It is tailor made for this application.
(Markdown is kicking my butt) |
Using a min-heap is the best way.
<http://en.wikipedia.org/wiki/Heap_(data_structure)>
It is tailor made for this application. |
Are there benefits to Classic ASP over ASP.net |
|asp.net|comparison|asp-classic|interpreted|compiled| |
Having worked with Classic ASP for about 2 years now by creating a few 100 simple web forms I can't see a good reason for switching to .net; however, I'm not that versed in .net so I'm sure I could be missing a few things.
An over view of why I feel this way is best found here: <a href="http://www.packtpub.com/article/Classic-ASP">http://www.packtpub.com/article/Classic-ASP</a>
I'm very interested to hear what others have to say on this matter. |
Having worked with Classic ASP for about 2 years now by creating a few 100 simple web forms I can't see a good reason for switching to .net; however, I'm not that versed in .net so I'm sure I could be missing a few things.
Some points that I often hear around work can be found here: <a href="http://www.packtpub.com/article/Classic-ASP">http://www.packtpub.com/article/Classic-ASP</a> (not that I share all of these thoughts, but it's a good jumping off point)
I'm very interested to hear what others have to say on this matter. |