instruction stringlengths 0 30k ⌀ |
|---|
Formatting tabular data using unicode characters |
|unicode| |
I need to produce a calculation trace file containing tabular data showing intermediate results. I am currently using a combination of the standard ascii pipe symbols (|) and dashes (-) to draw the table lines:
E.g.
Numerator | Denominator | Result
----------|-------------|-------
6 | ... |
I need to produce a calculation trace file containing tabular data showing intermediate results. I am currently using a combination of the standard ascii pipe symbols (|) and dashes (-) to draw the table lines:
E.g.
Numerator | Denominator | Result
----------|-------------|-------
6 | ... |
I do not think there is a official set of conventions, so I would recommend looking at the examples at <http://perldoc.perl.org/Test/More.html> and see how the write their tests. |
@Jonathan Holland
> T is already a type parameter, you don't need to call typeof on it. TypeOf takes a type and returns its type parameter.
`typeof` "takes" a type and returns its `System.Type` |
@Jonathan Holland
> T is already a type parameter, you don't need to call typeof on it. TypeOf takes a type and returns its type parameter.
`typeof` "takes" a type and returns its `System.Type` |
The basic setup looks ok, although there are syntax errors in the posted pointcut syntax. I'm sure these weren't in your friend's original code as he would get compile errors. You might want to check with him and correct the code example in the question.
The syntax can be simplified slightly by not defining an in-pl... |
|windows|shell|command.com| |
Website Hardware Scaling |
|hardware|scaling| |
So I was listening to the latest Stackoverflow podcast ([episode 19][1]), and Jeff and Joel talked a bit about scaling server hardware as a website grows. From what Joel was saying, the first few steps are pretty standard:
1. One server running both the webserver and the database (the current Stackoverflow setup)
... |
Joel mentioned adding a second datacenter, with the same setup, and then assigning your users randomly to each. Changes to the data are logged and sent from one location to the other, so that both locations contain all the data. |
The talk Scalable Web Architectures Common Patterns & Approaches from Cal Henderson (Yahoo) on Web 2.0 Expo was quite interesting. I thought there was an video, but I could not find it. But here are the slides:
http://www.slideshare.net/techdude/scalable-web-architectures-common-patterns-and-approaches |
A certain next step would be a cluster of webservers (a web farm) and a clustered system of database servers (replication or Oracle RAC etc. etc.) |
Catching SQL Injection and other Malicious Web Requests |
|xss|sqlinjection| |
I am looking for a tool that can detect malicious requests (such as obvious SQL injection gets or posts) and will immediately ban the IP address of the requester/add to a blacklist. I know, I know, the code should be able to handle such requests accordingly but there is still value in such a tool even when the site i... |
|xss|sql-injection| |
SQL NOCOUNT |
|sql-server| |
What are the advantages and disadvantages of turning NOCOUNT off in SQL Server queries? |
|sql-server| |
Two main ways :
1. Deploy using the full .NET Framework
2. Write your own / 3rd party lib for these functionalities |
Accessing Excel data source running SSIS package on 64 bit server |
Algorithm for joining e.g. an array of strings |
|language-agnostic|algorithm|string|arrays| |
I have wondered for some time, what a nice, clean solution for joining an array of strings might look like.
Example: I have ["Alpha, "Beta", "Gamma"] and want to join the strings into one, separated by commas – "Alpha, Beta, Gamma".
Now I know that most programming languages offer some kind of join method for this.... |
I'm assuming you would like to be ablt to use if globally, or at least in IE/Firefox, not just be installing Safari as other have suggested.
Back in the days wen Mac OS X was still in development, there was a plan to release the Cocoa framework for windows, to allow applications written to it to run natively on Wind... |
Getting the latest service pack for SharePoint 2007 will resolve your problem (and add full support for AJAX). Without the service pack you will need to follow an example like that outlined in this article:
[AjaxBasePart: Easy ASP.NET 2.0 AJAX Extensions 1.0 and Office SharePoint Server 2007][1]
Posting this hea... |
Mac font rendering on Windows |
|macos|font|rendering| |
I love the way Mac OS *beautifully* renders fonts (not just browsers). I was wondering if we could somehow get the same rendering in browsers running on Windows?
Someone recommended sIFR but I guess that's useful when I need to use non-standard fonts?
--
Swap |
|macos|fonts|rendering| |
I usually go with something like...
list = ["Alpha", "Beta", "Gamma"];
output = "";
separator = "";
for (int i = 0; i < list.length ; i++) {
output = output + separator;
output = output + list[i];
separator = ", ";
}
This works because on the first pass, separator is e... |
I did a test where I listened for key up events on the stage and noticed that (on my Mac) I could capture control-c, control-v, etc. just fine, but anything involving command (the key) wasn't captured until I released the command key, and then ctrlKey was false (even though the docs says that ctrlKey should be true f... |
In T-Sql:
select count(distinct name)
from page-tag
where tag-id in (1, 3, 8)
This will give you a count of the number of different tag names for your list of ids |
How to remove debug statements from production code in Java |
|performance|java|debugging| |
Is it possible for the compiler to remove statements used for debugging purposes (such as logging) from production code? The debug statements would need to be marked somehow, maybe using annotations.
It's easy to set a property (debug = true) and check it at each debug statement, but this can reduce performance. It ... |
|java|debugging|compiler-construction| |
To directly answer your question: I don't know.
But here is another solution to your problem:
In my mind, there are two statements that collide with each other here: "debug statements" and "production code".
What is the purpose of debug statements? Help to get rid of bugs while (unit) testing. If a piece of sof... |
<xsl:variable name="length" select="count(nodeset)"/> |
I think [Windows PowerShell][1] from Microsoft is the current favourite for this sort of thing.
[1]: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx |
I would say yes, it was Anders Heljsberg's intent to make the observer pattern a first-class language feature with events in C#, based on his experience with Delphi. Anders makes this and other design intentions clear in an excellent interview on [Software Engineering Radio][1].
[1]: http://www.se-radio.net/podc... |
Agree with **Neall**, bit confusing the question.
If you want the output listed in the question, the sql is as simple as:
select page.content, page-tag.tag-id
from page, page-tag
where page.id = page-tag.pag-id
and page-tag.tag-id in (1, 3, 8)
order by page-tag.tag-id desc
But if you w... |
The basic setup looks ok.
The syntax can be simplified slightly by not defining an in-place pointcut and just specifying the method to which the after-advice should be applied. (The named pointcuts for methods are automatically created for you.)
e.g.
@After( "com.example.bg.web.controllers.assets.AssetAddC... |
Postback events from within DataView |
|c#|.net|postback|datatable|gridview| |
I'm presenting information from a DataTable on my page and would like to add some sorting functionality which goes a bit beyond a straight forward column sort. As such I have been trying to place LinkButtons in the HeaderItems of my GridView which postback to functions that change session information before reloading t... |
|c#|.net|postback|gridview|asp.net| |
|c#|.net|asp.net|gridview|postback| |
I'm presenting information from a DataTable on my page and would like to add some sorting functionality which goes a bit beyond a straight forward column sort. As such I have been trying to place LinkButtons in the HeaderItems of my GridView which postback to functions that change session information before reloading t... |
SQL Delete: can't specify target table for update in FROM clause |
|sql|delete| |
I have a table *story_category* in my database with corrupt entries. The next query returns the corrupt entries.
SELECT * FROM story_category WHERE category_id NOT IN (
SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id=category.id);
I tried to delete them excuting:
... |
> Suppose you have a TextBox in a window, and a ToolBar with a Save button in it. Assume the TextBox’s Text property is bound to a property on a business object, and the binding’s UpdateSourceTrigger property is set to the default value of LostFocus, meaning that the bound value is pushed back to the business object pr... |
I think you should describe your real problem behind this. I say this because you ask for somthing time efficient, yet the answer set to the problem seems to grow exponentially!
Therefore I wouln't expect a better algorithm than something exponential.
I'd do backtracking and going through the whole graph. In orde... |
[Setting Server Control Properties Based on Target Browser][1] and [more][2]. That one kinda took me by surprise.
[1]: http://ryanfarley.com/blog/archive/2008/08/14/set-browser-specific-asp.net-server-control-properties-and-taking-an.aspx
[2]: http://ryanfarley.com/blog/archive/2008/08/14/more-on-device-filteri... |
Do you use .config file? If so, check it for errors. Initialization errors of such sort are often triggered by invalid XML: if there are no errors in XAML, XML config is the first place to look. |
As a disclaimer I should add that I'm quite new to C but not exactly a newbie, so there might be bugs, or bad coding practices, please do correct me (and my grammar sucks too).
I personally didn't know about it until I came upon [this post](http://www.imperialviolet.org/page25.html#e498) by Adam Langley, I shall giv... |
As a disclaimer I should add that I'm quite new to C but not exactly a newbie, so there might be bugs, or bad coding practices, please do correct me (and my grammar sucks too).
I personally didn't know about it until I came upon [this post](http://www.imperialviolet.org/page25.html#e498) by Adam Langley, I shall giv... |
As a disclaimer I should add that I'm quite new to C but not exactly a newbie, so there might be bugs, or bad coding practices, please do correct me (and my grammar sucks too).
I personally didn't know about it until I came upon [this post](http://www.imperialviolet.org/page25.html#e498) by Adam Langley, I shall... |
As a disclaimer I should add that I'm quite new to C but not exactly a newbie, so there might be bugs, or bad coding practices, please do correct me (and my grammar sucks too).
I personally didn't know about it until I came upon [this post](http://www.imperialviolet.org/page25.html#e498) by Adam Langley, I shall... |
As a disclaimer I should add that I'm quite new to C but not exactly a newbie, so there might be bugs, or bad coding practices, please do correct me (and my grammar sucks too).
I personally didn't know about it until I came upon [this post](http://www.imperialviolet.org/page25.html#e498) by Adam Langley, I shall... |
Well, 1.20b7 is technically a *beta* version of Firebug. :)
I've had problems with certain features off and on, but a restart of Firefox seems to fix it more often than not. |
Here's a simple example: how many elements in a set. (there are better ways to count things, but this is a nice simple recursive example.)
First, we need two rules:
1. if the the set is empty, the count of items in the set is zero (duh!).
2. if the set is not empty, is one, plus the number of items in the set a... |
Here's a simple example: how many elements in a set. (there are better ways to count things, but this is a nice simple recursive example.)
First, we need two rules:
1. if the the set is empty, the count of items in the set is zero (duh!).
2. if the set is not empty, the count is one plus the number of items in ... |
We used the built in `soap/wsdlDriver` class, which is actually SOAP4R.
It's dog slow, but really simple. The SOAP4R that you get from gems/etc is just an updated version of the same thing.
Example code:
require 'soap/wsdlDriver'
client = SOAP::WSDLDriverFactory.new( 'http://site.com/service.wsdl' ).c... |
How do I close a parent Form from child form in Windows Forms 2.0? |
|c#|winforms| |
I have a need to close a parent form from within child form from a Windows application. What would be the best way to do this? |
As far as I remember, using ALL_CAPS for environment variables is the recommended practice in both Windows and *NIX worlds. My guess is Perl is just using some kind of legacy API to access the environment, and thus only retrieves the upper-case-only name for the variable.
In any case, you should never rely on someth... |
I was aware that Java 6 included scripting support, but I just recently discovered [jrunscript][1],
which can interpret and run JavaScript (and, one presumes, other scripting languages such as Groovy) interactively, sort of like the Python shell or irb in Ruby
[1]: http://java.sun.com/javase/6/docs/technotes/too... |
Linked in API |
|linked-in|social-media| |
Do you know if it's possible to build an application for the Linked In platform?
Thanks |
The Form class doesn't provide any kind of reference to the 'parent' Form, so there's no direct way to access the parent (unless it happens to be the MDI parent as well, in which case you could access it through the MDIParent property). You'd have to pass a reference to the parent in the constructor of the child, or a ... |
Definitely use `onload`. Keep your scripts separate from your page, or you'll go mad trying to disentangle them later. |
Here is an example of sending back a pdf.
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="name_of_file.pdf"');
header('Content-Transfer-Encoding: binary');
readfile($filename); |
Here is an example of sending back a pdf.
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
header('Content-Transfer-Encoding: binary');
readfile($filename); |
Here is an example of sending back a pdf.
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
header('Content-Transfer-Encoding: binary');
readfile($filename);
[@Swish](http://stackoverflow.com/questions/40943/how-to-automa... |
|mysql|delete| |
I have used [ASP.NET][1] Web Forms to make UI front-end to collection of command line application written in legacy language, RESTful-ish web service, and bash scripts.
Once it works on Firefox, it should work at least on Firefox on other architecture. If you haven't played around with it, you should give ASP.NET a ... |
That code sample tries to turn XmlReader style code into SAX style code - if you're writing code from scratch I'd just use XmlReader as it was intended - Pull not Push. |
Answering my own question, in two ways:
1) In VS2005/8, the things I mentioned (Tools/Options, External Tools) are all stored in the CurrentSettings.vssettings file, in the folder "Visual Studio 200{5|8}\Settings". This file is just XML, and it can be edited programmatically by anything that knows how to parse XML. ... |
Scripting the Visual Studio IDE |
|visual-studio|ide|scripting| |
I'd like to create a script that will configure the Visual Studio IDE the way I like it. Nothing vastly complicated, just a few Tools/Options settings, adding some External Tools, that kind of thing.
I know that this can be done inside VS with Import/Export Settings, but I'd like to be able to automate it from outs... |
|visual-studio|ide|scripting| |
I'd like to create a script that will configure the Visual Studio IDE the way I like it. Nothing vastly complicated, just a few Tools/Options settings, adding some External Tools, that kind of thing.
I know that this can be done inside VS with Import/Export Settings, but I'd like to be able to automate it from outs... |
I'd like to create a script that will configure the Visual Studio IDE the way I like it. Nothing vastly complicated, just a few Tools/Options settings, adding some External Tools, that kind of thing.
I know that this can be done inside VS with Import/Export Settings, but I'd like to be able to automate it from outs... |
As a disclaimer I should add that I'm quite new to C but not exactly a newbie, so there might be bugs, or bad coding practices, please do correct me (and my grammar sucks too).
I personally didn't know about it until I came upon [this post](http://www.imperialviolet.org/page25.html#e498) by Adam Langley, I shall... |
Ok, I’ve done a little more research into this now.
When you create a windows service in .Net, you create a class that inherits from System.ServiceProcess.ServiceBase (In VB this is hidden in the .Designer.vb file). You then override the OnStart and OnStop function, and OnPause and OnContinue if you choose to.
Thes... |
This is a UGLY hack but should also work
TextBox focusedTextBox = Keyboard.FocusedElement as TextBox;
if (focusedTextBox != null)
{
focusedTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
}
This code checks if a TextBox has focus... If 1 is found... update the binding s... |
' Pseudo code Assume zero based
<pre>
ResultString = InputArray[0]
n = 1
while n (is less than) Number_Of_Strings
ResultString (concatenate) ", "
ResultString (concatenate) InputArray[n]
n = n + 1
loop
</pre>
|
All of these solutions are decent ones, but for an underlying library, both independence of separator and decent speed are important. Here are two function that fits the requirement assuming the language has some form of string builder.
public static string join(String[] strings, String sep) {
if(strings.... |
All of these solutions are decent ones, but for an underlying library, both independence of separator and decent speed are important. Here is a function that fits the requirement assuming the language has some form of string builder.
public static string join(String[] strings, String sep) {
if(strings.len... |
The following is no longer language-agnostic (but that doesn't matter for the discussion because the implementation is easily portable to other languages). I tried to implement Luke's (theretically best) solution in an imperative programming language. Take your pick; mine's C#. Not very elegant at all. However, (withou... |
The most elegant solution i found for problems like this is something like
separator = ""
foreach(string in strings)
{
concatenatedString += separator + string
separator = ","
}
You just run the loop and only after the second time around the separator is set. So the first time... |