instruction stringlengths 0 30k ⌀ |
|---|
Besides another commercial product, like [Wowza Media Server][1], you could go with a CDN (Content Delivery Network), like [Limelight Networks][2] or [Voxel.net][3]. You might even be able to find a local hosting provider that would serve up live Flash video for you.
(Live Flash video in a non-trivial thing to do, so the options are a bit limited.)
[1]: http://www.wowzamedia.com/
[2]: http://www.limelightnetworks.com/
[3]: http://www.voxel.net/ |
Obvious question, but have you got Hudson set up to point to the same Maven repository as your command line build? You can check this from the Hudson admin gui - look in the Maven section of the Manage Hudson page. This should have a `MAVEN_HOME` environment variable listed. Look in the settings.xml file under:
MAVEN_HOME\conf\settings.xml
The `localRepository` configuration item is the location of the Maven repository that the Hudson build is using. |
How will the other site validate your username and password?
Ideally your site shouldn't even be remembering the user's password to be able to pass it to another site (you store hashes of the password, not the password itself, and only use the actually password during validation).
What if your site provided a token to the user, who presents that token to the new site, which in turn asks your site to validate the token. Basically the second site is trusting you to tell them who the user is.
This all breaks down if the second site is actually using the Windows accounts for anything other than just retrieving a user name (for example permissions on the underlying file), since the user is not logged on as the actual Windows user account in this scenario. |
To my mind, the simplest way is maintain a 1:1 between rails instances and DB shards. |
System.Reflection.MethodBase.GetCurrentMethod().Name;
|
- [@@IDENTITY][1] returns the last identity value generated for any table in the current session, across all scopes. You need to be careful here, since it's across scopes. You could get a value from a trigger, instead of your current statement.
- [SCOPE_IDENTITY][2] returns the last identity value generated for any table in the current session and the current scope. Generally what you want to use.
- [IDENT_CURRENT][3] returns the last identity value generated for a specific table in any session and any scope. This lets you specify which table you want the value from, in case the two above aren't quite what you need (very rare).
[1]: http://msdn.microsoft.com/en-us/library/ms187342.aspx
[2]: http://msdn.microsoft.com/en-us/library/ms190315.aspx
[3]: http://msdn.microsoft.com/en-us/library/ms175098.aspx |
In native code you can get a shot at walking the callstack by installing a [Vectored Exception handler][1]. VC++ implements C++ exceptions on top of SEH exceptions and a vectored exception handler is given first shot before any frame based handlers. However be really careful, problems introduced by vectored exception handling can be difficult to diagnose.
Also [Mike Stall has some warnings][2] about using it in an app that has managed code. Finally, read [Matt Pietrek's article][3] and make sure you understand SEH and vectored exception handling before you try this. (Nothing feels quite so bad as tracking down a critical problem to code you added help track down critical problems.)
[1]: http://msdn.microsoft.com/en-us/library/ms681420.aspx
[2]: http://blogs.msdn.com/jmstall/archive/2006/05/24/avoid-vectored-exception-handler-managed-code.aspx
[3]: http://msdn.microsoft.com/en-us/magazine/cc301714.aspx |
I think so. RESTful solutions are more and more sensible for the vast majority of use cases; the complexities of SOAP and other RPC technologies just aren't worth the effort anymore. |
I think the only solution will be to create an asynchronous service that wraps a [standard connector](http://dev.mysql.com/downloads/connector/odbc/5.1.html). You'll need to understand the ODBC APIs though.
Skizz |
One good reason not to use a relational database would be when you have a massive data set and want to do massively parallel and distributed processing on the data. The Google web index would be a perfect example of such a case.
Hadoop also has an implementation of the [Google File System][1] called the [Hadoop Distributed File System][2].
[1]: http://labs.google.com/papers/gfs.html
[2]: http://hadoop.apache.org/core/docs/current/hdfs_design.html |
You need to use the "allowScriptAccess" flash variable in the HTML. You probably want to use "sameDomain" as the type. Note that if you go cross-domain, you also need to host a special file on the server called 'crossdomain.xml' which enables such scripting (the flash player will check for this. More info at [http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213&sliceId=2][1]
The call is the easy part. :-) In the Flash code, you'll use the ExternalInterface to do the call, as documented here:
[http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001655.html][2]
Short version: you say
> ExternalInterface.call("javascriptFunction", "argument")
[1]: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213&sliceId=2
[2]: http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001655.html |
Why not throw an exception if the operation wasn't successful? Personally, I tend to be of the opinion that if you need to return more than one value from a function, you should reconsider if you're doing things the right way or use an object. |
Why not throw an exception if the operation wasn't successful? Personally, I tend to be of the opinion that if you need to return more than one value from a function, you should reconsider if you're doing things the right way or use an object.
But more directly to the point, if you throw an exception, you're forcing them to deal with the problem. If you try to return a value that indicates failure, it's very well possible somebody could not check the value and end up with some potentially hard to debug errors. |
If you can find a professional or some other super-enterprise version of Visual Studio 6.0 - it came with a copy of <a href="http://en.wikipedia.org/wiki/MSDE">MSDE</a> (Basically the predecessor to SQL Express). I believe MSDE 2000 is still available as a free download from Microsoft, but I don't know if you can migrate directly from 6.5 to 2000.
I think in concept, you won't likely face any danger. Years of practice however tell me that you will always miss some object, permission, or other database item that won't manifest itself immediately. If you can script out the entire dump, the better as you will be less likely to miss something - and if you do miss something, it can be easily added to the script and fixed. I would avoid any manual steps (other than hitting the enter key once) like the plague. |
With git, you can do practically anything offline, because everybody has their own repository.
Making branches and merging between branches is really easy.
Even if you don't have commit rights for a project, you can still have your own repository online, and publish "push requests" for your patches. Everybody who likes your patches can pull them into their project, including the official maintainers.
It's trivial to fork a project, modify it, and still keep merging in the bugfixes from the HEAD branch.
Git works for the linux kernel developers. That means it is really fast (it has to be), and scales to thousands of contributors. Git also uses less space (upto 30x less space for the Mozilla repository).
Git is very flexible, very TIMTOWTDI (There is more than one way to do it). You can use whatever workflow you want, and git will support it.
Finally, there's github, a great site for hosting your git repositories.
Drawbacks of git:
- it's much harder to learn, because git has more concepts and more commands.
- revisions don't have version numbers like in subversion
- many git commands are cryptic, and error messages are very user-unfriendly
- it lacks a good GUI (such as the great TortoiseSVN) |
Replace your hyphens with this:
­
It's called a "soft" hyphen. |
Word-wrapping is part of CSS3 (read not yet fully supported) and you can find information on it at [http://www.css3.info/preview/word-wrap/][1].
[1]: http://www.css3.info/preview/word-wrap/ |
Word-wrapping is part of CSS3 (read not yet fully supported) and you can find information on it at [http://www.css3.info/preview/word-wrap/][1]. Another option is the [wbr tag, &shy;, and &#8203;][2] none of which are fully supported either.
[1]: http://www.css3.info/preview/word-wrap/
[2]: http://www.quirksmode.org/oddsandends/wbr.html |
Some fun things:
1. Having a PHP and MySQL Application that works well with German and French, but now needs to support Russian and Chinese. I think I move this over to .net, as PHP's Unicode support is - in my opinion - not really good. Sure, juggling around with utf8_de/encode or the mbstring-functions is fun. Almost as fun as having Freddy Krüger visit you at night...
2. Realizing that some languages are a LOT more Verbose than others. German and English are nice examples, and seeing how the German Version destroys the User Interface because too little space was allocated was not fun. Some products gaines some fame for their creative ways to work around that, with Oblivion's "Schw.Tr.d.Le.En.W." being memorable :-)
3. Playing around with date formats, woohoo! Yes, there ARE actually people in the world who use date formats where the day goes in the middle. Sooooo much fun trying to find out what 07/02/2008 is supposed to mean, just because some users might believe it could be July 2... But then again, you guys over the pond may believe the same about users who put the month in the middle :-P (I use 2008-02-07 whenever possible. It's clear that it means February 7 and it sorts properly)
4. Anoter fun thing, [Number formats][1]! 10.000,50 vs 10,000.50 vs. 10 000,50 vs. 10'000,50... This is my biggest nightmare right now, having to support a multi-cultural environent but not having any way to reliably know what number format the user will use.
[1]: http://stackoverflow.com/questions/192/floating-point-number-parsing-is-there-a-catch-all-algorithm |
Is this what you're after?
select * from master..syslogins |
I think, most of the time, we developers forget this we all do is, after all, about bussiness.
From that point of view a project is not a failure while the client is willing to pay for it. It all depends on the client, some clients have more patience and understand better the risks of software development, other just won't pay if there's a substantial delay.
Anyway, about your question. Whenever you evolve a project there are risks involved, maybe you schedule the end of the project in a certain date but it will take like six month longer than you expected. In that case you have to balance what you have already spent and what you have to gain against the risks you're taking. There's actually an entire science called "decision making" that studies it at software level, so your boss is not wrong at all.
Let's look at some questions, Is the client willing to wait for the project? Is he willing to assume certain overcosts? Even if he doesn't, Is worth completing the project assuming the extra costs instead of throwing away all the already done work? Can the company assume what's already lost?
The real answer to your problem lies behind that questions. You can't establish a point and say, here, if the project isn't done by this time then it's a failure. As for your specific situation, who knows? Your boss has probably more information that you have so your work is to tell him how is the project going, how much it will take and how much it will cost (in terms hours/man if you wish) |
Unless the goals were clearly stated in the beginning of the project, there are no clear lines between "success" and "failure." Often, a project would have varying degree of success/failure.
For some, just getting some concepts in code would be a success, while other may measure success as recovering all investments and making profit.
Two well-known modes of failures are schedule slip and quality deterioration, but in real-world, people do not seem to care much about them.
Simple ways to slip the schedule are to let the managers make request whenever they want (features creep) and let the programmers code whatever they feel is right (cowboy coding). Change management process such as [sprint planning][1] of scrum and [planning game][2] of XP are some of the examples. Theses are some of the attempts for the management and the developers to ship reliable products on time. If either party is not interested in reliable or on-time, then change management would not be useful.
[1]: http://www.agilecollab.com/sprint-planning-meeting
[2]: http://www.extremeprogramming.org/rules/planninggame.html |
SQL Query for Logins |
|sql| |
What is the SQL query to select all of the MSSQL Server's logins? |
|sql|mssql| |
|sql| |
What is the SQL query to select all of the MSSQL Server's logins?
Thanks, more then one of you had the answer I was looking for
SELECT * FROM syslogins |
The best quality control for gcc is the linux kernel. GCC is the compiler of choice for basically all major open source C/C++ programs. A released GCC, especially one like 4.3.X, which is in major linux distros, should be pretty good.
GCC 4.3 also has better support for optimizations on newer cpus. |
- [@@IDENTITY][1] returns the last identity value generated for any table in the current session, across all scopes. You need to be careful here, since it's across scopes. You could get a value from a trigger, instead of your current statement.
- [SCOPE_IDENTITY][2] returns the last identity value generated for any table in the current session and the current scope. Generally what you want to use.
- [IDENT_CURRENT][3] returns the last identity value generated for a specific table in any session and any scope. This lets you specify which table you want the value from, in case the two above aren't quite what you need (very rare). Also, as @[Guy Starbuck][4] mentioned, "You could use this if you want to get the current IDENTITY value for a table that you have not inserted a record into."
[1]: http://msdn.microsoft.com/en-us/library/ms187342.aspx
[2]: http://msdn.microsoft.com/en-us/library/ms190315.aspx
[3]: http://msdn.microsoft.com/en-us/library/ms175098.aspx
[4]: http://stackoverflow.com/questions/42648/best-way-to-get-identity-of-inserted-row#42665 |
Try this inside the Main method in an empty console program:
MethodBase method = MethodBase.GetCurrentMethod();
Console.WriteLine(method.Name);
Console Output:
<code>Main</code> |
Functions are first class citizens in F#. You can therefore pass them around just like you want to. |
Functions are first class citizens in F#. You can therefore pass them around just like you want to.
If you have a function like this:
let myFunction f =
f 1 2 3
and **f** is function then the return value of **myFunction** is **f** applied to 1,2 and 3.
|
EDIT: MethodBase is probably a better way to just get the method you're in (as opposed to the whole calling stack). I'd still be concerned about inlining however.
You can use a StackTrace within the method:
StackTrace st = new StackTrace(true);
And the look at the frames:
// The first frame will be the method you want (However, see caution below)
st.GetFrames();
However, be aware that if the method is inlined, you will not be inside the method you think you are. You can use an attribute to prevent inlining:
[MethodImpl(MethodImplOptions.NoInlining)] |
strip all html tags except links |
|html|regex|actionscript-3|string|tags| |
I am trying to write a regex to strip all HTML with the exception of links (the `<a href` and `</a>` tags respectively. It does not have to be 100% secure (I am not worried about injection attacks or anything as I am parsing content that has already been approved and published into a SWF movie.
The original "strip tags" RegEx I'm using was `<(.|\n)+?>`, and I tried to modify it to `<([^a]|\n)+?>`, but that of course will allow any tag that has an **a** In it rather than one that has it in the beginning, with a space.
Not that it should really matter, but in case anyone cares to know I am writing this in AS3 for a Flash movie. |
|html|regex|string|actionscript-3|tags| |
How much order do you need to impose on the threads? If you just need all of the work started in the loop to finish before the code continues, but you don't care about the order the work within the loop finishes, then calling Join is the answer. To add more detail to [Kevin Kenny's answer,][1] you should call Join *outside* the loop. This means you will need a collection to hold references to the threads you started:
// Start all of the threads.
List<Thread> startedThreads = new List<Thread>();
foreach (...) {
Thread thread = new Thread(new ThreadStart(MyMethod));
thread.Start();
startedThreads.Add(thread);
}
// Wait for all of the threads to finish.
foreach (Thread thread in startedThreads) {
thread.Join();
}
In contrast, if you called Join inside the loop, the result would basically be the same as not using threads at all. Each iteration of the loop body would create and start a thread but then immediately Join it and wait for it to finish.
If the individual threads produce some result (write a message in a log, for example) then the messages may still appear out of order because there's no coordination between the threads. It is possible to get the threads to output their results in order by coordinating them with a Monitor.
[1]: http://stackoverflow.com/questions/6890/compact-framework-how-to-wait-for-thread-complete-before-continuing#6935 |
Static constructors are guaranteed to be run only once per application domain, before any instances of a class are created or any static members are accessed. <http://msdn.microsoft.com/en-us/library/aa645612.aspx>
The implementation shown is thread safe for the initial construction, that is, no locking or null testing is required for constructing the Singleton object. However, this does not mean that any use of the instance will be synchronised. There are a variety of ways that this can be done; I've shown one below.
public class Singleton
{
private static Singleton instance;
// Added a static mutex for synchronising use of instance.
private static System.Threading.Mutex mutex;
private Singleton() { }
static Singleton()
{
instance = new Singleton();
mutex = new System.Threading.Mutex();
}
public static Singleton Acquire()
{
mutex.WaitOne();
return instance;
}
// Each call to Acquire() requires a call to Release()
public static void Release()
{
mutex.ReleaseMutex();
}
} |
Static constructors are guaranteed to fire only once per App Domain so your approach should be OK. However, it is functionally no different from the more concise, inline version:
private static readonly Singleton instance = new Singleton();
Thread safety is more of an issue when you are lazily initializing things. |
I suspect these are related to the SQL Server Agent trying to login to a database that no longer exists.
To clear it up you need to:
1. Go to SQL Server Management Studio
2. Disable the job called <database name>_job_deleteExpiredSessions
If that works, then you should be all clear to delete it. |
Using a static constructor actually *is* threadsafe. The static constructor is guaranteed to be executed only once.
From the C# language specification <http://msdn.microsoft.com/en-us/library/aa645612(VS.71).aspx>:
>The static constructor for a class executes at most once in a given application domain. The execution of a static constructor is triggered by the first of the following events to occur within an application domain:
>
> * An instance of the class is created.
> * Any of the static members of the class are referenced.
So yes, you can trust that your singleton will be correctly instantiated. |
Some fun things:
1. Having a PHP and MySQL Application that works well with German and French, but now needs to support Russian and Chinese. I think I move this over to .net, as PHP's Unicode support is - in my opinion - not really good. Sure, juggling around with utf8_de/encode or the mbstring-functions is fun. Almost as fun as having Freddy Krüger visit you at night...
2. Realizing that some languages are a LOT more Verbose than others. German is a LOT more verbose than English usually, and seeing how the German Version destroys the User Interface because too little space was allocated was not fun. Some products gained some fame for their creative ways to work around that, with Oblivion's "Schw.Tr.d.Le.En.W." being memorable :-)
3. Playing around with date formats, woohoo! Yes, there ARE actually people in the world who use date formats where the day goes in the middle. Sooooo much fun trying to find out what 07/02/2008 is supposed to mean, just because some users might believe it could be July 2... But then again, you guys over the pond may believe the same about users who put the month in the middle :-P (I use 2008-02-07 whenever possible. It's clear that it means February 7 and it sorts properly)
4. Anoter fun thing, [Number formats][1]! 10.000,50 vs 10,000.50 vs. 10 000,50 vs. 10'000,50... This is my biggest nightmare right now, having to support a multi-cultural environent but not having any way to reliably know what number format the user will use.
5. Formal or Informal. In some language, there are two ways to address people, a formal way and a more informal way. In English, you just say "You", but in German you have to decide between the formal "Sie" and the informal "Du", same for French Tu/Vous. It's usually a safe bet to choose the formal way, but this is easily overlooked.
6. Calendars. In Europe, the first day of the Week is Monday, whereas in the US it's Sunday. Calendar Widgets are nice. Showing a Calendar with Sunday on the left and Saturday on the right to a European user is not so nice, it confuses them.
[1]: http://stackoverflow.com/questions/192/floating-point-number-parsing-is-there-a-catch-all-algorithm |
Some fun things:
1. Having a PHP and MySQL Application that works well with German and French, but now needs to support Russian and Chinese. I think I move this over to .net, as PHP's Unicode support is - in my opinion - not really good. Sure, juggling around with utf8_de/encode or the mbstring-functions is fun. Almost as fun as having Freddy Krüger visit you at night...
2. Realizing that some languages are a LOT more Verbose than others. German is a LOT more verbose than English usually, and seeing how the German Version destroys the User Interface because too little space was allocated was not fun. Some products gained some fame for their creative ways to work around that, with Oblivion's "Schw.Tr.d.Le.En.W." being memorable :-)
3. Playing around with date formats, woohoo! Yes, there ARE actually people in the world who use date formats where the day goes in the middle. Sooooo much fun trying to find out what 07/02/2008 is supposed to mean, just because some users might believe it could be July 2... But then again, you guys over the pond may believe the same about users who put the month in the middle :-P, especially because in English, July 2 sounds a lot better than 2nd of July, something that does not neccessarily apply to other languages (i.e. in German, you would never say Juli 2 but always Zweiter Juli). I use 2008-02-07 whenever possible. It's clear that it means February 7 and it sorts properly, but dd/mm vs. mm/dd can be a really tricky problem.
4. Anoter fun thing, [Number formats][1]! 10.000,50 vs 10,000.50 vs. 10 000,50 vs. 10'000,50... This is my biggest nightmare right now, having to support a multi-cultural environent but not having any way to reliably know what number format the user will use.
5. Formal or Informal. In some language, there are two ways to address people, a formal way and a more informal way. In English, you just say "You", but in German you have to decide between the formal "Sie" and the informal "Du", same for French Tu/Vous. It's usually a safe bet to choose the formal way, but this is easily overlooked.
6. Calendars. In Europe, the first day of the Week is Monday, whereas in the US it's Sunday. Calendar Widgets are nice. Showing a Calendar with Sunday on the left and Saturday on the right to a European user is not so nice, it confuses them.
[1]: http://stackoverflow.com/questions/192/floating-point-number-parsing-is-there-a-catch-all-algorithm |
I don't know the answer to your specific question, but hopefully this information will point you in the right direction.
The "native" format for WF workflows is ".xoml" files. These are basically identical to XAML files, and both are nothing more than generic persistence formats for a .NET object tree. If you can access the saved data that is output by the Dynamics designer, it should be in the same format. If it is, you should be able to open it from the Visual Studio designer.
The key here is that CRM undoubtedly defines its own set of custom activities that you'll need to be able to reference from within the alternate designer. With any luck, these will be in assemblies with obvious names and/or in the GAC. |
you could change the title of the web page with each new message to alert the user. I did this for a browser chat client and most users thought it worked well enough. |
you could change the title of the web page with each new message to alert the user. I did this for a browser chat client and most users thought it worked well enough.
document.title = "[user] hello world"; |
Lightweight rich-text XML format? |
|xml|standards| |
I am writing a basic word processing application, and I am trying to settle on a native "internal" format, the one that my code parsers in order to render to the screen. I'd like this to be XML, so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever.
However, when searching for existing standards to use, the only one that looks promising is ODF. But that looks like massive overkill for what I'm thinking of. All I need is paragraph tags, font selection, font size & decoration... that's pretty much it. It would take me a long time to implement even a minimal ODF renderer and I'm not sure it's worth the trouble.
Right now I'm thinking of making my own XML format, but that's not really good practice. Better to use a standard, especially since then I can probably find the XSLTs I might need in the future already written.
Or should I just bite the bullet and implement ODF? |
I am writing a basic word processing application, and I am trying to settle on a native "internal" format, the one that my code parsers in order to render to the screen. I'd like this to be XML, so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever.
However, when searching for existing standards to use, the only one that looks promising is ODF. But that looks like massive overkill for what I'm thinking of. All I need is paragraph tags, font selection, font size & decoration... that's pretty much it. It would take me a long time to implement even a minimal ODF renderer and I'm not sure it's worth the trouble.
Right now I'm thinking of making my own XML format, but that's not really good practice. Better to use a standard, especially since then I can probably find the XSLTs I might need in the future already written.
Or should I just bite the bullet and implement ODF?
**EDIT: Regarding the Answer**
I had known about XSL-FO before, but due to the weight of the spec hadn't really consdiered it. But you're right, a subset would give me everything I need to work with and room to grow... thanks so much the reminder.
Plus, by including a rendering library like FOP or RenderX, I get PDF generation for free. Not bad... |
I am trying to write a regex to strip all HTML with the exception of links (the `<a href` and `</a>` tags respectively. It does not have to be 100% secure (I am not worried about injection attacks or anything as I am parsing content that has already been approved and published into a SWF movie).
The original "strip tags" RegEx I'm using was `<(.|\n)+?>`, and I tried to modify it to `<([^a]|\n)+?>`, but that of course will allow any tag that has an **a** In it rather than one that has it in the beginning, with a space.
Not that it should really matter, but in case anyone cares to know I am writing this in AS3 for a Flash movie. |
I don't think there is a library that does this out of the box. If you want to implement your own, I would definitely go with the [Python Imaging Library][1] (PIL).
This is [a Python Cookbook recipe][2] that uses PIL to add a _visible_ watermark to an image. If it's enough for your needs, you could use this to add a watermark with enough transparency that it is only visible if you know what you are looking for.
[1]: http://effbot.org/zone/pil-index.htm
[2]: http://code.activestate.com/recipes/362879/ |
I think you should be able to get that from creating a [StackTrace][1].
[1]: http://msdn.microsoft.com/en-us/library/6zh7csxz(VS.80).aspx |
I think you should be able to get that from creating a [StackTrace][1]. Or, as @[edg][2] and @[Lars Mæhlum][3] mention, MethodBase.[GetCurrentMethod][4]()
[1]: http://msdn.microsoft.com/en-us/library/6zh7csxz(VS.80).aspx
[2]: http://stackoverflow.com/questions/44153/can-you-use-reflection-to-find-the-name-of-the-currently-executing-method#44166
[3]: http://stackoverflow.com/questions/44153/can-you-use-reflection-to-find-the-name-of-the-currently-executing-method#44170
[4]: http://msdn.microsoft.com/en-us/library/system.reflection.methodbase.getcurrentmethod.aspx |
How can I install libgluezilla on Ubuntu 8.04? |
|ubuntu|mono| |
I want to use the Web Browser control within an mono application, but when I do get the error "libgluezilla not found. To have webbrowser support, you need libgluezilla installed." I can't find the package other than a SUSE rpm, how do I install the library? |
I want to use the Web Browser control within an mono application, but when I do get the error "libgluezilla not found. To have webbrowser support, you need libgluezilla installed." Installing the Intrepid Deb causes any application that references the web browser control to crash on startup with : 'Thread (nil) may have been prematurely finalized'.
|
Yes definately.
I actually do this in this function I use in my code framework to get the calling method:
public static T CreateWrapper<T>(Exception innerException, params object[] parameterValues) where T : Exception, new()
{
if (parameterValues == null)
{
parameterValues = new object[0];
}
Exception exception = null;
StringBuilder builder = new StringBuilder();
MethodBase method = new StackFrame(2).GetMethod();
ParameterInfo[] parameters = method.GetParameters();
builder.AppendFormat(CultureInfo.InvariantCulture, ExceptionFormat, new object[] { method.DeclaringType.Name, method.Name });
if ((parameters.Length > 0) || (parameterValues.Length > 0))
{
builder.Append(GetParameterList(parameters, parameterValues));
}
exception = (Exception)Activator.CreateInstance(typeof(T), new object[] { builder.ToString(), innerException });
return (T)exception;
}
Basically what's happening here is; I walk the stack here to find the calling method and then get the parameters of that method before tying them to the values passed to it. This allows me to easily create error reportd for my functions. All you need to do is get the current stack frame instead of the calling one.
|
@Bernard:
That's a good question... I think the code's ok.
From a practical standpoint, we use it in my company every day,
and we run on a pretty wide array of boxes, everything from 2-8 cores.
Of course, YMMV, etc, but it seems to be a reliable and low-overhead
(because it doesn't make a context switch into system-space) method
of timing.
Generally how it works is:
- declare the block of code to be assembler (and volatile, so the
optimizer will leave it alone).
- execute the CPUID instruction. In addition to getting some CPU information
(which we don't do anything with) it synchronizes the CPU's execution buffer
so that the timings aren't affected by out-of-order execution.
- execute the rdtsc (read timestamp) execution. This fetches the number of
machine cycles executed since the processor was reset. This is a 64-bit
value, so with current CPU speeds it will wrap around every 194 years or so.
Interestingly, in the original Pentium reference, they note it wraps around every
5800 years or so.
- the last couple of lines store the values from the registers into
the variables hi and lo, and put that into the 64-bit return value.
Specific notes:
- out-of-order execution can cause incorrect results, so we execute the
"cpuid" instruction which in addition to giving you some information
about the cpu also synchronizes any out-of-order instruction execution.
- Most OS's synchronize the counters on the CPUs when they start, so
the answer is good to within a couple of nano-seconds.
- The hibernating comment is probably true, but in practice you
probably don't care about timings across hibernation boundaries.
- regarding speedstep: Newer Intel CPUs compensate for the speed
changes and returns an adjusted count. I did a quick scan over
some of the boxes on our network and found only one box that
didn't have it: a Pentium 3 running some old database server.
(these are linux boxes, so I checked with: grep constant_tsc /proc/cpuinfo)
- I'm not sure about the AMD CPUs, we're primarily an Intel shop,
although I know some of our low-level systems gurus did an
AMD evaluation.
Hope this satisfies your curiosity, it's an interesting and (IMHO)
under-studied area of programming. You know when Jeff and Joel were
talking about whether or not a programmer should know C? I was
shouting at them, "hey forget that high-level C stuff... assembler
is what you should learn if you want to know what the computer is
doing!" |
String literals and escape characters in postgresql |
|postgresql| |
Attempting to insert an escape character into a table results in a warning and the string being truncated at the escape character. For example:
create table EscapeTest (text varchar(50));
insert into EscapeTest (text) values ('This will be inserted \n This will not be');
Produces the warning:
WARNING: nonstandard use of escape in a string literal
(Using PSQL 8.2)
Anyone know how to get around this? |
Partially. The text is inserted, but the warning is still generated.
I found a discussion that indicated the text needed to be preceded with 'E', as such:
insert into EscapeTest (text) values (E'This will be inserted \n This will not be');
This suppressed the warning, but still didn't insert the text. When I added the additional slash as Michael suggested, it worked.
As such:
insert into EscapeTest (text) values (E'This will be inserted \\n This will not be'); |
An example of a lambda in Ruby is as follows:
hello = lambda do
puts('Hello')
puts('I am inside a proc')
end
hello.call
Will genereate the following output:
Hello
I am inside a proc |
I have used both MSBuild and NAnt, and I much prefer MSBuild, mainly because it requires a lot less configuration by default. Although you can over-complicate things and load MSBuild down with a lot of configuration junk too, at its simplest, you can just point it at a solution/project file and have it go which, most of the time, for most cases, is enough. |
LIMIT n,1 doesn't work in MS SQL Server. I think it's just about the only major database that doesn't support that syntax. To be fair, it isn't part of the SQL standard, although it is so widely supported that it should be. In everything except SQL server LIMIT works great. For SQL server, I haven't been able to find an elegant solution. |
Here's a generic version of a sproc I recently wrote for Oracle that allows for dynamic paging/sorting - HTH
-- p_LowerBound = first row # in the returned set; if second page of 10 rows,
-- this would be 11 (-1 for unbounded/not set)
-- p_UpperBound = last row # in the returned set; if second page of 10 rows,
-- this would be 20 (-1 for unbounded/not set)
OPEN o_Cursor FOR
SELECT * FROM (
SELECT
Column1,
Column2
rownum AS rn
FROM
(
SELECT
tbl.Column1,
tbl.column2
FROM MyTable tbl
WHERE
tbl.Column1 = p_PKParam OR
tbl.Column1 = -1
ORDER BY
DECODE(p_sortOrder, 'A', DECODE(p_sortColumn, 1, Column1, 'X'),'X'),
DECODE(p_sortOrder, 'D', DECODE(p_sortColumn, 1, Column1, 'X'),'X') DESC,
DECODE(p_sortOrder, 'A', DECODE(p_sortColumn, 2, Column2, sysdate),sysdate),
DECODE(p_sortOrder, 'D', DECODE(p_sortColumn, 2, Column2, sysdate),sysdate) DESC
))
WHERE
(rn >= p_lowerBound OR p_lowerBound = -1) AND
(rn <= p_upperBound OR p_upperBound = -1); |
I'm not sure about any of the rest, but I know SQLite and MySQL don't have any "default" row ordering. In those two dialects, at least, the following snippet grabs the 15th entry from the_table, sorting by the date/time it was added:
SELECT * FROM the_table ORDER BY added DESC LIMIT 1,15
(of course, you'd need to have an added DATETIME field, and set it to the date/time that entry was added...) |
It also depends on **what** you're building. [MSBuild SDC Task library][1] has a couple of special tasks for example AD, BizTalk etc.
> There are over 300 tasks included in
> this library including tasks for:
> creating websites, creating
> application pools, creating
> ActiveDirectory users, running FxCop,
> configuring virtual servers, creating
> zip files, configuring COM+, creating
> folder shares, installing into the
> GAC, configuring SQL Server,
> configuring BizTalk 2004 and BizTalk
> 2006 etc.
[1]: http://www.codeplex.com/sdctasks |
Seat [number]: [letters&numbers&characters] ([number] in chips)
Your Regex should look something like this
Seat (\d+): ([a-zA-Z0-9]+) \((\d+) in chips\)
The brackets will let you capture the seat number, name and number of chips in groups. |
Thanks guys, lot of good info, but Martin has given me a bit more detail on how to proceed. I'll give him the answer, as it seems like now we're off the front few pages answers will drop off. |
[db4objects][1] might be the best choice
[1]: http://www.db4o.com |
I know a lot of people think short code equals elegant code but that isn't true.
The example you propose is perfectly solved in code, as you have shown so, what do you need a preprocessor directive to? You don't want to "preprocess" your code, you want the compiler to insert some code for you in your properties. It's common code but that's not the purpose of the preprocessor.
With your example, Where do you put the limit? Clearly that satisfies an observer pattern and there's no doubt that will be useful but there are a lot of things that would be useful that are actually done because code provides **flexibility** where as the preprocessor does not. If you try to implement common patterns through preprocessor directives you'll end with a preprocessor which needs to be as powerful as the language itself. If you want to **process your code in a different way the use a preprocessor directive** but if you just want a code snippet then find another way because the preprocessor wasn't meant to do that. |
C# Preprocessor |
|c#| |
While the C# spec does include a pre-processor and basic directives (#define, #if, etc), the language does not have the same flexible pre-processor found in languages such as C/C++. I believe the lack of such a flexible pre-processor was a design decision made by Anders Hejlsberg (although, unfortunately, I can't find reference to this now). From experience, this is certainly a good decision, as there were some really terrible un-maintainable macros created back when I was doing a lot of C/C++.
That said, there are a number of scenarios where I could find a slightly more flexible pre-processor to be useful. Code such as the following could be improved by some simple pre-processor directives:
public string MyProperty
{
get { return _myProperty; }
set
{
if (value != _myProperty)
{
_myProperty = value;
NotifyPropertyChanged("MyProperty");
// This line above could be improved by replacing the literal string with
// a pre-processor directive like "#Property", which could be translated
// to the string value "MyProperty" This new notify call would be as follows:
// NotifyPropertyChanged(#Property);
}
}
}
Would it be a good idea to write a pre-processor to handle extremely simple cases like this? Steve McConnell wrote in [Code Complete][1] (p208):
> *Write your own preprocessor* If a language doesn't include a preprocessor, it's fairly easy to write one...
I am torn. It was a design decision to leave such a flexible pre-processor out of C#. However, an author I highly respect mentions it may be ok in some circumstances.
**Should I build a C# pre-processor? Is there one available that does the simple things I want to do?**
[1]: http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670 |
|c#|preprocessor| |
I found the following in an [Apple Forum][1]:
> Xcode doesn't come with any symbolic breaks built in - but they're
quick to add. Go to the breakpoints window and add:
> -[NSException raise]
[1]: http://lists.apple.com/archives/Cocoa-dev/2003/Nov/msg00166.html |
Yes definately.
I actually do this in this function I use in my code framework to get the calling method:
public static T CreateWrapper<T>(Exception innerException, params object[] parameterValues) where T : Exception, new()
{
if (parameterValues == null)
{
parameterValues = new object[0];
}
Exception exception = null;
StringBuilder builder = new StringBuilder();
MethodBase method = new StackFrame(2).GetMethod();
ParameterInfo[] parameters = method.GetParameters();
builder.AppendFormat(CultureInfo.InvariantCulture, ExceptionFormat, new object[] { method.DeclaringType.Name, method.Name });
if ((parameters.Length > 0) || (parameterValues.Length > 0))
{
builder.Append(GetParameterList(parameters, parameterValues));
}
exception = (Exception)Activator.CreateInstance(typeof(T), new object[] { builder.ToString(), innerException });
return (T)exception;
}
Basically what's happening here is; I walk the stack here to find the calling method and then get the parameters of that method before tying them to the values passed to it. This allows me to easily create error reportd for my functions. All you need to do is get the current stack frame instead of the calling one.
As others have said for the current methods name you can also use:
MethodBase.GetCurrentMethod()
I prefer walking the stack because if look internally at that method it simply creates a StackCrawlMark anyway. Addressing the Stack directly seems clearer to me
|
AFAIK, this **cannot** be done. The TextBox control is a funny control because it actually has a *lot* of behaviour that can't be modified due to the way it taps into the operating system. This is why many of the cool custom TextBoxes are written from scratch.
I am afraid you may not be able to do what you wish to do :( |
You can do through a win32 call
DllImport("user32")] private static extern bool HideCaret(IntPtr hWnd);
public void HideCaret()
{
HideCaret(someTextBox.Handle);
} |
Yes, on the server side for sure. Client side? I don't know.
One the server side, one would have to parse the file, read the header and/or look for audio frames. (I've ported a haskel FLV parser to Java for indexing purposes myself, and there are other parsing utilities out there. It is possible.)
[osflash.org's FLV page][1] has the gory details. Check out the FLV Format sections's FLV Header table.
[1]: http://osflash.org/flv |
Yes, on the server side for sure. Client side? I don't know. (I'm a serverside kind of guy.)
On the server side, one would have to parse the file, read the header and/or look for audio frames. (I've ported a haskel FLV parser to Java for indexing purposes myself, and there are other parsing utilities out there. It is possible.)
[osflash.org's FLV page][1] has the gory details. Check out the FLV Format sections's FLV Header table.
FIELD DATA TYPE EXAMPLE DESCRIPTION
Signature byte[3] “FLV” Always “FLV”
Version uint8 “\x01” (1) Currently 1 for known FLV files
Flags uint8 bitmask “\x05” (5, audio+video) Bitmask: 4 is audio, 1 is video
Offset uint32-be “\x00\x00\x00\x09” (9) Total size of header (always 9 for known FLV files)
[1]: http://osflash.org/flv |
There is nothing I know of that can do this without you at least writing a little bit of code... You will need 2 separate library:
- A CSV Parser Framework
- An XML Serialization Framework
The CSV parser I would recommend (unless you want to have a little bit of fun to write your own CSV Parser) is OpenCSV (A SourceForge Project for parsing CSV Data)
The XML Serialization Framework should be something that can scale in case you want to transform large (or huge) CSV file to XML: I recommend is the Sun Java Streaming XML Parser Framework (See [here][1]) which allows pull-parsing AND serialization.
[1]: https://sjsxp.dev.java.net/ |
Very roughly and from memory since I don't have code on this laptop:
<pre>
using (OleDBConnection conn = new OleDbConnection())
{
conn.ConnectionString = "Whatever connection string";
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = conn;
cmd.CommandText = "Select * from CoolTable";
using (OleDbDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
// do something like Console.WriteLine(dr["column name"] as String);
}
}
}
}
</pre> |
All editions of SQL Server 2000/2005/2008 support having multiple databases, each using their own collation sequence. You don't need the Enterprise version.
When you have a database that uses a collation sequence that is different from default collation for the database server, you will need to take some extra precautions if you use temporary tables and/or table variables. Temp tables/variables live in the tempdb database, which uses the collation seqyuence used by by the master databases. Just remember to use "COLLATE database_default" when defining character fields in the temp tables/variables. I [blogged about that][1] not too long ago, if you want some more details.
[1]: http://anotherlab.rajapet.net/2008/07/handling-collation-sequences-with.html |
Cool.
I also found the documentation regarding the E:
[http://www.postgresql.org/docs/8.3/interactive/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS][1]
> PostgreSQL also accepts "escape" string constants, which are an extension to the SQL standard. An escape string constant is specified by writing the letter E (upper or lower case) just before the opening single quote, e.g. E'foo'. (When continuing an escape string constant across lines, write E only before the first opening quote.) Within an escape string, a backslash character (\\) begins a C-like backslash escape sequence, in which the combination of backslash and following character(s) represents a special byte value. \\b is a backspace, \\f is a form feed, \\n is a newline, \\r is a carriage return, \\t is a tab. Also supported are \\digits, where digits represents an octal byte value, and \\xhexdigits, where hexdigits represents a hexadecimal byte value. (It is your responsibility that the byte sequences you create are valid characters in the server character set encoding.) Any other character following a backslash is taken literally. Thus, to include a backslash character, write two backslashes (\\\\). Also, a single quote can be included in an escape string by writing \\', in addition to the normal way of ''.
[1]: http://www.postgresql.org/docs/8.3/interactive/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS |
PHP variables are passed by value, but there is a way to pass them by reference.
Therefor, the following code:
$aVar = "test";
$aNewVar = $aVar;
$aNewVar = "newTest";
print ($aNewVar . " " . $aVar);
would output "newTest test", NOT "newTest newTest". If PHP where pass by reference, it would output "newTest newTest". You can pass by reference by doing the following:
$aVar = "test";
$aNewVar = $aVar;
$bNewVar = &$aVar;
$bNewVar = "blah";
$cNewVar = &$aVar;
$aVar = "newest";
print ($aVar . " " . $aNewVar . " " . $bNewVar . " " . $cNewVar);
The code would print out:
newest test newest newest
Because bNewVar and cNewVar are all just references back to aVar, whenever you change any one of them, all three are changed.
You can see a better explanation here:
[http://www.phppatterns.com/docs/develop/php_and_variable_references][1]
[1]: http://www.phppatterns.com/docs/develop/php_and_variable_references |
Yes, on the server side for sure. Client side? I don't know. (I'm a serverside kind of guy.)
On the server side, one would have to parse the file, read the header and/or look for audio frames. (I've ported a haskel FLV parser to Java for indexing purposes myself, and there are other parsing utilities out there. It is possible.)
[osflash.org's FLV page][1] has the gory details. Check out the FLV Format sections's FLV Header table.
FIELD DATA TYPE EXAMPLE DESCRIPTION
Signature byte[3] “FLV” Always “FLV”
Version uint8 “\x01” (1) Currently 1 for known FLV files
Flags uint8 bitmask “\x05” (5, audio+video) Bitmask: 4 is audio, 1 is video
Offset uint32-be “\x00\x00\x00\x09” (9) Total size of header (always 9 for known FLV files)
----------
EDIT: My client side coding with Flash is non-existent, but I believe there is an onMetaDataLoad event that your code could catch. That might be happening a bit late for you, but maybe it is good enough?
[1]: http://osflash.org/flv |
If you need to maintain the name of the column (so as not to break client code), you will need to drop the column and add back a stored column with the same name. You can do this without downtime by making the changes (along the lines of SQLMenace's solution) in a single transaction. Here's some pseudo-code:
<pre>
begin transaction
drop computed colum X
add stored column X
populate column using the old formula
commit transaction
</pre> |
Connecting private IPs |
|ip|private-ips| |
A friend of mine told me there was a way to connect two private IPs without using a proxy server. The idea was that both computers connected to a public server and some how the server joined the private connections and won't use any more bandwidth.
Is this true? How's this technique named?
Thanks |
After installing the DEB my app crashes... Is this because the deb is for the wrong Ubuntu, it appears to be correct for the version of Mono (everything is. 1.9.1)...
<pre>
Mono-INFO: Assembly Loader probing location: '/usr/lib/mono/gac/Mono.Mozilla/0.2.0.0__0738eb9f132ed756/Mono.Mozilla.dll'.
Mono-INFO: Image addref Mono.Mozilla 0x8514cb0 -> /usr/lib/mono/gac/Mono.Mozilla/0.2.0.0__0738eb9f132ed756/Mono.Mozilla.dll 0x8514590: 2
Mono-INFO: Assembly Ref addref Mono.Mozilla 0x8514cb0 -> mscorlib 0x823ba30: 10
Mono-INFO: Assembly Mono.Mozilla 0x8514cb0 added to domain TestbedCSharp.exe, ref_count=1
Mono-INFO: AOT failed to load AOT module /usr/lib/mono/gac/Mono.Mozilla/0.2.0.0__0738eb9f132ed756/Mono.Mozilla.dll.so: /usr/lib/mono/gac/Mono.Mozilla/0.2.0.0__0738eb9f132ed756/Mono.Mozilla.dll.so: cannot open shared object file: No such file or directory
Mono-INFO: Assembly Loader loaded assembly from location: '/usr/lib/mono/gac/Mono.Mozilla/0.2.0.0__0738eb9f132ed756/Mono.Mozilla.dll'.
Mono-INFO: Config attempting to parse: '/usr/lib/mono/gac/Mono.Mozilla/0.2.0.0__0738eb9f132ed756/Mono.Mozilla.dll.config'.
Mono-INFO: Config attempting to parse: '/etc/mono/assemblies/Mono.Mozilla/Mono.Mozilla.config'.
Mono-INFO: Config attempting to parse: '/home/kris/.mono/assemblies/Mono.Mozilla/Mono.Mozilla.config'.
Mono-INFO: Assembly Ref addref System.Windows.Forms 0x82880d8 -> Mono.Mozilla 0x8514cb0: 2
Mono-INFO: Assembly Ref addref Mono.Mozilla 0x8514cb0 -> System 0x8290908: 5
Mono-INFO: DllImport attempting to load: 'gluezilla'.
Mono-INFO: DllImport loading location: 'libgluezilla.so'.
Mono-INFO: Searching for 'gluezilla_init'.
Mono-INFO: Probing 'gluezilla_init'.
Mono-INFO: Found as 'gluezilla_init'.
** (TestbedCSharp.exe:22700): WARNING **: Thread (nil) may have been prematurely finalized
</pre> |
Using a static constructor actually *is* threadsafe. The static constructor is guaranteed to be executed only once.
From the C# language specification <http://msdn.microsoft.com/en-us/library/aa645612(VS.71).aspx>:
>The static constructor for a class executes at most once in a given application domain. The execution of a static constructor is triggered by the first of the following events to occur within an application domain:
>
> * An instance of the class is created.
> * Any of the static members of the class are referenced.
So yes, you can trust that your singleton will be correctly instantiated.
Zooba made an excellent point (and 15 seconds before me, too!) that the static constructor will not guarantee thread-safe shared access to the singleton. That will need to be handled in another manner. |
I would recommend using background images. The other ways aren't nearly as good: No anti-aliasing and senseless markup. This is not the place to use JavaScript. |
I disagree with [Yaakov Ellis' answer.][1] The Common Language Specification guarantees that "a type initializer shall run exactly once for any given type, unless explicitly called by user code." (Section 9.5.3.1.) So unless you have some whacky IL on the loose calling Singleton::.cctor directly (unlikely) your static constructor will run exactly once before the Singleton type is used, and so your static singleton is thread-safe.
[1]: http://stackoverflow.com/questions/7095/is-the-c-static-constructor-thread-safe#7100 |