instruction
stringlengths
0
30k
I'm looking at sessions in Django, and by default they are stored in the database. What are the benefits of filesystem and cache sessions and when should I use them?
|python|django|caching|session|
You can't create an array in .NET (as opposed to declaring a reference to it, which is what you did in your example) without specifying its dimensions, either explicitly, or implicitly by specifying a set of literal values when you initialize it. (e.g. int[,] array4 = { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };) You...
I generally use the nicer collections for this sort of work (List<T>, ArrayList etc.) and then (if really necessary) cast to T[,] when I'm done.
you would either need to preallocate the array to a Maximum size (float[999,22] ) , or use a different data structure. i guess you could copy/resize on the fly.. (but i don't think you'd want to) i think the List<float[]> sounds reasonable.
One way to handle this would be to use the context menu's Popup event to grab the selected index of the combobox launching the menu. When the dialog form closes reset the selected index.
I would just use a list, then convert that list into an array. You will notice here that I used a jagged array (float[][]) instead of a square array (float [,]). Besides being the "standard" way of doing things, it should be much faster. When converting the data from a list to an array you only have to copy [calibra...
static void Main(string[] args) { NorthwindDataContext db = new NorthwindDataContext(); var query = db.Customers; string json = query.GetJsonTable<Customer>(2, 10, "CustomerID", new string[] {"CustomerID", "CompanyName", "City", "Country", "Orders.Count" }); } public static cla...
davidg was on the right track, and I am crediting him with the answer. But the WMI query necessary was a little less than straightfoward, since I needed not just a list of users for the whole machine, but the subset of users *and groups*, whether local or domain, that were members of the local Administrators group. ...
@[Jared](#24024): > Non-overloaded, non-inherited static methods (like Class.b(a,c)) that take an instance as the first variable are semantically equivalent to a method call (like a.b(c)) No, they aren't. > (Assuming it compiles to the same CIL, which it should.) That's your mistake. The CIL produced is dif...
I've been building a few sites with the framework since the first preview came out, and it has certainly come a long way already. It feels like a very light-weight and tidy framework. There are a couple of areas where I think it really excels over "vanilla" asp.net: - Enables a much cleaner separation of concerns...
"Reflection" is a language's ability to inspect and dynamically call classes, methods, attributes, etc. at runtime. For example, all objects in Java has the method <b>getClass</b>, which lets you determine its class even if you don't know it at compile time (like if you declared it as <b>Object</b>) - this might seem t...
"Reflection" is a language's ability to inspect and dynamically call classes, methods, attributes, etc. at runtime. For example, all objects in Java has the method <b>getClass</b>, which lets you determine its class even if you don't know it at compile time (like if you declared it as <b>Object</b>) - this might seem t...
> Johannes: > >> @PConroy: This was my initial thougt also. the interesting part on this is to find good transformation rules for the different parts of the address! Any good suggestions? When we were working on this type of project before, our approach was to take our existing corpus of addresses (150k or so), t...
*@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.* ***Edit:** So I can't mark this as the answer, prob...
*@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.* ***Edit:** So I can't mark this as the answer, prob...
This one's not specifically about development, but [Security Now][1] from Steve Gibson and Leo Laporte is an excellent discussion of security issues. I think it's a must-listen for just about any computer user who's concerned about security, and especially for web developers who are responsible both for the security o...
Is your customer using Exchange 2007? If so, I'd have a look at [Exchange Web Services][1]. If not, as hairy as it can be, I think WebDAV is your best bet. Personally I don't like using the Outlook.Application COM object route, as its security prompts ("An application is attempting to access your contacts. Allo...
The responses to this question have got more than a little confused. The title asks about disposal, but then says that they want memory back immediately. .Net is *managed*, which means that when you write .Net apps you don't need to worry about memory directly, the cost is that you don't have direct control over ...
The responses to this question have got more than a little confused. The title asks about disposal, but then says that they want memory back immediately. .Net is *managed*, which means that when you write .Net apps you don't need to worry about memory directly, the cost is that you don't have direct control over ...
Reflection
|reflection|java|
What is reflection, and why is it useful? I'm particularly interested in Java, but I assume the principles are the same in any language(?).
What is reflection, and why is it useful?
|java|reflection|
What is reflection, and why is it useful? I'm particularly interested in Java, but I assume the principles are the same in any language(?).
Examining Berkeley DB files from the CLI
|linux|command-line-interface|berkeley-db|
I have a set of Berkeley DB files on my Linux file system that I'd like to examine. What useful tools exist for getting a quick overview of the contents? I can write Perl scripts that use BDB modules for examining them, but I'm looking for some CLI utility to be able to take a look inside without having to start wri...
I have found these two links useful: Using CLR and single audit table.<br /> [http://www.sqljunkies.ddj.com/Article/4CD01686-5178-490C-A90A-5AEEF5E35915.scuk][1] Using triggers and seperate audit table for each table being audited.<br /> [http://sqlserver2000.databases.aspfaq.com/how-do-i-audit-changes-to-sql-s...
# Visual Basic: Linq <Extension()> _ Public Function Product(ByVal xs As IEnumerable(Of Integer)) As Integer Return xs.Aggregate(1, Function(a, b) a * b) End Function Public Function Fact(ByVal n As Integer) As Integer Return Aggregate x In Enumerable.Range(1, n) Into Product()...
Follow-up to my previous posting. Templates are one of the main reasons why C++ fails so abysmally at intellisense, regardless of the IDE used. Because of template specialization, the IDE can never be really sure if a given member exists or not. Consider: template <typename T> struct X { void fo...
I believe JWebPane is going to be the official way to embed a browser into a java app. Its based on the open sourced engine - WebKit, which is used in Apples Safari and Googles Chrome browsers.See [this blog][1] for details. [1]: http://weblogs.java.net/blog/ixmal/archive/2008/05/introducing_jwe.html
How to use webclient in a secure site?
|screen-scraping|
I need to automate a process involving a website that is using a login form. I need to capture some data in the pages following the login page. I know how to screen-scrape normal pages, but not those behind a secure site. 1. Can this be done with the WebClient class? - How would I automatically login? - How wo...
|.net|screen-scraping|
I need to automate a process involving a website that is using a login form. I need to capture some data in the pages following the login page. I know how to screen-scrape normal pages, but not those behind a secure site. 1. Can this be done with the .NET WebClient class? - How would I automatically login? - H...
Composite is used extensively in UI. Components can be leaf components e.g. buttons and labels or composites e.g. panels, that can contain other leaf or composite components. From the point of view of the client, all components are treated the same, which greatly simplifies the client code.
Setting DataGridView.DefaultCellStyle.NullValue to null at designtime raises error at adding rows runtime.
|c#|datagridview|null|
In Visual Studio 2008 - add a new DataGridView to a form - Edit Columns - Add a a new DataGridViewImageColumn - Open the CellStyle Builder of this column (DefaultCellStyle property) - Change the NullValue from System.Drawing.Bitmap to null - Try to add a new Row to the DataGridView at runtime (...
I think you should base your server class on the [SocketServer][1] class from the standard library. You'll need to write a `RequestHandler` to read and echo input but a lot of the heavy lifting is already done for you. You can use the [ThreadingMixIn][2] to make the server multi-threaded very easily. [1]: ...
I think you should base your server class on the [`SocketServer`][1] class from the standard library. You'll need to write a `RequestHandler` to read and echo input but a lot of the heavy lifting is already done for you. You can use the [`ThreadingMixIn`][2] to make the server multi-threaded very easily. [...
Carlton : Alfresco seems to be a Java based solution. Ta: I've looked into the plugin folders but none was really good for asp.net mvc. What I'm now testing is a mix between Tiny with the image uploader of FCKEditor: this is the pho version but I think it is pretty easy to convert to .net [Tinyfck][1] [1]: th...
Mark-up is a term from print editing - the editor would go through the text and add annotations (i.e. this in italic, that in bold) for the printers to use when producing the final version. This was called marking up the text. A computer mark-up language is just a standardised short-hand for these sorts of annotatio...
>Isn't it a security flaw of the site to let hackers throw everything in their arsenal against the site? Well, you should focus on closing holes, rather than trying to thwart scanners (which is a futile battle). Consider running such tests yourself.
It's good that you block bad request after a couple of trials, but you should let it continue. If you block it after 5 bad requests you won't know if the 6th request wouldn't crash your site. EDIT: I meant that some attacker might send only one request but similar to one of those 1495 that You didn't test because...
According to [wikipedia][1] Fib(0) should be 0 but it does not matter. Here is simple C# solution with for cycle: ulong Fib(int n) { ulong fib = 1; // value of fib(i) ulong fib1 = 1; // value of fib(i-1) ulong fib2 = 0; // value of fib(i-2) for (int i = 0; i < n; ...
According to [wikipedia][1] Fib(0) should be 0 but it does not matter. Here is simple C# solution with for cycle: ulong Fib(int n) { ulong fib = 1; // value of fib(i) ulong fib1 = 1; // value of fib(i-1) ulong fib2 = 0; // value of fib(i-2) for (int i = 0; i < n; ...
If you're referring to simply accessing your IIS server from a remote location, remote desktop generally solves that problem. Assuming your server has a static IP address or a host name you can access from the internet, remote desktop is a simple and relatively secure solution.
If you're referring to simply accessing your IIS server from a remote location, remote desktop generally solves that problem. Assuming your server has a static IP address or a host name you can access from the internet, remote desktop is a simple and relatively secure solution. Is there a problem with this answer? ...
Something like this should work. ( though, you **will** want to change the interval ) public Form1() { InitializeComponent(); Timer Every4Minutes = new Timer(); Every4Minutes.Interval = 10; Every4Minutes.Tick += new EventHandler(MoveNow); Every4Minutes.Start(); ...
Python - How do I tell what OS I'm running on?
|python|
What do I need to look at to see if I'm on Windows, Unix, etc?
This is an active area of research. There are literally oodles of academic papers on the subject. It's going to be difficult to give you assistance especially w/o more deatails. Are you looking for specific types of text? Fonts? English-only? Are you familiar with the academic literature? "Text detection" is a stan...
>>> import os >>> print os.name posix >>> import platform >>> platform.system() 'Linux' >>> platform.release() '2.6.22-15-generic' See: <http://docs.python.org/lib/node441.html>
How can I programmatically determine if my workstation is locked?
|c#|productivity|
I'm writing up some productivity/metrics tools for myself to help monitor my focus throughout the day. Recently, I've noticed that I tend to get off track more than usual and feel the need to get up and go for walks/drinks/etc and I'm concerned that I'm "wasting" too much time. Since I always lock my computer when I...
I'm writing up some productivity/metrics tools for myself to help monitor my focus throughout the day. Recently, I've noticed that I tend to get off track more than usual and feel the need to get up and go for walks/drinks/etc and I'm concerned that I'm "wasting" too much time. Since I always lock my computer when I...
You could also use a two-dimensional ArrayList (from System.Collections) -- you create an ArrayList, then put another ArrayList inside it. This will give you the dynamic resizing you need, but at the expense of a bit of overhead.
Without native code, you can only tell whether the current thread holds the lock. You can't tell what thread, if any, holds it if it isn't the current thread.
You can only tell whether the current thread holds a normal lock (`Thread.holdsLock(Object)`). You can't get a reference to the thread that has the lock without native code. However, if you're doing anything complicated with threading, you probably want to familiarize yourself with the java.util.concurrent packages....
That's what I would like to avoid if properly, but this seems to be much more complicated than excepted. Normally, everyone advises using the AsyncPostBackError of the ScriptManager, but this does not work if called on the Global.asax. Unfortunately, as the HttpRequestValidationException is emitted by the runtime, i...
That's what I would like to avoid if possible, but this seems to be much more complicated than expected. Normally, everyone advises using the AsyncPostBackError of the ScriptManager, but this does not work if called on the Global.asax. Unfortunately, as the HttpRequestValidationException is emitted by the runtime, i...
Have a look at [EasyListBox][1]. I used on a project and while a bit quirky at first, got the job done. [1]: http://www.easylistbox.com/home.aspx
I would just use Red Gate's ANTS Profiler. It will tell you a lot about what's going on in memory without you having to learn the profiling API yourself.
In general, the problem is one of using two different "constants" for form layout, and then changing one of those constants without changing the other. You are using pixels for your form entities, and points (basically inches) to specify font size. Pixels and points are related by DPI, so you change the DPI and sud...
In all versions of MySQL, simply alias the aggregate in the SELECT list, and order by the alias: SELECT COUNT(id) AS theCount, `Tag` from `images-tags` GROUP BY `Tag` ORDER BY theCount DESC LIMIT 20
programmatically retrieve Visual Studio install directory
|visual-studio|
I know there is a registry key indcating the install directory, but don't remember what it is off-hand. Currently interested in VS2008 install directory, though it wouldn't hurt to list others for future reference.
Well, since you only have a four element array you may just want ot unroll the recursion to save time. Passing arrays as arguments will eat up memory and leave a mess for the GC to clean up later.
UK Government Data Standards Catalogue suggests 35 characters for each of Given Name and Family Name, or 70 characters for a single field to hold the Full Name: [http://www.govtalk.gov.uk/gdsc/html/noframes/PersonName-1-1-Release.htm][1] [1]: http://www.govtalk.gov.uk/gdsc/html/noframes/PersonName-1-1-Release...
Use the [Version](http://msdn.microsoft.com/en-us/library/system.version.aspx) class. Version a = new Version("1.0.0.0"); Version b = new Version("2.0.0.0"); Console.WriteLine(string.Format("Newer: {0}", (a > b) ? "a" : "b")); // prints b
I'm sure there's a registry entry as well but I couldn't easily locate it. There is the VS90COMNTOOLS environment variable that you could use as well.
If you can assume that each place in the version string will only be one number (or at least the last 3, you can just remove the commas or periods and compare...which would be a lot faster...not as robust, but you don't always need that. public static int CompareVersions(string strA, string strB) { ...
I kept digging around some of the "major" frameworks and it seems that Django does exactly what I was talking about. Or so it seems from this [screencast][1]. Does anyone have any remark to make about this? Does it work well? [1]: http://www2.lamptraining.com/screencast/1/
[Jboss clustering][1] was very easy to get up and running. It seems to work well for us. [1]: http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html
For non developer tools try Microsoft Action Pack https://partner.microsoft.com/40016455 Then use Visual Studio Professional (in some exibitions you will get this for free) For the versioning use svn and not TeamSystem
I'm no expert, but from what I learned so far the golden rule is not to trust any user data (GET, POST, COOKIE). Common attack types and how to save yourself: 1. [SQL Injection Attack][1]: Use prepared queries 2. [Cross Site Scripting][2]: Send no user data to browser without filtering/escaping first. This also inc...
I my applications I usually have `setup.php` file that includes all core classes (i.e. framework and accompanying libraries). My custom classes are loaded using autoloader aided by directory layout map. Each time new class is added I run command line builder script that scans whole directory tree in search for model...
Checkout Netbeans, it's written in Java so you'll have the same environment regardless of your OS, and it supports a lot more than just C++. I'm not going to try to convince you, because I think IDEs can be a very personal choice. For me it improves my productivity by being fast, supporting the languages I code in a...
Outlook Add-in using .NET
|.net|outlook|add-in|
Follow-up to my previous posting. Templates are one of the main reasons why C++ fails so abysmally at intellisense, regardless of the IDE used. Because of template specialization, the IDE can never be really sure if a given member exists or not. Consider: template <typename T> struct X { void fo...
Two alternatives 1. Use a temporary table 2. Investigate the [XOR algorithm][1] [1]: http://en.wikipedia.org/wiki/XOR_swap_algorithm
To add an answer to my own question: A different way of doing it is ask users for their mobile phone number, send them a text msg for verification. This stops most people messing with duplicate addresses. I'm talking from personal experience. (thanks [pigsback][1] !) They introduced confirmation through mobile p...
Reflection is a key mechanism to allow an application or framework to work with code that might not have even been written yet! Take for example your typical web.xml file. This will contain a list of servlet elements, which contain nested servlet-class elements. The servlet container will process the web.xml file, a...
I heard lot of good about [Django Schema Evolution Branch](http://code.google.com/p/deseb/) and those were opions of actual users. It mostely works out of the box and do what it should do.
As [kronoz said](#47776) in .Net 3.5 you can use `Distinct()`. In .Net 2 you could mimic it: public IEnumerable<T> DedupCollection<T> ( IEnumerable<T> input ) { List<T> passedValues = new List<T>(); //relatively simple dupe check alg used as example foreach( T item in input) ...
I agree, it gives me the *it works but it feels like a hack* feeling. I try to avoid reflection whenever possible. I have been burned many times after refactoring code which had reflection in it. Code compiles fine, tests even run, but under special circumstances (which the tests didn't cover) the program blows up ...
I agree, it gives me the *it works but it feels like a hack* feeling. I try to avoid reflection whenever possible. I have been burned many times after refactoring code which had reflection in it. Code compiles fine, tests even run, but under special circumstances (which the tests didn't cover) the program blows up ...
PHP callbacks are structures that "point" to global functions, object methods, or static methods of a class. This allows some level of functional programming in PHP before 5.3. The 3 flavors are: $cb1 = 'someGlobalFunction'; $cb2 = array(&$obj, 'somePublicMethod'); $cb3 = array('ClassName', 'someStatic...
PHP callbacks are structures that "point" to global functions, object methods, or static methods of a class. This allows some level of functional programming in PHP before 5.3. The 3 flavors are: $cb1 = 'someGlobalFunction'; $cb2 = array(&$obj, 'somePublicMethod'); $cb3 = array('ClassName', 'someStatic...
I am very happy with RedGate ANTS. The only other one I tried was the one that comes with Visual Studio Team, and it sucks.
signed to unsigned conversion in C - is it always safe?
|c|