instruction
stringlengths
0
30k
I'd like to suggest HTML Purifier (http://htmlpurifier.org/) It doesn't just filter the html, it basically tokenizes and re-compiles it. It is truly industrial-strength. It has the additional benefit of allowing you to ensure valid html/xhtml output. Also n'thing textile, its a great tool and I use it all the...
My first debugging action would be to look at the generated SQL: JobMaster newJobToCreate = new JobMaster(); newJobToCreate.JobID = 9999 newJobToCreate.ProjectID = "New Project"; this.UpdateJobMaster(newJobToCreate); this.Log = Console.Out; // prints the SQL to the debug console this.Sub...
Here is a bit of a brute force way: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:z="foo" > <xsl:output method="xml" indent="yes"/> <xsl:template match="z:row"> <xsl:element n...
I doubt you'll find much sympathy for help with pop-up ads.
Monkey patching is an (inelegant) option. For example, suppose you don't like the fact that Flex 3 SpriteAsset.as returns a default border metrics of [7,7,7,7] (unlike flex 2). To fix this, you can: 1. Create a copy of SpriteAsset.as and add it to your project at /mx/core/SpriteAsset.as 2. Edit your local copy t...
Windows Live Photo Gallery Wave 3 Beta includes this feature. From the help: > If you change the date and time > settings for more than one photo at > the same time, each photo's time stamp > is changed by the same amount, so that > the time stamps of all the selected > photos remain in their original > chrono...
In .NET you can fill a dataset from any source and then it can write that out to disk for you as XML with or without the schema. I can't say what performance for large sets would be like. Simple :)
[nsayer][1] mentions having a print button change the layout of your screen and then kicking off a window.print() This is a solution that will probably have been overlooked by a lot of people and should be considered when you think your users want a little more of a WYSIWYG. It should probably be a "printer friendl...
Use `var_export($_GET)` to more easily see what kind of array you are getting. From the output of your script I can see that you have multiple nested arrays. It seems to be something like: $_GET = array( array( array("Grade1", "ln", "North America", "yuiyyu", "iuy", "uiyui", "yui","uiy","0:0:5"))) so to ge...
Fade splash screen in and out
|c#|winforms|.net-2.0|splash-screen|
In a C# windows forms application. I have a splash screen with some multi-threaded processes happening in the background. What I would like to do is when I display the splash screen initially, I would like to have it appear to "fade in". And then, once all the processes finish, I would like it to appear as though the s...
`man ssh` gives me this options would could be useful. > -i identity_file Selects a file from which the identity (private key) for RSA or DSA authentication is read. The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro- ...
A JPG with sizes being multiplies of 8 can also be rotated/flipped with no quality loss. For example gthumb can do this on Linux.
I have now got the Mappoint control working but in a slightly different way. The control does appear on the list of controls the test container can use. I have tried reregistering it and unregistering it but still it doesn't appear on the list of controls when I try a "Insert ActiveX Control". However if I use "Add/Rem...
If you are going to manage your memory manually, you have two cases: 1. I created the object (perhaps indirectly, by calling a function that allocates a new object), I use it (or a function I call uses it), then I free it. 2. Somebody gave me the reference, so I should not free it. If you need to break any of th...
If you are going to manage your memory manually, you have two cases: 1. I created the object (perhaps indirectly, by calling a function that allocates a new object), I use it (or a function I call uses it), then I free it. 2. Somebody gave me the reference, so I should not free it. If you need to break any of th...
on some Windows PC, when I have both easyPHP and a standalone apache service configured on another network port and with a specific service name, I have a problem : when I stop easyphp, the other apache is stopped too. The problem do not occur on all PC I have, but seems very strange to me. Any idea? more inform...
I have no problem with Critic tests - admittedly I run at severity=3, at least in part because some of what I have to work with is legacy code that I don't have /time/ to tidy, but my Moose stuff sails through that.
The best I've come up with is def is_printable(c): if ord(c) > 31 or ord(c) == 9: return True return False def filter_non_printable(str): rv = '' for i in xrange(len(str)): if is_printable(str[i]): rv += str[i] return rv Is it good enough? Any better opt...
The best I've come up with now is (thanks to the python-izers above) def filter_non_printable(str): return ''.join([c for c in str if ord(c) > 31 or ord(c) == 9]) This is the only way I've found out that works with Unicode characters/strings Any better options?
I think you've been watching too many sci-fi movies. Why do I have the feeling you're the kind of guy who will bring about humanity's demise by letting loose the robots with deadly AI... Interesting thought though. I like it. :)
Variable declarations in header files - static or not?
|c++|static|
When refactoring away some #defines I came across declarations similar to the following in a C++ header file: static const unsigned int VAL = 42; const unsigned int ANOTHER_VAL = 37; The question is, what difference, if any, will the static make? Note that multiple inclusion of the headers isn't possibl...
|c|static|
Defence in depth is a good principle. But false security measures are a bad principle. The difference depends on a lot of details. If you're truly confident that any URL over N is invalid, then you may as well reject it. But if it's true, and if the rest of your input validation is correct, then it will get rejected...
It's not necessarily that bad provided you know what context you're using it in. If your application is using eval() to create an object from some JSON which has come back from an XMLHttpRequest to your own site, created by your trusted server-side code, it's probably not a problem. Untrusted client-side Javascri...
How to SelectAll / SelectNone in .NET 2.0 ListView?
|listview|selectall|
What is a good way to select all or select no items in a listview without using: foreach (ListViewItem item in listView1.Items) { item.Selected = true; } or foreach (ListViewItem item in listView1.Items) { item.Selected = false; } i know the underlying Win32 listview ...
I ask my customers *why* they need some feature. I try and get to the bottom of their request and identify the problem they are experiencing. This often lends itself to a simpler solution than I (or they) would think of. Of course, if you know your clients' work habits and what problems they have to tackle, you ca...
This has served us well: SQL> desc aux_values; Name Type ----------------------------------------- ------------ VARIABLE_ID VARCHAR2(20) VALUE_SEQ NUMBER DESCRIPTION ...
ActiveRecord doesn't know the object's id, in order to save the data. So include the id field in :select, like the example below: @users = User.find(:first, :select => "id, name, lastname, salary")
there: [openjdk javax.net][1] in the security group src/share/classes/javax/net src/share/classes/com/sun/net/ssl src/share/classes/sun/security/ssl src/share/classes/sun/net/www/protocol/https [1]: http://openjdk.java.net/groups/security/ also on this page: src/share/classes/javax...
How to wrap an existing memory buffer as a DC for GDI
|c#|.net|c++|vb.net|gdi+|
I have a memory buffer corresponding to my screen resolution (1280x800 at 24-bits-per-pixel) that contains my screen contents at 24bpp. I want to convert this to 8-bpp (ie. Halftone color palette in Windows). I currently do this: 1. Use CreateDIBSection to allocate a new 1280x800 24-bpp buffer and access it as a DC, ...
Change default port when registering a new SQL 2000 server
|sql-server|ports|enterprise-manager|
I'm trying to register an externally hosted SQL 2000 server through Enterprise Manager which isn't on the default port and I can't see anywhere to change it within Enterprise Manager. So, the question is, how do I connect to the database if: I.P Address is 123.456.789 (example) Port is 1334 Thanks in advanc...
I'm trying to register an externally hosted SQL 2000 server through Enterprise Manager which isn't on the default port and I can't see anywhere to change it within Enterprise Manager. So, the question is, how do I connect to the database if: I.P Address is 123.456.789 (example) Port is 1334 Thanks in advanc...
I tried the 'accepted' answer for PHP, which did not work for me. Then I did a little research, found a slight variant, tested it, and it worked. Here it is: header('Cache-Control: no-store, private, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0, ...
GnuPG: "decryption failed: secret key not available" error from gpg on Windows
for( int i = 0; variable ; ++i, variable >>= 1 ) { if( variable & 1 ) // store bit index - i }
[TagLib Sharp][1] is pretty popular. As a side note, if you wanted to take a quick and dirty peek at doing it yourself.. here is a C# snippet I found to read an mp3's tag info. class MusicID3Tag { public byte[] TAGID = new byte[3]; // 3 public byte[] Title = new byte[30]; ...
[TagLib Sharp][1] is pretty popular. As a side note, if you wanted to take a quick and dirty peek at doing it yourself.. here is a C# snippet I found to read an mp3's tag info. class MusicID3Tag { public byte[] TAGID = new byte[3]; // 3 public byte[] Title = new byte[30]; ...
How do I fix 404.17 error on Win Server 2k8 and IIS7
|asp.net|iis-7|
I've setup a new .net 2.0 website on IIS 7 under Win Server 2k8 and when browsing to a page it gives me a 404.17 error, claiming that the file (default.aspx in this case) appears to be a script but is being handled by the static file handler. It SOUNDS like the module mappings for ASP.Net got messed up, but they look ...
I'll bet your STL uses a checked implementation for debug. This is probably a good thing, as it will catch iterator overruns and such. If it's that much of a problem for you, there may be a compiler switch to turn it off. Check your docs.
How to set an HTTP header while using a Flex RemoteObject method ?
|blazeds|remoteobject|flash|apache-flex|http-headers|
I am running blazeds on the server side. I would like to filter http requests using an http header. My goal is to implement a security mechanism without changing the signatures of my blazeds services. On the client side, I am using Flex **RemoteObject** methods. With Flex WebService components, it is possible to...
|apache-flex|flash|http-headers|blazeds|remoteobject|
I am running blazeds on the server side. I would like to filter http requests using an http header. My goal is to send extra parameters to the server without changing the signatures of my blazeds services. On the client side, I am using Flex **RemoteObject** methods. With Flex WebService components, it is possib...
I personally use [Tapestry 5][1] for creating webpages with Java, but I agree that it can sometimes be a bit overkill. I would look into using JAX-RS ([java.net project][jax-1], [jsr311][jax-2]) it is pretty simple to use, it supports marshalling and unmarshalling objects to/from XML out of the box. It is possible to e...
I printed out and looked over [Design Patterns in Ocaml][1], and they use modules and functors (and objects) to recreate the normal design patterns we are used to. It's interesting, but I think they use objects _too_ much to really see the benefit of functional languages. FP is very composable, part of it's nature. I g...
You can use the HttpWebRequest class to perform a request and retrieve a response from a given URL. You'll use it like: Try Dim fr As System.Net.HttpWebRequest Dim targetURI As New Uri("http://whatever.you.want.to.get/file.html") fr = DirectCast(System...
You can use the HttpWebRequest class to perform a request and retrieve a response from a given URL. You'll use it like: Try Dim fr As System.Net.HttpWebRequest Dim targetURI As New Uri("http://whatever.you.want.to.get/file.html") fr = DirectCast(HttpWebRequest.Cr...
|gnupg|gnu|windows-xp|
Environment: HP laptop with Windows XP SP2 I had created some encrypted files using GnuPG (gpg) for Windows. Yesterday, my hard disk failed so I had reimage the hard disk. I have now reinstalled gpg and recreated my keys using the same passphrase as earlier. But, I am now unable to decrypt the files. I get the f...
|windows-xp|gnu|gnupg|
Environment: HP laptop with Windows XP SP2 I had created some encrypted files using GnuPG (gpg) for Windows. Yesterday, my hard disk failed so I had reimage the hard disk. I have now reinstalled gpg and regenerated my keys using the same passphrase as earlier. But, I am now unable to decrypt the files. I get the...
Also for database access I have a set of functions - GetSingleRecord, GetRecordset and UpdateDatabase which has similar function to what Michael mentions above
You can attach javadoc to any library you have configure in your module or project. Just access the project settings windows, then select "modules" and select the module that has the dependency you want to configure. Then select the "Dependencies" tab, select the dependency that's missing the javadoc and click "Edit...
.NET: Get all Outlook calendar items
|.net|c#|outlook|calendar|recurring|
Depends on your exact requirements. If you allow JavaScript and allow frames then you can stick a hidden frame within a frameset on your page into which you load some JavaScript. This JavaScript will then control the content of the main frame using the window.location object and setTimeout function. The downside wou...
You can use the Opacity property for the form to alter the fade (between 0.0 and 1.0).
We had to do something similar (i.e. inner join 2 data sources from different server into 1). I believe the best way is to write your own custom Data Extension. It's not very difficult and it would give you the ability to do this and more.
We had to do something similar (i.e. inner join 2 data sources from different servers). I believe the best way is to write your own custom Data Extension. It's not very difficult and it would give you the ability to do this and more.
The resources it is refering to are those used by the threads for receiving/handling the messages. You can monitor the thread pool size & other resources using the Taskmanager (look at View->Select Columns). It it may help you identify the specific resource if the consumer is resource locked, look for a resource coun...
Drill down through ListviewItemCollection and you can set the Selected property for individual items to true. This will, I believe, emulate the "multi-select" feature that you are trying to reproduce. (Also, as the above commenter mentioned, be sure to have the MultiSelect property of the lisetview set to true.)
You could use a timer to modify the [Form.Opacity level][1]. [1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.opacity(VS.80).aspx
Create a wrapper HTML page with an IFrame in it, sized at `100% x 100%`. Then add in some javascript that changes the `src` of the IFrame between set intervals.
The naive approach is to find the distance between the red and 50 blue objects -- so you're looking at 50 3d Pythagorean calculations + sorting to find the answer. That would only really work for finding the distance between center points though. If you want arbitrary polygons, maybe your best best is a raytracing s...
Which is the best tool for automatic GUI performance testing?
|performance|testing|user-interface|
We are currently testing a Java Swing application for it's performance. I wonder if there is a good tool to automate this?
The "sample" editor scite uses the bookmark feature to bookmark all the lines that match the search result.
One other thing worth mentioning: the design philosophy of both framework is somewhat different when it comes to the model. Grails is more "domain-oriented" while Rails is more "database-oriented". In Rails, you essentially start by defining your tables (with field names and their specifics). Then ActiveRecord will ...
in our working enviroment we have to use the free Oracle JDeveloper ... *sigh* .. at home I tend to use Eclipse more and I really like it
The bank account must either be tied to a person (via SSN), or a corporation (via TIN). You'd have better luck tying it to a personal account because while a corporation **sounds** like what you're looking for, there are other costs involved such as state and federal taxes which would cause the corporation to be disso...
Assuming that these declarations are at global scope (i.e. aren't member variables), then: **static** means 'internal linkage'. In this case, since it is declared **const** this can be optimised/inlined by the compiler. If you omit the **const** then the compiler must allocate storage in each compilation unit. By...
*The Python Cookbook* is absolutely essential if you want to master idiomatic Python. Besides, that's the book that made me fall in love with the language.
(Security) Should I reject URLS longer than N?
|security|web-services|rest|
I am trying to write an application that uses pretty URLS or REST (still learning what this entails). Anyway my urls look like www.foo.net/some_url/some_parameter/some_keyword. I can be sure a url will never exceed N characters. Should I validate the url length with every request in order to protect against buffer over...
STL containers should not run "really slowly" in debug or anywhere else. Perhaps you're misusing them. You're not running against something like ElectricFence or Valgrind in debug are you? They slow anything down that does lots of allocations. All the containers can use custom allocators, which some people use to im...
An approach we use in our projects is to create a service for each view you have. Then the view fetches the sub-graph you need for this specific view, always trying to reduce the number of sqls send to the database. Therefore we are using a lot of joins to get the n:1 associated objects. If you are using a 2-tier de...
If the URL works fine in the web browser on the same machine, it might be that the Java code isn't using the HTTP proxy the browser is using for connecting to the URL.
In at least PHP4, connection_aborted and connection_status only worked after the script sent any output to the browser (using: flush() | ob_flush()). Also don't expect accurately timed results. It's mostly useful to check if there is still someone waiting on the other side.
You may need to set the HomeDrive property as well: DirectoryEntry deUser = new DirectoryEntry(findMeinAD(tbPNUID.Text)); deUser.InvokeSet("HomeDirectory", tbPFolderVerification.Text); deUser.InvokeSet("HomeDrive", "Z:"); deUser.CommitChanges();
Towards answering the updated question, its a chicken/egg problem. The best way to justify an expense is to show how it reduces a cost somewhere else, so you may need to spend some extra/personal time to learn something first to build some kind of functional prototype. Show your boss a demo like "hey, i did this th...
Run your program with -Dlog4j.debug so that standard out gets info about how log4j is configured -- I suspected that it isn't configured the way that you think it is.
If you have to use the exact format you specified, then you need to parse it yourself. Here is a simple example (not tested): var str:String = "9/17/2008 10:30" var items:Array = str.split(" "); var dateElements:Array = items[0].split("/"); var timeElements:Array = items[1].split(":"); var n:Date = n...
You could use Builder instead of creating your to_xml method, and you could use XMLSimple to pull your xml file into a Hash instead of using the from _xml method. Unfortunately, I'm not sure you'll really gain all that much from using these techniques.
How can I get all items from a specific calendar (for a specific date). Lets say for instance that I have a calendar with a recurring item every Monday evening. When I request all items like this: CalendarItems = CalendarFolder.Items; CalendarItems.IncludeRecurrences = true; I only get 1 item... Is ...
|c#|.net|outlook|calendar|recurring|