instruction stringlengths 0 30k ⌀ |
|---|
Python ReportLab use of splitfirst/splitlast |
|python|reportlab| |
I'm trying to use Python with ReportLab 2.2 to create a PDF report.
According to the [user guide](http://www.reportlab.com/docs/userguide.pdf),
> Special TableStyle Indeces [sic]
>
> In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that th... |
Merging 2 Collection<T> |
|c#| |
I got a Function that returns a Collection<string>, and that calls itself recursively to eventually return one big Collection<string>
Now, i just wonder what the best approach to merge the lists? Collection.CopyTo only copies to string[], and using a foreach() loop feels like being inefficient. However, ... |
I got a Function that returns a Collection<string>, and that calls itself recursively to eventually return one big Collection<string>
Now, i just wonder what the best approach to merge the lists? Collection.CopyTo only copies to string[], and using a foreach() loop feels like being inefficient. However, ... |
Crash Instantiating System.Xml.Serialization.XmlSerializer in C#. |
|c#|.net|serialization| |
We're seeing a crash when instantiating an instance of the System.Xml.Serialization.XmlSerializer class in a C# library. The crash occurs in the constructor, when it tries to add a duplicate key to a dictionary. I've included a stack trace below.
This crash is only occurring on one machine, and repairing our insta... |
How to attach debugger to step into native (C++) code from a managed (C#) wrapper? |
|c#|c++|visual-studio|debugging| |
I have a wrapper around a C++ function call which I call from C# code. How do I attach a debugger in Visual Studio to step into the native C++ code?
This is the wrapper that I have which calls GetData() defined in a C++ file:
[DllImport("Unmanaged.dll", CallingConvention=CallingConvention.Cdecl,
... |
You don't need any jQuery specific code to handle this. Just use a RegExp to replace them:
$("#a").className = $("#a").className.replace(/\bbg.*?\b/g, ''); |
You don't need any jQuery specific code to handle this. Just use a RegExp to replace them:
$("#a").className = $("#a").className.replace(/\bbg.*?\b/g, '');
You can modify this to support any prefix but the faster method is above as the RegExp will be compiled only once:
function removeClassByPrefix(el... |
ActiveX is used to enable the bridge between MOSS and Office, and as ActiveX is only on Windows, you will find that you cannot get the full experience if you do not use Windows as your OS. |
There is [Menees Diff][1] which will provide you with a C# diff implementation. The source code is included. I've used it in the past with good success wrapping it in my own implemenation.
[1]: http://www.menees.com/index.html |
There is [Menees Diff][1] which will provide you with a C# diff implementation. The source code is included. I've used it in the past with good success wrapping it in my own implemenation.
[1]: http://www.menees.com/DiffDotNet.htm |
You could use the [Text.Regex][1] package.
Your example might look something like this:
import Text.Regex(mkRegex, subRegex)
subs :: String -> String -> String -> String
subs wildcard input value = subRegex (mkRegex wildcard) input value
[1]: http://haskell.org/ghc/docs/latest/html/librarie... |
What are the most frequently used flow controls for handling protocol communication? |
|c|communication|protocols| |
I am rewriting code to handle some embedded communications and right now the protocol handling is implemented in a While loop with a large case/switch statement. This method seems a little unwieldy. What are the most commonly used flow control methods for implementing communication protocols? |
What is the most frequently used flow control for handling protocol communication? |
I am rewriting code to handle some embedded communications and right now the protocol handling is implemented in a While loop with a large case/switch statement. This method seems a little unwieldy. What is the most commonly used flow control method for implementing communication protocol? |
What are the most frequently used flow controls for handling protocol communication? |
I am rewriting code to handle some embedded communications and right now the protocol handling is implemented in a While loop with a large case/switch statement. This method seems a little unwieldy. What are the most commonly used flow control methods for implementing communication protocols? |
.Net will always replace your id values with some mangled (every so slightly predictable, but still don't count on it) value. Do you really NEED to have that id runat=server? If you don't put in runat=server, then it won't mangle it... |
.Net will always replace your id values with some mangled (every so slightly predictable, but still don't count on it) value. Do you really NEED to have that id runat=server? If you don't put in runat=server, then it won't mangle it...
ADDED:
Like leddt said, you can reference the span (or any runat=server with a... |
You don't need to include this information. Just provide a URI relative to the root.
Redirect temp /terms /articles/terms/
This is explained in <a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect">the mod_alias documentation</a>:
> The new URL should be an absolute URL beginning with a s... |
I believe (but I may be wrong) that these classes are the same as the BCGToolbar classes that were included in MFC when Microsoft bought BCG. If so, you can create a toolbar with and use the same ID on a toolbar button as in the menu items you want to create icons for, and they should appear automatically. Of course, y... |
Often you will return 0 to indicate success, and 1,2,3 etc to indicate different failures.
Your way of doing it is kinda hackish, because you can only have so many errors, and this kind of coding _will_ bite you sooner or later.
I like defining a struct/object that includes a Boolean to indicate success, and an e... |
I got it figured out.
I just pass the complete resolved url of the exe directory to the XSL transform that contains the HTML output with image tags:
XsltArgumentList lstArgs = new XsltArgumentList();
lstArgs.AddParam("absoluteRoot", string.Empty, Path.GetFullPath("."));
Then I just prefixed all the im... |
At start-up, you need to show a form and disable other menus etc. That way your user only ever sees your limited functionality and cannot directly open the tables etc.
This book excerpt, [Real World Microsoft Access Database Protection and Security][1], should be enlightening.
[1]: http://msdn.microsoft.com... |
Here is how I'll do that using a class variable, a class procedure and an initialization block:
unit MyObject;
interface
type
TMyObject = class
private
class var FLogger : TLogLogger;
public
class procedure SetLogger(value:TLogLogger);
end;
... |
Here is how I'll do that using a class variable, a class procedure and an initialization block:
unit MyObject;
interface
type
TMyObject = class
private
class var FLogger : TLogLogger;
public
class procedure SetLogger(value:TLogLogger);
class... |
Here's another interesting one from Scheme:
<pre>((lambda (x) (x x)) (lambda (x) (x x)))</pre>
|
When the array is resized, a new array must be allocated, and the contents copied. If you are only modifying the contents of the array, it is just a memory assignment.
So, you should not use arrays when you don't know the size of the array, or the size is likely to change. However, if you have a fixed length arr... |
The simple fact is that harddrives over a period of time will fail. The best two solutions
I can recommend unfortunately do not avail of using harddrives.
Using a tape backup, granted is slower but you get the flexibility of having the option of offsite backups. It is easy to put a tape in the boot of a car. Rotati... |
In your htaccess file, put the following
RewriteEngine On
RewriteRule ^([0-9]{6})$ /scriptname.php?no=$1 [R=301, L]
The first line turns the mod_rewrite engine on. The () brackets put the contents into $1 - successive () would populate $2, $3... and so on. The [0-9]{6} says look for a string precisely 6 ... |
In your htaccess file, put the following
RewriteEngine On
RewriteRule ^([0-9]{6})$ /scriptname.php?no=$1 [L]
The first line turns the mod_rewrite engine on. The () brackets put the contents into $1 - successive () would populate $2, $3... and so on. The [0-9]{6} says look for a string precisely 6 charact... |
Look at the generic List<T> as a replacement for arrays. They support most of the same things arrays do, including allocating an initial storage size if you want. |
Git pack file entry format |
|untagged| |
My understanding of the Git pack file format is something like:
![alt text][1]
[1]: http://content.screencast.com/users/aggieben/folders/Jing/media/dc42fabf-6fd6-47f3-9244-446b9ec04494/2008-09-16_1424.png
Where the table is 32-bits wide, and the first three 32-bit words are the pack file header. The last ro... |
You don't have to use regex if you are using the response to fill a div or something. You can use getElementsByTagName.
div.innerHTML = response;
var scripts = div.getElementsByTagName('script');
for (var ix = 0; ix < scripts.length; ix++) {
eval(scripts[ix].text);
} |
The best defense against leaks is a program structure which minimizes the use of malloc. This is not only good from a programming perspective, but also improves performance and maintainability. I'm not talking about using other things in place of malloc, but in terms of re-using objects and keeping very explicit tabs... |
Many possibilities. E.g.<br />
<code>
return str1.GetHashCode() ^ str1.GetHashCode()
</code> |
Perhaps something like str1.GetHashCode() + str2.GetHashCode()? or (str1.GetHashCode() + str2.GetHashCode()) / 2? This way it would be the same regardless of whether str1 and str2 are swapped.... |
You may find it easier to set up your tabs as follows:
M-x customize-group
At the `Customize group:` prompt enter `indent`.
You'll see a screen where you can set all you indenting options and set them for the current session or save them for all future sessions.
If you do it this way you'll want to [set... |
It's also good to run the [vimtutor][1] when learning these commands
[1]: http://www.linuxcommand.org/man_pages/vimtutor1.html |
For profiling your code, there's [Xdebug][1]. Doing regression testing with [Siege][2] can also be quite useful.
[1]: http://xdebug.org/docs/profiler
[2]: http://www.joedog.org/JoeDog/Siege |
There's no built-in way to do green threading in ActionScript. You have to write code to handle it.
Make a function that performs one iteration of whatever operation you want to do. It should return true or false depending on if its job is done or not. Now, you have to compute the time interval left to the next scre... |
Try out this one:
(((long)str1.GetHashCode()) + ((long)str2.GetHashCode())).GetHashCode() |
How do you implement GetHashCode for this structure? |
One of the biggest setbacks in high concurrency connections is actually the routers involved. Home user oriented routers usually have a small NAT table, preventing the router from actually servicing the server the connections.
Be sure to research your router/ network infrastructure setup just as well. |
I think you mean, as you're assigning not comparing:
> Isn't :
>
> Complex a, b, c; a = b + c;
>
> *much* simpler than:
>
> Complex a, b, c; a = b.add(c); |
Assuming Java as the implementation language then a, b, and c would all be references to type Complex with initial values of null. Also assuming that Complex is immutable as the mentioned [BigInteger][1] and similar immutable [BigDecimal][2], I'd I think you mean the following, as you're assigning the reference to the ... |
One important point to note is that it can make using percentage widths almost impossible. Take this for example, if you want your "content" div to take the full width, but have a 10px padding:
#content {
width: 100%;
padding: 0 10px;
}
That works in the (sensible, but incorrect) IE mod... |
Also, I think if you send as both text/plain and text/html, Gmail users (of the webmail UI) have no choice but to view the text/html version. |
Try this. It's a one-line addition to the Dispose() method, and calls the ancestor's dispose, if it exists. (Note that `Dispose(bool)` is not a member of `IDisposable`)
// Disposal Helper Functions
public static class Disposing
{
// Executes IDisposable.Dispose() if it exists.
public ... |
There is also the commands module:
import commands
status, output = commands.getstatusoutput("gvimdiff <(hg cat file.txt) file.txt")
There is also the popen set of functions, if you want to actually grok the data from a command as it is running.
namaste,
Mark |
Emacs query-replace with textual transformation |
|regex|emacs| |
I want to find any text in a file that matches a regexp of the form *t*`[A-Z]`*u* (i.e., a match *t* followed by a capital letter and another match *u*, and transform the matched text so that the capital letter is lowercase. For example, for the regexp `x[A-Z]y`
xAy
becomes
xay
and
xZy
bec... |
I want to find any text in a file that matches a regexp of the form *t*`[A-Z]`*u* (i.e., a match *t* followed by a capital letter and another match *u*, and transform the matched text so that the capital letter is lowercase. For example, for the regexp `x[A-Z]y`
xAy
becomes
xay
and
xZy
bec... |
Turn off your antivirus. It adds ages to the compile time. |
ThreadPool.QueueUserWorkItem(delegateThatSendsEmails)
or on System.Net.Mail.SmtpServer use the SendAsync method.
You want to put the email sending code on another thread, because then it will return the the user immediately, and will just process, no matter how long it takes. |
A bit of research turns up the fact that you can do it with a macro:
* Create a new macro (or use an existing one). You should see a module called `EnvironmentEvents` in Macro Explorer. (For details, see [here][1].)
* Open the `EnvironmentEvents` module.
* Put in this code:
Public Sub CloseDocsOnExit(... |
.NET ListView row padding |
|c#|listview| |
There doesn't seem to be a way to change the padding (or row height) for all rows in a .NET ListView. Does anybody have an elegant hack-around? |
It is possible. Once you start a new thread asynchronously from page, page request will proceed and send the page back to the user. The async thread will continue to run on the server but will no longer have access to the session.
If you have to show task progress, consider some Ajax techniques. |
These files contain user preference configurations that are in general specific to your machine, so it's better not to put it in SCM. Also, VC will change it almost every time you execute it, so it will allways be marked by the SCM as 'changed'.
I don't include both, I'm in a project using VC for 2 years and had no pr... |
In response to your edit: yes, what you describe will prevent doing upgrades (other than delete/reinstall) and remote configuration, since the MSI database won't know anything about the contents of your installer.
Many installer packages started MSI 'support' in this way, though: InstallShield did, for example. That... |
Ick.
In Unix pre-exception this is done with errno. You return 0 for success or -1 for failure, then you have a value you can retrieve with an integer error code to get the actual error. This works in all cases, because you don't have a (realistic) limit to the number of error codes. INT_MAX is certainly more than 7... |
Developing for an embedded, I have a loop that checks on a variable that can be changed in an interrupt handler. Without "volatile", the loop becomes a noop - as far as the compiler can tell, the variable never changes, so it optimizes the check away.
Same thing would apply to a variable that may be changed in a dif... |
Should I use a state machine or a sequence workflow in WF? |
|.net-3.5|com|interop|workflow|business-process-management| |
I have a repeatable business process that I execute every week as part of my configuration management responsibilities. The process does not change: I download change details into Excel, open the spreadsheet and copy out details based on a macro, create a Word document from an agenda template, update the agenda with th... |
The best thing you can do is allocate as much memory as you need upfront if possible. This will prevent .Net from having to make additional calls to get memory on the heap. Failing that then it makes sense to allocate in chunks of 5 or whatever number makes sense for your application.
This is a rule you can apply t... |
The `getTime()` method of `Date` returns the number of milliseconds since January 1, 1970 (this date is called the "epoch" because all computer dates are based off of this date). It should **not** be used to display a human-readable version of your Date.
Use the `SimpleDateFormat.format()` method instead. Here is ... |
A standard array should be defined with a length, which reserves all of the memory that it needs in a contiguous block. Adding an item to the array would put it inside of the block of already reserved memory. |
IE has a known bug with PNG gamma info, though I thought they had fixed it in version 7 :-?
I remove the gamma info from PNG files using "PNG Crush". I've created a right-click shortcut in Windows explorer. Further info: [using pngcrush in windows][1]
[1]: http://www.weirdlooking.com/blog/64 |
Use getenv() to get the value of an environment variable, then use sprintf or strcat to compose the path.
|
AI in games is very often implemented using State Machines.
Helps create discrete logic much easier to build and test. |
AI in games is very often implemented using State Machines.
Helps create discrete logic that is much easier to build and test. |
You could create a separate appdomain, using the sandboxing API in 2.0. MSDN [explains it][1] far better than I can. Of course then you're marshalling over appdomains; but if you want isolation that's the price you have to pay.
[1]: http://msdn.microsoft.com/en-us/magazine/cc163701.aspx |
ArrayList and List grow the array by more than one when needed (I think it's by doubling the size, but I haven't checked the source). They are generally the best choice when you are building a dynamically sized array.
When your benchmarks indicate that array resize is seriously slowing down your application (rememb... |
Arrays are great for few writes and many reads, particularly those of an iterative nature - for anything else, use one of the many other data structures. |
Wow, thanks for all the answers.
I had thought long and hard about the schema, and went with a record=night approach after trying the other way and having difficulty in converting to html.
I used CodeIgniter with the built in Calendar Class to display the booking info. Checking if a date was available was easier... |
You might also want to use something like BCEL to analyse which lines of source actually exist in the byte-code. You don't want to report that things like blank lines and comments haven't been covered. |
Yes, you're second code snippit is perfectly valid.
Every time -autorelease is sent to an object, it is added to the outer-most autorelease pool. When the pool is drained, it simply sends -release to all the objects in the pool.
Autorelease pools are simply a convenience that allows you to defer sending -release ... |
Adobe uses Perforce |
You can also use svnsync. This only requires read-only access on the source repository
[more at svnbook](http://svnbook.red-bean.com/en/1.4/svn.ref.svnsync.c.copy-revprops.html) |
You can have almost any character, including most Unicode characters! The exact definition is in [section 3.8 of the Java Language Specification][1].
However see [this question][2] for whether or not you should do that.
[1]: http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#40625
[2]... |
What's the best way to load highly re-used data in a .net web application |
|global-asax|onstart| |
Let's say I have a list of categories for navigation on a web app. Rather than selecting from the database for evey user, should I add a function call in the application_onStart of the global.asax to fetch that data into an array or collection that is re-used over and over. If my data does not change at all, would th... |
|caching|global-asax|onstart| |
Let's say I have a list of categories for navigation on a web app. Rather than selecting from the database for evey user, should I add a function call in the application_onStart of the global.asax to fetch that data into an array or collection that is re-used over and over. If my data does not change at all - (Edit -... |