question_id
int64
4
6.31M
answer_id
int64
7
6.31M
title
stringlengths
9
150
question_body
stringlengths
0
28.8k
answer_body
stringlengths
60
27.2k
question_text
stringlengths
40
28.9k
combined_text
stringlengths
124
39.6k
tags
listlengths
1
6
question_score
int64
0
26.3k
answer_score
int64
0
28.8k
view_count
int64
15
14M
answer_count
int64
0
182
favorite_count
int64
0
32
question_creation_date
stringdate
2008-07-31 21:42:52
2011-06-10 18:12:18
answer_creation_date
stringdate
2008-07-31 22:17:57
2011-06-10 18:14:17
109,154
109,627
.NET Reporting Tutorial
Does anyone know a Tutorial for the Reporting in C#.NET. I mean the Reports in "Microsoft.Reporting" Namespace (not Crystal Reports).
I know you probably aren't looking for links that you can find on google yourself, but these cover reporting services in great detail and should cover most of your questions. Reporting Services Tutorials Intro to reporting services Reporting Services in Action Webcasts on Reporting Services Useful reporting services li...
.NET Reporting Tutorial Does anyone know a Tutorial for the Reporting in C#.NET. I mean the Reports in "Microsoft.Reporting" Namespace (not Crystal Reports).
TITLE: .NET Reporting Tutorial QUESTION: Does anyone know a Tutorial for the Reporting in C#.NET. I mean the Reports in "Microsoft.Reporting" Namespace (not Crystal Reports). ANSWER: I know you probably aren't looking for links that you can find on google yourself, but these cover reporting services in great detail a...
[ "c#", ".net", "reporting" ]
3
7
7,918
1
0
2008-09-20T19:56:15.187000
2008-09-20T22:31:47.450000
109,179
110,190
Strict vs NonStrict NHibernate cache concurrency strategies
This question is about the difference between ReadWrite and NonStrictReadWrite cache concurrency strategies for NHibernate's second level cache. As I understand it, the difference between these two strategies is relevant when you have a distributed replicated cache - nonstrict won't guarantee that one cache has the exa...
What you assume is right, in a single target/thread environment there's little difference. However if you look at the cache providers there is a bit going on even in a multi-threaded scenario. How an object is re-cached from it's modified state is different in the non-strict. For example, if your object is much heftier...
Strict vs NonStrict NHibernate cache concurrency strategies This question is about the difference between ReadWrite and NonStrictReadWrite cache concurrency strategies for NHibernate's second level cache. As I understand it, the difference between these two strategies is relevant when you have a distributed replicated ...
TITLE: Strict vs NonStrict NHibernate cache concurrency strategies QUESTION: This question is about the difference between ReadWrite and NonStrictReadWrite cache concurrency strategies for NHibernate's second level cache. As I understand it, the difference between these two strategies is relevant when you have a distr...
[ "nhibernate", "caching" ]
13
19
3,419
2
0
2008-09-20T20:04:59.253000
2008-09-21T03:43:15.597000
109,186
109,340
Bypass invalid SSL certificate errors when calling web services in .Net
We are setting up a new SharePoint for which we don't have a valid SSL certificate yet. I would like to call the Lists web service on it to retrieve some meta data about the setup. However, when I try to do this, I get the exception: The underlying connection was closed: Could not establish trust relationship for the S...
The approach I used when faced with this problem was to add the signer of the temporary certificate to the trusted authorities list on the computer in question. I normally do testing with certificates created with CACERT, and adding them to my trusted authorities list worked swimmingly. Doing it this way means you don'...
Bypass invalid SSL certificate errors when calling web services in .Net We are setting up a new SharePoint for which we don't have a valid SSL certificate yet. I would like to call the Lists web service on it to retrieve some meta data about the setup. However, when I try to do this, I get the exception: The underlying...
TITLE: Bypass invalid SSL certificate errors when calling web services in .Net QUESTION: We are setting up a new SharePoint for which we don't have a valid SSL certificate yet. I would like to call the Lists web service on it to retrieve some meta data about the setup. However, when I try to do this, I get the excepti...
[ ".net", "web-services", "sharepoint" ]
91
18
150,135
8
0
2008-09-20T20:07:16.987000
2008-09-20T20:51:42.263000
109,188
109,195
How do I check if a directory is writeable in PHP?
Does anyone know how I can check to see if a directory is writeable in PHP? The function is_writable doesn't work for folders. Edit: It does work. See the accepted answer.
Yes, it does work for folders.... Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.
How do I check if a directory is writeable in PHP? Does anyone know how I can check to see if a directory is writeable in PHP? The function is_writable doesn't work for folders. Edit: It does work. See the accepted answer.
TITLE: How do I check if a directory is writeable in PHP? QUESTION: Does anyone know how I can check to see if a directory is writeable in PHP? The function is_writable doesn't work for folders. Edit: It does work. See the accepted answer. ANSWER: Yes, it does work for folders.... Returns TRUE if the filename exists ...
[ "php", "permissions", "directory" ]
64
102
90,383
10
0
2008-09-20T20:07:38.657000
2008-09-20T20:09:44.923000
109,199
112,915
Deploying a site from VSS
In answer to this question Joel Coehoorn said Finally, only after the site's gone through a suitable QA process, the production server is updated from source control, not from within visual studio. Does VSS Explorer have tools for deploying sites (via FTP, I would assume)? I noticed for the first time a Web/Deploy menu...
Managing Web Content Using MS Visual SourceSafe yes you can deploy via ftp or network share using the "web deploy" feature in the VSS explorer.
Deploying a site from VSS In answer to this question Joel Coehoorn said Finally, only after the site's gone through a suitable QA process, the production server is updated from source control, not from within visual studio. Does VSS Explorer have tools for deploying sites (via FTP, I would assume)? I noticed for the fi...
TITLE: Deploying a site from VSS QUESTION: In answer to this question Joel Coehoorn said Finally, only after the site's gone through a suitable QA process, the production server is updated from source control, not from within visual studio. Does VSS Explorer have tools for deploying sites (via FTP, I would assume)? I ...
[ "asp.net", "visual-sourcesafe" ]
2
0
746
3
0
2008-09-20T20:10:53.220000
2008-09-22T02:43:14.717000
109,210
109,299
PHP GD, imagecreatefromstring( ); how to get the image dimensions?
Normally I use imagecreatefromjpeg() and then getimagesize(), but with Firefox 3 I need to go round this different. So now im using imagecreatefromstring(), but how do I retreive the image dimensions now?
imagesx() and imagesy() functions seem to work with images made with imagecreatefromstring(), too.
PHP GD, imagecreatefromstring( ); how to get the image dimensions? Normally I use imagecreatefromjpeg() and then getimagesize(), but with Firefox 3 I need to go round this different. So now im using imagecreatefromstring(), but how do I retreive the image dimensions now?
TITLE: PHP GD, imagecreatefromstring( ); how to get the image dimensions? QUESTION: Normally I use imagecreatefromjpeg() and then getimagesize(), but with Firefox 3 I need to go round this different. So now im using imagecreatefromstring(), but how do I retreive the image dimensions now? ANSWER: imagesx() and imagesy...
[ "php", "image", "upload", "gd" ]
11
20
8,480
2
0
2008-09-20T20:13:43.587000
2008-09-20T20:38:14.730000
109,230
353,781
What is the best online book service for software development references?
I'm a member of ACM, and I have limited access to both Books 24x7 and Safari Books Online, however if I was interested in moving up to a full account for greater access to other books what online book service would you recommend?
Safari Books Online is my choice, here's a related post: Which Online eBook Reference Library Do You Use?
What is the best online book service for software development references? I'm a member of ACM, and I have limited access to both Books 24x7 and Safari Books Online, however if I was interested in moving up to a full account for greater access to other books what online book service would you recommend?
TITLE: What is the best online book service for software development references? QUESTION: I'm a member of ACM, and I have limited access to both Books 24x7 and Safari Books Online, however if I was interested in moving up to a full account for greater access to other books what online book service would you recommend...
[ "reference" ]
5
4
3,976
6
0
2008-09-20T20:15:54.003000
2008-12-09T18:44:14.787000
109,232
109,290
What is the best way to paginate results in SQL Server
What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?
Getting the total number of results and paginating are two different operations. For the sake of this example, let's assume that the query you're dealing with is SELECT * FROM Orders WHERE OrderDate >= '1980-01-01' ORDER BY OrderDate In this case, you would determine the total number of results using: SELECT COUNT(*) F...
What is the best way to paginate results in SQL Server What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?
TITLE: What is the best way to paginate results in SQL Server QUESTION: What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)? ANSWER: Getting the total number of results and paginating are two different...
[ "sql", "sql-server", "performance", "pagination" ]
604
522
680,272
19
0
2008-09-20T20:16:18.633000
2008-09-20T20:35:18.323000
109,249
111,215
Why isn't there a standard memswap function
Why doesn't have the c standard a memswap function, which would probably look like: int memswap(void *ptr1, void *ptr2, size_t nbytes)? I know it'd be easy to write, but i think the libc could do some awesome tricks to speed it up like some implementations do it for memcpy.
This isn't something that is routinely required. The ideas may have been considered and discarded because it is quite difficult to come up with an algorithm that is general purpose. Don't forget that C is an old language and extensions need to be generally useful. Possible error conditions:- behaviour when the ranges b...
Why isn't there a standard memswap function Why doesn't have the c standard a memswap function, which would probably look like: int memswap(void *ptr1, void *ptr2, size_t nbytes)? I know it'd be easy to write, but i think the libc could do some awesome tricks to speed it up like some implementations do it for memcpy.
TITLE: Why isn't there a standard memswap function QUESTION: Why doesn't have the c standard a memswap function, which would probably look like: int memswap(void *ptr1, void *ptr2, size_t nbytes)? I know it'd be easy to write, but i think the libc could do some awesome tricks to speed it up like some implementations d...
[ "c" ]
22
6
10,739
4
0
2008-09-20T20:21:47.250000
2008-09-21T15:21:50.863000
109,251
112,287
Binding TRANSFORM query in Access to a report
Whats the best way to bind variable column names to a report field in Access when using a crosstab query?
The best article I found for binding columns from a crosstab query to a report is from ewbi.develops 's notes. Specifically, PARAMETERS foryear Short; TRANSFORM Sum(mytable.amount) AS total SELECT mytable.project FROM mytable WHERE mytable.year In ([foryear],[foryear]+1) GROUP BY mytable.project PIVOT IIf(mytable.year=...
Binding TRANSFORM query in Access to a report Whats the best way to bind variable column names to a report field in Access when using a crosstab query?
TITLE: Binding TRANSFORM query in Access to a report QUESTION: Whats the best way to bind variable column names to a report field in Access when using a crosstab query? ANSWER: The best article I found for binding columns from a crosstab query to a report is from ewbi.develops 's notes. Specifically, PARAMETERS forye...
[ "sql", "ms-access", "report", "transform" ]
2
1
1,589
2
0
2008-09-20T20:22:09.103000
2008-09-21T21:54:16.690000
109,275
118,265
databinding a property to either of two dependency properties
I have two custom controls that are analogous to a node and the control that draws links between nodes. I would like to have both controls written as much in xaml as possible. The link stores both nodes as dependency properties, and I use databinding to move the line between the nodes whenever the nodes move. It would ...
you can try doing something like that: as in previous post define a width, stroke (whatever you need) property on your link class define a multibinding applied to that property, passing your two nodes to the binding it should look like: Implement interface IMultiValueConverter, which will basically calculate how the st...
databinding a property to either of two dependency properties I have two custom controls that are analogous to a node and the control that draws links between nodes. I would like to have both controls written as much in xaml as possible. The link stores both nodes as dependency properties, and I use databinding to move...
TITLE: databinding a property to either of two dependency properties QUESTION: I have two custom controls that are analogous to a node and the control that draws links between nodes. I would like to have both controls written as much in xaml as possible. The link stores both nodes as dependency properties, and I use d...
[ "c#", "wpf", "data-binding", "xaml" ]
1
1
495
2
0
2008-09-20T20:28:15.690000
2008-09-22T23:46:29.470000
109,280
114,967
In ASP.NET how you get the physcial file path when HttpContext.Current is NULL?
I'm working with DotNetNuke's scheduler to schedule tasks and I'm looking to get the physical file path of a email template that I created. The problem is that HttpContext is NULL because the scheduled task is on a different thread and there is not http request. How would you go about getting the file's physical path?
System.Web.Hosting.HostingEnvironment.MapPath is what you're looking for. Whenever you're using the Server or HttpContext.Current objects, check first to see if HostingEnvironment has what you need.
In ASP.NET how you get the physcial file path when HttpContext.Current is NULL? I'm working with DotNetNuke's scheduler to schedule tasks and I'm looking to get the physical file path of a email template that I created. The problem is that HttpContext is NULL because the scheduled task is on a different thread and ther...
TITLE: In ASP.NET how you get the physcial file path when HttpContext.Current is NULL? QUESTION: I'm working with DotNetNuke's scheduler to schedule tasks and I'm looking to get the physical file path of a email template that I created. The problem is that HttpContext is NULL because the scheduled task is on a differe...
[ ".net", "asp.net", "dotnetnuke", "scheduler", "server.mappath" ]
8
14
8,503
5
0
2008-09-20T20:29:47.650000
2008-09-22T13:53:26.293000
109,284
110,301
Testing rendering of a given layout with RSpec & Rails
Is it possible to test the use of a given layout using RSpec with Rails, for example I'd like a matcher that does the following: response.should use_layout('my_layout_name') I found a use_layout matcher when Googling but it doesn't work as neither the response or controller seem to have a layout property that matcher w...
I found an example of how to write a use_layout matcher that will do just that. Here's the code in case that link goes away: # in spec_helper.rb class UseLayout def initialize(expected) @expected = 'layouts/' + expected end def matches?(controller) @actual = controller.layout #@actual.equal?(@expected) @actual == @exp...
Testing rendering of a given layout with RSpec & Rails Is it possible to test the use of a given layout using RSpec with Rails, for example I'd like a matcher that does the following: response.should use_layout('my_layout_name') I found a use_layout matcher when Googling but it doesn't work as neither the response or c...
TITLE: Testing rendering of a given layout with RSpec & Rails QUESTION: Is it possible to test the use of a given layout using RSpec with Rails, for example I'd like a matcher that does the following: response.should use_layout('my_layout_name') I found a use_layout matcher when Googling but it doesn't work as neither...
[ "ruby-on-rails", "rspec", "layout" ]
28
7
21,000
11
0
2008-09-20T20:33:03.213000
2008-09-21T05:15:28.167000
109,293
109,307
What would you like to see in an beginner's ASP.NET security book
This is a shameless information gathering exercise for my own book. One of the talks I give in the community is an introduction to web site vulnerabilities. Usually during the talk I can see at least two members of the audience go very pale; and this is basic stuff, Cross Site Scripting, SQL Injection, Information Leak...
First, I would point out the insecurities of the web in a way that makes them accesible to people for whom developing with security in mind may (unfortunately) be a new concept. For example, show them how to intercept an HTTP header and implement an XSS attack. The reason you want to show them the attacks is so they th...
What would you like to see in an beginner's ASP.NET security book This is a shameless information gathering exercise for my own book. One of the talks I give in the community is an introduction to web site vulnerabilities. Usually during the talk I can see at least two members of the audience go very pale; and this is ...
TITLE: What would you like to see in an beginner's ASP.NET security book QUESTION: This is a shameless information gathering exercise for my own book. One of the talks I give in the community is an introduction to web site vulnerabilities. Usually during the talk I can see at least two members of the audience go very ...
[ "asp.net", "security" ]
8
6
416
8
0
2008-09-20T20:35:55.357000
2008-09-20T20:42:02.007000
109,317
109,341
Why use C strings in C++?
Is there any good reason to use C strings in C++ nowadays? My textbook uses them in examples at some points, and I really feel like it would be easier just to use a std::string.
The only reasons I've had to use them is when interfacing with 3rd party libraries that use C style strings. There might also be esoteric situations where you would use C style strings for performance reasons, but more often than not, using methods on C++ strings is probably faster due to inlining and specialization, e...
Why use C strings in C++? Is there any good reason to use C strings in C++ nowadays? My textbook uses them in examples at some points, and I really feel like it would be easier just to use a std::string.
TITLE: Why use C strings in C++? QUESTION: Is there any good reason to use C strings in C++ nowadays? My textbook uses them in examples at some points, and I really feel like it would be easier just to use a std::string. ANSWER: The only reasons I've had to use them is when interfacing with 3rd party libraries that u...
[ "c++", "c", "stl", "string", "c-strings" ]
20
23
9,019
18
0
2008-09-20T20:45:24.837000
2008-09-20T20:52:02.683000
109,318
109,393
Using .Net what limitations (if any) are there in using the XmlSerializer?
Using.Net what limitations (if any) are there in using the XmlSerializer? For example, can you serialize Images to XML?
The XmlSerializer has a few drawbacks. It must know all the types being serialized. You cannot pass it something by interface that represents a type that the serializer does not know. It cannot do circular references. It will serializes the same object multiple times if referenced multiple times in the object graph. Ca...
Using .Net what limitations (if any) are there in using the XmlSerializer? Using.Net what limitations (if any) are there in using the XmlSerializer? For example, can you serialize Images to XML?
TITLE: Using .Net what limitations (if any) are there in using the XmlSerializer? QUESTION: Using.Net what limitations (if any) are there in using the XmlSerializer? For example, can you serialize Images to XML? ANSWER: The XmlSerializer has a few drawbacks. It must know all the types being serialized. You cannot pas...
[ ".net", "xml", "serialization" ]
8
19
6,839
8
0
2008-09-20T20:45:39.657000
2008-09-20T21:07:10.040000
109,325
109,334
PostgreSQL "DESCRIBE TABLE"
How do you perform the equivalent of Oracle's DESCRIBE TABLE in PostgreSQL with psql command?
Try this (in the psql command-line tool): \d+ tablename See the manual for more info.
PostgreSQL "DESCRIBE TABLE" How do you perform the equivalent of Oracle's DESCRIBE TABLE in PostgreSQL with psql command?
TITLE: PostgreSQL "DESCRIBE TABLE" QUESTION: How do you perform the equivalent of Oracle's DESCRIBE TABLE in PostgreSQL with psql command? ANSWER: Try this (in the psql command-line tool): \d+ tablename See the manual for more info.
[ "database", "postgresql", "command", "psql", "table-structure" ]
2,180
3,173
1,484,608
25
0
2008-09-20T20:47:48.917000
2008-09-20T20:50:17.243000
109,343
115,026
Batching in REST
With web services it is considered a good practice to batch several service calls into one message to reduce a number of remote calls. Is there any way to do this with RESTful services?
I don't see how batching requests makes any sense in REST. Since the URL in a REST-based service represents the operation to perform and the data on which to perform it, making batch requests would seriously break the conceptual model. An exception would be if you were performing the same operation on the same data mul...
Batching in REST With web services it is considered a good practice to batch several service calls into one message to reduce a number of remote calls. Is there any way to do this with RESTful services?
TITLE: Batching in REST QUESTION: With web services it is considered a good practice to batch several service calls into one message to reduce a number of remote calls. Is there any way to do this with RESTful services? ANSWER: I don't see how batching requests makes any sense in REST. Since the URL in a REST-based s...
[ "wcf", "rest" ]
5
4
3,762
5
0
2008-09-20T20:52:50.917000
2008-09-22T14:05:16.497000
109,345
109,411
All possible uses for the Application.SysCmd Method
Is there a place to find all possible uses of the syscmd method in MS Access? I know Microsoft has a developer reference, but I have found there are many other uses for this method that are not listed here.
Here's a comprehensive list, including which Access versions each command applies to, translated into English. http://www.excite-webtl.jp/world/english/web/?wb_url=http%3A%2F%2Fwww.f3.dion.ne.jp%2F%7Eelement%2Fmsaccess%2FAcTipsUnDocumentedSysCmd.html&wb_lp=JAEN&wb_dis=2
All possible uses for the Application.SysCmd Method Is there a place to find all possible uses of the syscmd method in MS Access? I know Microsoft has a developer reference, but I have found there are many other uses for this method that are not listed here.
TITLE: All possible uses for the Application.SysCmd Method QUESTION: Is there a place to find all possible uses of the syscmd method in MS Access? I know Microsoft has a developer reference, but I have found there are many other uses for this method that are not listed here. ANSWER: Here's a comprehensive list, inclu...
[ "ms-access", "methods", "vba" ]
3
1
4,073
3
0
2008-09-20T20:53:20.073000
2008-09-20T21:11:23.340000
109,364
3,005,394
Bezier clipping
I'm trying to find/make an algorithm to compute the intersection (a new filled object) of two arbitrary filled 2D objects. The objects are defined using either lines or cubic beziers and may have holes or self-intersect. I'm aware of several existing algorithms doing the same with polygons, listed here. However, I'd li...
I found the following publication to be the best of information regarding Bezier Clipping: T. W. Sederberg, BYU, Computer Aided Geometric Design Course Notes Chapter 7 that talks about Curve Intersection is available online. It outlines 4 different approaches to find intersections and describes Bezier Clipping in detai...
Bezier clipping I'm trying to find/make an algorithm to compute the intersection (a new filled object) of two arbitrary filled 2D objects. The objects are defined using either lines or cubic beziers and may have holes or self-intersect. I'm aware of several existing algorithms doing the same with polygons, listed here....
TITLE: Bezier clipping QUESTION: I'm trying to find/make an algorithm to compute the intersection (a new filled object) of two arbitrary filled 2D objects. The objects are defined using either lines or cubic beziers and may have holes or self-intersect. I'm aware of several existing algorithms doing the same with poly...
[ "graphics", "geometry", "2d", "bezier", "csg" ]
16
12
10,320
4
0
2008-09-20T20:56:31.847000
2010-06-09T11:35:29.583000
109,417
109,452
Reading datagridview
I populated a datagridview from a datatable. How do I read from the datagridview when the application is running?
how did you populate it? is the DataSource something useful like a BindlingList? If it is then something like: BindingSource bindingSource = this.dataGridView1.DataSource as BindingSource; //substitute your business object type for T T entity = bindingSource.Current as T; would get you the entity bound to the row. Othe...
Reading datagridview I populated a datagridview from a datatable. How do I read from the datagridview when the application is running?
TITLE: Reading datagridview QUESTION: I populated a datagridview from a datatable. How do I read from the datagridview when the application is running? ANSWER: how did you populate it? is the DataSource something useful like a BindlingList? If it is then something like: BindingSource bindingSource = this.dataGridView...
[ ".net", "winforms", "datagridview", "datatable" ]
0
2
4,964
4
0
2008-09-20T21:13:07.047000
2008-09-20T21:19:30.980000
109,432
110,403
What not to test when it comes to Unit Testing?
In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp? If there is an answer to this question then %100 coverage is a myth, isn't it?
Here I found (via haacked something Michael Feathers says that can be an answer: He says, A test is not a unit test if: It talks to the database It communicates across the network It touches the file system It can't run at the same time as any of your other unit tests You have to do special things to your environment (...
What not to test when it comes to Unit Testing? In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp? If there is an answer to this question then %100 coverage is a myth, isn't it?
TITLE: What not to test when it comes to Unit Testing? QUESTION: In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp? If there is an answer to this question then %100 coverage is a myth, isn't it? ANSWER: Here I found (via haacked something Michael Feathers says that can be...
[ "unit-testing", "language-agnostic", "tdd", "testing-strategies" ]
34
37
6,222
21
0
2008-09-20T21:16:48.660000
2008-09-21T06:36:10.377000
109,444
109,454
PHP replace double backslashes "\\" to a single backslash "\"
Okay so im working on this php image upload system but for some reason internet explorer turns my basepath into the same path, but with double backslashes instead of one; ie: C:\\Documents and Settings\\kasper\\Bureaublad\\24.jpg This needs to become C:\Documents and Settings\kasper\Bureaublad\24.jpg.
Use the stripslashes function. That should make them all single slashes.
PHP replace double backslashes "\\" to a single backslash "\" Okay so im working on this php image upload system but for some reason internet explorer turns my basepath into the same path, but with double backslashes instead of one; ie: C:\\Documents and Settings\\kasper\\Bureaublad\\24.jpg This needs to become C:\Docu...
TITLE: PHP replace double backslashes "\\" to a single backslash "\" QUESTION: Okay so im working on this php image upload system but for some reason internet explorer turns my basepath into the same path, but with double backslashes instead of one; ie: C:\\Documents and Settings\\kasper\\Bureaublad\\24.jpg This needs...
[ "php", "string", "replace", "backslash" ]
5
1
17,450
3
0
2008-09-20T21:18:22.120000
2008-09-20T21:20:29.260000
109,449
109,522
Getting a FILE* from a std::fstream
Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream? The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*.
The short answer is no. The reason, is because the std::fstream is not required to use a FILE* as part of its implementation. So even if you manage to extract file descriptor from the std::fstream object and manually build a FILE object, then you will have other problems because you will now have two buffered objects w...
Getting a FILE* from a std::fstream Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream? The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*.
TITLE: Getting a FILE* from a std::fstream QUESTION: Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream? The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*. ANSWER: The short answer is no. The reason,...
[ "c++", "c", "file", "file-io", "fstream" ]
82
50
64,583
9
0
2008-09-20T21:19:16.020000
2008-09-20T21:43:45.680000
109,480
110,167
Caching paginated results, purging on update - how to solve?
I've created a forum, and we're implementing an apc and memcache caching solution to save the database some work. I started implementing the cache layer with keys like "Categories::getAll", and if I had user-specific data, I'd append the keys with stuff like the user ID, so you'd get "User::getFavoriteThreads|1471". Wh...
You might also want to have a look at the cost of storing the cache data, in terms of your effort and CPU cost, against how what the cache will buy you. If you find that 80% of your forum views are looking at the first page of threads, then you could decide to cache that page only. That would mean both cache reads and ...
Caching paginated results, purging on update - how to solve? I've created a forum, and we're implementing an apc and memcache caching solution to save the database some work. I started implementing the cache layer with keys like "Categories::getAll", and if I had user-specific data, I'd append the keys with stuff like ...
TITLE: Caching paginated results, purging on update - how to solve? QUESTION: I've created a forum, and we're implementing an apc and memcache caching solution to save the database some work. I started implementing the cache layer with keys like "Categories::getAll", and if I had user-specific data, I'd append the key...
[ "php", "caching", "pagination", "memcached" ]
7
5
4,099
8
0
2008-09-20T21:27:25.983000
2008-09-21T03:31:12.083000
109,488
109,516
Is it bad design to use table tags when displaying forms in html?
I keep hearing that div tags should be used for layout purposes and not table tags. So does that also apply to form layout? I know a form layout is still a layout, but it seems like creating form layouts with div s requires more html and css. So with that in mind, should forms layouts use div tags instead?
Yes, it does apply for form layouts. Keep in mind that there are also tags like FIELDSET and LABEL which exist specifically for adding structure to a form, so it's not really a question of just using DIV. You should be able to markup a form with pretty minimal HTML, and let CSS do the rest of the work. E.g.: Name:...
Is it bad design to use table tags when displaying forms in html? I keep hearing that div tags should be used for layout purposes and not table tags. So does that also apply to form layout? I know a form layout is still a layout, but it seems like creating form layouts with div s requires more html and css. So with tha...
TITLE: Is it bad design to use table tags when displaying forms in html? QUESTION: I keep hearing that div tags should be used for layout purposes and not table tags. So does that also apply to form layout? I know a form layout is still a layout, but it seems like creating form layouts with div s requires more html an...
[ "html", "css", "forms", "layout" ]
23
23
9,234
12
0
2008-09-20T21:30:04.650000
2008-09-20T21:41:21.160000
109,491
109,611
Problems with accessing FlashVars via parameters in AS3
I keep getting compiler errors when I try to access flashVars in an AS3 class. Here's a stripped version of the code: package myPackage { import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; public class myClass { public function CTrafficHandler() { var myVar:String = LoaderInfo(th...
I found what the problem was. The class in question wasn't the main class used in the project, but rather a secondary class. I've moved the code to the main class to get the parameters and after I got them, I sent them to the class constructor function.
Problems with accessing FlashVars via parameters in AS3 I keep getting compiler errors when I try to access flashVars in an AS3 class. Here's a stripped version of the code: package myPackage { import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; public class myClass { public funct...
TITLE: Problems with accessing FlashVars via parameters in AS3 QUESTION: I keep getting compiler errors when I try to access flashVars in an AS3 class. Here's a stripped version of the code: package myPackage { import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; public class myCl...
[ "flash", "actionscript-3", "parameters", "flashvars" ]
0
2
12,496
5
0
2008-09-20T21:32:09.530000
2008-09-20T22:23:00.857000
109,520
109,539
Rails and Gmail SMTP, how to use a custom from address
I've got my Rails (2.1) app setup to send email via Gmail, however whenever I send an email no matter what I set the from address to in my ActionMailer the emails always come as if sent from my Gmail email address. Is this a security restriction they've put in place at Gmail to stop spammers using their SMTP? Note: I'v...
I believe it's just something Gmail does when mail is sent through its SMTP, as it was mentioned that they do this on a tutorial about using their SMTP to send mail.
Rails and Gmail SMTP, how to use a custom from address I've got my Rails (2.1) app setup to send email via Gmail, however whenever I send an email no matter what I set the from address to in my ActionMailer the emails always come as if sent from my Gmail email address. Is this a security restriction they've put in plac...
TITLE: Rails and Gmail SMTP, how to use a custom from address QUESTION: I've got my Rails (2.1) app setup to send email via Gmail, however whenever I send an email no matter what I set the from address to in my ActionMailer the emails always come as if sent from my Gmail email address. Is this a security restriction t...
[ "ruby-on-rails", "smtp", "gmail", "actionmailer" ]
7
6
4,643
3
0
2008-09-20T21:43:25.227000
2008-09-20T21:50:47.597000
109,528
109,596
How do I test that a Rails Helper defines a method?
I am creating a Rails plugin and it is dynamically adding a method to a Helper. I just want to ensure that the method is added. How can I see if the Helper responds to the method name?
Try this: def test_that_foo_helper_defines_bar o = Object.new assert!o.respond_to?:bar o.extend FooHelper assert o.respond_to?:bar end
How do I test that a Rails Helper defines a method? I am creating a Rails plugin and it is dynamically adding a method to a Helper. I just want to ensure that the method is added. How can I see if the Helper responds to the method name?
TITLE: How do I test that a Rails Helper defines a method? QUESTION: I am creating a Rails plugin and it is dynamically adding a method to a Helper. I just want to ensure that the method is added. How can I see if the Helper responds to the method name? ANSWER: Try this: def test_that_foo_helper_defines_bar o = Objec...
[ "ruby-on-rails", "ruby", "unit-testing", "helper" ]
3
6
273
1
0
2008-09-20T21:46:51.490000
2008-09-20T22:18:10.433000
109,580
114,287
How do I access cookies within Flash?
I'm looking to grab cookie values for the same domain within a Flash movie. Is this possible? Let's see I let a user set a variable foo and I store it using any web programming language. I can access it easily via that language, but I would like to access it via the Flash movie without passing it in via printing it wit...
If you just want to store and retrieve data, you probably want to use the SharedObject class. See Adobe's SharedObject reference for more details of that. If you want to access the HTTP cookies, you'll need to use ExternalInterface to talk to javascript. The way we do that here is to have a helper class called HTTPCook...
How do I access cookies within Flash? I'm looking to grab cookie values for the same domain within a Flash movie. Is this possible? Let's see I let a user set a variable foo and I store it using any web programming language. I can access it easily via that language, but I would like to access it via the Flash movie wit...
TITLE: How do I access cookies within Flash? QUESTION: I'm looking to grab cookie values for the same domain within a Flash movie. Is this possible? Let's see I let a user set a variable foo and I store it using any web programming language. I can access it easily via that language, but I would like to access it via t...
[ "flash", "actionscript", "cookies" ]
10
11
20,951
7
0
2008-09-20T22:09:49.593000
2008-09-22T11:12:10.767000
109,592
113,480
Speed up images in Tomcat 6
In tomcat 6 i have a servlet running openbluedragon, everything compiles and servers up quik, with the exception of images, they really lag significantly. Any suggestions optimization for image serving? Here is my server.xml:...context
Another option is to use apache as a frontend, connecting tomcat with mod_jk. This way you can let apache serve static content (e.g. images, css, javascript) and let tomcat generate the dynamic content. Might leave a bit of work to separate the static content from the dynamic ones, but works great for me. On Unix, havi...
Speed up images in Tomcat 6 In tomcat 6 i have a servlet running openbluedragon, everything compiles and servers up quik, with the exception of images, they really lag significantly. Any suggestions optimization for image serving? Here is my server.xml:...context
TITLE: Speed up images in Tomcat 6 QUESTION: In tomcat 6 i have a servlet running openbluedragon, everything compiles and servers up quik, with the exception of images, they really lag significantly. Any suggestions optimization for image serving? Here is my server.xml:...context ANSWER: Another option is to use apac...
[ "optimization", "tomcat", "ajp" ]
3
4
2,932
3
0
2008-09-20T22:15:35.727000
2008-09-22T06:35:28.827000
109,594
109,598
Finding SQL queries in compiled app
I have just inherited a server application, however it seems that the only copy of the database is corrupt and the working version is gone, so is it possible to find what queries the application is running so I can try to rebuild the tables? Edit: I have some files with no extensions that I are named the same as the da...
Turn on SQL query logging and watch what the application asks for.
Finding SQL queries in compiled app I have just inherited a server application, however it seems that the only copy of the database is corrupt and the working version is gone, so is it possible to find what queries the application is running so I can try to rebuild the tables? Edit: I have some files with no extensions...
TITLE: Finding SQL queries in compiled app QUESTION: I have just inherited a server application, however it seems that the only copy of the database is corrupt and the working version is gone, so is it possible to find what queries the application is running so I can try to rebuild the tables? Edit: I have some files ...
[ "sql-server" ]
2
3
293
5
0
2008-09-20T22:17:04.197000
2008-09-20T22:18:42.757000
109,608
110,400
How do I position the content of a tabpage in Silverlight?
When I place a control on a tabpage in Silverlight the control is placed ~10 pixels down and ~10 pixels right. For example, the following xaml: will produce: How do I position the content at 0,0?
Look at the control template, it has a margin of that size. Use blend to modify the a copy of the tab control's template.
How do I position the content of a tabpage in Silverlight? When I place a control on a tabpage in Silverlight the control is placed ~10 pixels down and ~10 pixels right. For example, the following xaml: will produce: How do I position the content at 0,0?
TITLE: How do I position the content of a tabpage in Silverlight? QUESTION: When I place a control on a tabpage in Silverlight the control is placed ~10 pixels down and ~10 pixels right. For example, the following xaml: will produce: How do I position the content at 0,0? ANSWER: Look at the control template, it has a...
[ "c#", "silverlight" ]
1
1
756
4
0
2008-09-20T22:22:45.663000
2008-09-21T06:33:01.773000
109,618
109,756
How would you achieve this table based layout using CSS instead of HTML tables?
I want the following layout to appear on the screen: FieldName 1 [Field input 1] FieldName 2 is longer [Field input 2].... FieldName N [Field input N] Requirements: Field names and field inputs must align on the left edges Both columns must dynamically size themselves to their content Must work cross-browsers I find th...
I think most of the answers are missing the point that the original questioner wanted the columns widths to depend on the width of the content. I believe the only way to do this with pure CSS is by using display: table, display: table-row and display: table-cell, but that isn't supported by IE. But I'm not sure that th...
How would you achieve this table based layout using CSS instead of HTML tables? I want the following layout to appear on the screen: FieldName 1 [Field input 1] FieldName 2 is longer [Field input 2].... FieldName N [Field input N] Requirements: Field names and field inputs must align on the left edges Both columns must...
TITLE: How would you achieve this table based layout using CSS instead of HTML tables? QUESTION: I want the following layout to appear on the screen: FieldName 1 [Field input 1] FieldName 2 is longer [Field input 2].... FieldName N [Field input N] Requirements: Field names and field inputs must align on the left edges...
[ "html", "css" ]
9
5
3,599
7
0
2008-09-20T22:28:26.493000
2008-09-20T23:24:33.283000
109,620
109,629
What are the bigger hurdles to overcome migrating from Winforms to WPF?
I've been developing Winforms applications in C# for a few years now and have been interested in moving future development toward WPF, mainly because of the positive things I've been hearing about it. But, I'm wondering what sort of hurdles others have had to overcome as they migrated to WPF. Was there a significant hi...
I'm not sure I can give you just one hurdle, because it is a complete departure from WinForms. My suggestion is get Adam Nathan's WPF Unleashed, forget everything you know about building UI's with any previous technology (Winforms, MFC, Java) and begin again at square one. If you try and do it any other way it will cau...
What are the bigger hurdles to overcome migrating from Winforms to WPF? I've been developing Winforms applications in C# for a few years now and have been interested in moving future development toward WPF, mainly because of the positive things I've been hearing about it. But, I'm wondering what sort of hurdles others ...
TITLE: What are the bigger hurdles to overcome migrating from Winforms to WPF? QUESTION: I've been developing Winforms applications in C# for a few years now and have been interested in moving future development toward WPF, mainly because of the positive things I've been hearing about it. But, I'm wondering what sort ...
[ "c#", "wpf", "windows", "winforms" ]
6
11
3,151
8
0
2008-09-20T22:29:44.133000
2008-09-20T22:32:49.307000
109,631
109,703
Finding the right VPS
The market is flooded with VPS (virtual private server) hosting options. It seems everyone and their mother has a overloaded server in his/her closet. Enterprise options always seem priced insanely high, which make the ones that are cheap and claim enterprise level seem shaky. What do you look for in a quality VPS prov...
Most virtual hosting platforms will have a trial period in which you can test out their reliability. They will also give you a list of their high profile sites on their systems. Most keep track of the traffic hogs as it's a great way for them to attest their own stability. I would recommend Slicehost as I have been wit...
Finding the right VPS The market is flooded with VPS (virtual private server) hosting options. It seems everyone and their mother has a overloaded server in his/her closet. Enterprise options always seem priced insanely high, which make the ones that are cheap and claim enterprise level seem shaky. What do you look for...
TITLE: Finding the right VPS QUESTION: The market is flooded with VPS (virtual private server) hosting options. It seems everyone and their mother has a overloaded server in his/her closet. Enterprise options always seem priced insanely high, which make the ones that are cheap and claim enterprise level seem shaky. Wh...
[ "vps" ]
19
6
45,258
12
0
2008-09-20T22:33:28.820000
2008-09-20T23:00:34.560000
109,668
109,726
IoC, Where do you put the container?
I'm using castle windsor for a pet-project I'm working on. I'm starting to notice that I need to call the IoC container in different places in my code to create new objects. This dependency on the container makes my code harder to maintain. There are two solutions I've used to solve this problem I tried to create abstr...
The main benefit of Dependency Injection, at least in my applications, is the ability to write code that is context agnostic. From that perspective, your second solution seems like it really subverts the benefit DI could be giving you. If the 'god object' exposes different interfaces to each class that references it, i...
IoC, Where do you put the container? I'm using castle windsor for a pet-project I'm working on. I'm starting to notice that I need to call the IoC container in different places in my code to create new objects. This dependency on the container makes my code harder to maintain. There are two solutions I've used to solve...
TITLE: IoC, Where do you put the container? QUESTION: I'm using castle windsor for a pet-project I'm working on. I'm starting to notice that I need to call the IoC container in different places in my code to create new objects. This dependency on the container makes my code harder to maintain. There are two solutions ...
[ "oop", "dependency-injection", "inversion-of-control", "castle-windsor" ]
27
4
6,384
7
0
2008-09-20T22:48:01.907000
2008-09-20T23:11:02.367000
109,705
109,783
Python signal woes: SIGQUIT handler delays execution if SIGQUIT received during execution of another signal handler?
The following program is very simple: it outputs a single dot each half a second. If it recieves a SIGQUIT, it proceeds to output ten Q s. If it recieves a SIGTSTP ( Ctrl - Z ), it outputs ten Z s. If it recieves a SIGTSTP while printing Q s, it will print ten Z s after it's done with the ten Q s. This is a good thing....
Your larger problem is blocking in signal handlers. This is usually discouraged since it can lead to strange timing conditions. But it's not quite the cause of your problem since the timing condition you're vulnerable to exists because of your choice of signal handlers. Anyway, here's how to at least minimize the timin...
Python signal woes: SIGQUIT handler delays execution if SIGQUIT received during execution of another signal handler? The following program is very simple: it outputs a single dot each half a second. If it recieves a SIGQUIT, it proceeds to output ten Q s. If it recieves a SIGTSTP ( Ctrl - Z ), it outputs ten Z s. If it...
TITLE: Python signal woes: SIGQUIT handler delays execution if SIGQUIT received during execution of another signal handler? QUESTION: The following program is very simple: it outputs a single dot each half a second. If it recieves a SIGQUIT, it proceeds to output ten Q s. If it recieves a SIGTSTP ( Ctrl - Z ), it outp...
[ "python", "signals" ]
9
6
4,496
2
0
2008-09-20T23:02:35.333000
2008-09-20T23:39:49.287000
109,710
109,721
How do the likely/unlikely macros in the Linux kernel work and what is their benefit?
I've been digging through some parts of the Linux kernel, and found calls like this: if (unlikely(fd < 0)) { /* Do something */ } or if (likely(!err)) { /* Do something */ } I've found the definition of them: #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) I know that they ar...
They are hint to the compiler to emit instructions that will cause branch prediction to favour the "likely" side of a jump instruction. This can be a big win, if the prediction is correct it means that the jump instruction is basically free and will take zero cycles. On the other hand if the prediction is wrong, then i...
How do the likely/unlikely macros in the Linux kernel work and what is their benefit? I've been digging through some parts of the Linux kernel, and found calls like this: if (unlikely(fd < 0)) { /* Do something */ } or if (likely(!err)) { /* Do something */ } I've found the definition of them: #define likely(x) __built...
TITLE: How do the likely/unlikely macros in the Linux kernel work and what is their benefit? QUESTION: I've been digging through some parts of the Linux kernel, and found calls like this: if (unlikely(fd < 0)) { /* Do something */ } or if (likely(!err)) { /* Do something */ } I've found the definition of them: #define...
[ "c", "gcc", "linux-kernel", "branch-prediction", "likely-unlikely" ]
455
423
214,332
10
0
2008-09-20T23:04:16.813000
2008-09-20T23:09:26.847000
109,717
109,729
Multiple Constructors with complex logic
In C#, if you have multiple constructors, you can do something like this: public MyClass(Guid inputId, string inputName){ // do something } public MyClass(Guid inputId): this(inputId, "foo") {} The idea is of course code reuse. However, what is the best approach when there is a bit of complex logic needed? Say I want ...
The most common pattern used to solve this problem is to have an Initialize() method that your constructors call, but in the example you just gave, adding a static method that you called like the code below, would do the trick. public MyClass(MyOtherClass inputObject): this(inputObject.ID, GetHelperText(inputObject) {}...
Multiple Constructors with complex logic In C#, if you have multiple constructors, you can do something like this: public MyClass(Guid inputId, string inputName){ // do something } public MyClass(Guid inputId): this(inputId, "foo") {} The idea is of course code reuse. However, what is the best approach when there is a...
TITLE: Multiple Constructors with complex logic QUESTION: In C#, if you have multiple constructors, you can do something like this: public MyClass(Guid inputId, string inputName){ // do something } public MyClass(Guid inputId): this(inputId, "foo") {} The idea is of course code reuse. However, what is the best approa...
[ "c#", ".net" ]
6
17
8,897
3
0
2008-09-20T23:06:48.647000
2008-09-20T23:13:11.690000
109,753
109,772
Creating a shiny Graphic/Gloss Effect
I would like to programmatically create a gloss effect on an Image, kinda like on the Apple-inspired design that the Web has adopted when it was updated to 2.0 Beta. Essentially this: example icons http://nhc.hcmuns.googlepages.com/web2_icons.jpg Now, I see two approaches here: I create one image which has an Alpha cha...
I can explain that effect in graphic terms. Create an image around 3* the size of the icon. Within this image, create a circle where (the height of the icon) < radius < 2*(the height of the icon). Fill the circle with an alpha blend/transparency (to white) of say 10%. Crop that circle image into a new image of equal si...
Creating a shiny Graphic/Gloss Effect I would like to programmatically create a gloss effect on an Image, kinda like on the Apple-inspired design that the Web has adopted when it was updated to 2.0 Beta. Essentially this: example icons http://nhc.hcmuns.googlepages.com/web2_icons.jpg Now, I see two approaches here: I c...
TITLE: Creating a shiny Graphic/Gloss Effect QUESTION: I would like to programmatically create a gloss effect on an Image, kinda like on the Apple-inspired design that the Web has adopted when it was updated to 2.0 Beta. Essentially this: example icons http://nhc.hcmuns.googlepages.com/web2_icons.jpg Now, I see two ap...
[ ".net", "image" ]
8
8
5,221
3
0
2008-09-20T23:22:30.903000
2008-09-20T23:34:25.913000
109,759
109,795
Rails ar_mailer fails to send emails
I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error: Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4 I am using Gmail SMTP to send the emails and I haven't changed any of the ActionMailer::Base.smtp_settings ju...
Did some digging in the lib and it seems that if you want to use TLS (as you do with Gmail) then it adds a new option to the ActionMailer::Base.smtp_settings of:tls (default of which is false) which you should set to true. The only thing the installation instructions mention regarding TLS is to remove any other smtp_tl...
Rails ar_mailer fails to send emails I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error: Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4 I am using Gmail SMTP to send the emails and I haven't changed any of th...
TITLE: Rails ar_mailer fails to send emails QUESTION: I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error: Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4 I am using Gmail SMTP to send the emails and I haven't...
[ "ruby-on-rails", "plugins", "smtp", "ar-mailer" ]
1
1
1,236
3
0
2008-09-20T23:26:09.067000
2008-09-20T23:45:45.963000
109,769
109,788
How do you serialize javascript objects with methods using JSON?
I am looking for an enhancement to JSON that will also serialize methods. I have an object that acts as a collection of objects, and would like to serialize the methods of the collection object as well. So far I've located ClassyJSON. Any thoughts?
I don't think serializing methods is ever a good idea. If you intend to run the code serverside, you open yourself to attacks. If you want to run it client side, you are better off just the local methods, possibly referencing the name of the method you are going to use in the serialized objects. I do believe though tha...
How do you serialize javascript objects with methods using JSON? I am looking for an enhancement to JSON that will also serialize methods. I have an object that acts as a collection of objects, and would like to serialize the methods of the collection object as well. So far I've located ClassyJSON. Any thoughts?
TITLE: How do you serialize javascript objects with methods using JSON? QUESTION: I am looking for an enhancement to JSON that will also serialize methods. I have an object that acts as a collection of objects, and would like to serialize the methods of the collection object as well. So far I've located ClassyJSON. An...
[ "asp.net", "json", "viewstate" ]
3
1
4,262
3
0
2008-09-20T23:31:46.277000
2008-09-20T23:41:56.643000
109,790
109,807
Use of the Exception class in c#
Errors that occur deep down in a data access layer or even higher up, (say within ADO.net operations for example) rarely make much sense to an end user. Simply bubbling these errors up to a UI and displaying them will usually achieve nothing except frustration for an end user. I have recently employed a basic technique...
It is just slightly horrible. If you are showing an error to the end user, the user is supposed to be able to act about it. In "The list of customer names your requested could not be displayed." case, your user will just think "so what?" On all of these cases, just display a "something bad happened" message. You do not...
Use of the Exception class in c# Errors that occur deep down in a data access layer or even higher up, (say within ADO.net operations for example) rarely make much sense to an end user. Simply bubbling these errors up to a UI and displaying them will usually achieve nothing except frustration for an end user. I have re...
TITLE: Use of the Exception class in c# QUESTION: Errors that occur deep down in a data access layer or even higher up, (say within ADO.net operations for example) rarely make much sense to an end user. Simply bubbling these errors up to a UI and displaying them will usually achieve nothing except frustration for an e...
[ ".net", "exception" ]
5
9
1,853
6
0
2008-09-20T23:43:15.097000
2008-09-20T23:50:06.030000
109,830
112,573
Not getting emails from ExceptionNotifier
I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I have ActionMailer configured correctly because I am getting mail from other forms. I even have local_addresses.clear set so that it should be delivering mail no matter what. I am using Apache with a mongrel_cluster running in the ...
If you added your ExceptionNotifier configuration information (your email address, etc.) into config/environment.rb, did you add it within the Rails::Initializer block or did you add it at the end of the file? The tutorial you linked to doesn't specify where in the environment file to put the configuration information....
Not getting emails from ExceptionNotifier I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I have ActionMailer configured correctly because I am getting mail from other forms. I even have local_addresses.clear set so that it should be delivering mail no matter what. I am using Apa...
TITLE: Not getting emails from ExceptionNotifier QUESTION: I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I have ActionMailer configured correctly because I am getting mail from other forms. I even have local_addresses.clear set so that it should be delivering mail no matter wh...
[ "ruby-on-rails", "ruby", "exception" ]
1
1
316
3
0
2008-09-20T23:59:36.977000
2008-09-21T23:42:58.863000
109,836
109,851
Object Memory Analysis in .NET
Is there a tool or a way to find out how much memory consumed by each DLL or object in.NET? The more detail it analyzes the better. Thanks.
You could try CLR Profiler which is free, or maybe the trial version of ANTS Profiler.
Object Memory Analysis in .NET Is there a tool or a way to find out how much memory consumed by each DLL or object in.NET? The more detail it analyzes the better. Thanks.
TITLE: Object Memory Analysis in .NET QUESTION: Is there a tool or a way to find out how much memory consumed by each DLL or object in.NET? The more detail it analyzes the better. Thanks. ANSWER: You could try CLR Profiler which is free, or maybe the trial version of ANTS Profiler.
[ ".net", "memory" ]
6
6
4,836
4
0
2008-09-21T00:02:52.350000
2008-09-21T00:11:44.777000
109,854
109,913
Auto-format structured data (phone, date) using jQuery plugin (or failing that vanilla JavaScript)
I like jQuery and I was wondering if anyone have used a good plugin or (non-jQuery) JavaScript library that allows for auto-formatting of structured fields like phone numbers or dates. I know of the jquery-ui-datapicker plugin, and not what I am looking for here. You may type in a phone number as 123 which then becomes...
Does the Masked Input plugin do what you need or that one you have already found to be unreliable?
Auto-format structured data (phone, date) using jQuery plugin (or failing that vanilla JavaScript) I like jQuery and I was wondering if anyone have used a good plugin or (non-jQuery) JavaScript library that allows for auto-formatting of structured fields like phone numbers or dates. I know of the jquery-ui-datapicker p...
TITLE: Auto-format structured data (phone, date) using jQuery plugin (or failing that vanilla JavaScript) QUESTION: I like jQuery and I was wondering if anyone have used a good plugin or (non-jQuery) JavaScript library that allows for auto-formatting of structured fields like phone numbers or dates. I know of the jque...
[ "javascript", "jquery", "html", "user-interface" ]
21
38
34,952
2
0
2008-09-21T00:14:22.540000
2008-09-21T01:12:26.520000
109,858
109,881
PHP with AWASP framework
Who here is using WASP ( http://wasp.sourceforge.net/content/ ) to in real world applications? What impressions do you have? Good? Bad? If you can provide any inputs, how good it is comparing with rails for example. I'm really looking for MVC frameworks for PHP Update: This comparation I found is good.
I downloaded it a while ago and tried it out, but as the documentation is pretty terrible at the moment (consisting of some auto-generated 'documentation' that was useless) I gave up pretty quickly. I think one of the most important things to have in a framework is clear, thorough documentation - if you have to spend t...
PHP with AWASP framework Who here is using WASP ( http://wasp.sourceforge.net/content/ ) to in real world applications? What impressions do you have? Good? Bad? If you can provide any inputs, how good it is comparing with rails for example. I'm really looking for MVC frameworks for PHP Update: This comparation I found ...
TITLE: PHP with AWASP framework QUESTION: Who here is using WASP ( http://wasp.sourceforge.net/content/ ) to in real world applications? What impressions do you have? Good? Bad? If you can provide any inputs, how good it is comparing with rails for example. I'm really looking for MVC frameworks for PHP Update: This co...
[ "php", "model-view-controller", "frameworks" ]
0
2
234
6
0
2008-09-21T00:15:50.447000
2008-09-21T00:29:15.577000
109,859
109,872
What does "DateTime?" mean in C#?
I am reading a.NET book, and in one of the code examples there is a class definition with this field: private DateTime? startdate What does DateTime? mean?
Since DateTime is a struct, not a class, you get a DateTime object, not a reference, when you declare a field or variable of that type. And, in the same way as an int cannot be null, so this DateTime object can never be null, because it's not a reference. Adding the question mark turns it into a nullable type, which me...
What does "DateTime?" mean in C#? I am reading a.NET book, and in one of the code examples there is a class definition with this field: private DateTime? startdate What does DateTime? mean?
TITLE: What does "DateTime?" mean in C#? QUESTION: I am reading a.NET book, and in one of the code examples there is a class definition with this field: private DateTime? startdate What does DateTime? mean? ANSWER: Since DateTime is a struct, not a class, you get a DateTime object, not a reference, when you declare a...
[ "c#", ".net", "datetime", "syntax", "nullable" ]
79
144
72,650
7
0
2008-09-21T00:16:02.740000
2008-09-21T00:20:10.263000
109,880
109,920
Is there a Perl solution for lazy lists this side of Perl 6?
Has anybody found a good solution for lazily-evaluated lists in Perl? I've tried a number of ways to turn something like for my $item ( map {... } @list ) { } into a lazy evaluation--by tie-ing @list, for example. I'm trying to avoid breaking down and writing a source filter to do it, because they mess with your abilit...
As mentioned previously, for(each) is an eager loop, so it wants to evaluate the entire list before starting. For simplicity, I would recommend using an iterator object or closure rather than trying to have a lazily evaluated array. While you can use a tie to have a lazily evaluated infinite list, you can run into trou...
Is there a Perl solution for lazy lists this side of Perl 6? Has anybody found a good solution for lazily-evaluated lists in Perl? I've tried a number of ways to turn something like for my $item ( map {... } @list ) { } into a lazy evaluation--by tie-ing @list, for example. I'm trying to avoid breaking down and writing...
TITLE: Is there a Perl solution for lazy lists this side of Perl 6? QUESTION: Has anybody found a good solution for lazily-evaluated lists in Perl? I've tried a number of ways to turn something like for my $item ( map {... } @list ) { } into a lazy evaluation--by tie-ing @list, for example. I'm trying to avoid breakin...
[ "perl", "lazylist", "source-filter" ]
11
13
1,313
8
0
2008-09-21T00:26:55.070000
2008-09-21T01:16:22.580000
109,883
111,528
How to return JSON from a HandleError filter?
aspnet mvc has the HandleError filter that will return a view if an error occurs, but if an error occurs when calling a JsonResult Action how can I return a JSON object that represents an error? I don't want to wrap the code in each action method that returns a JsonResult in a try/catch to accomplish it, I'd rather do ...
Take a look at the MVC implementation of HandleErrorAttribute. It returns a ViewResult. You could write your own version (HandleJsonErrorAttribute) that returns a JsonResult.
How to return JSON from a HandleError filter? aspnet mvc has the HandleError filter that will return a view if an error occurs, but if an error occurs when calling a JsonResult Action how can I return a JSON object that represents an error? I don't want to wrap the code in each action method that returns a JsonResult i...
TITLE: How to return JSON from a HandleError filter? QUESTION: aspnet mvc has the HandleError filter that will return a view if an error occurs, but if an error occurs when calling a JsonResult Action how can I return a JSON object that represents an error? I don't want to wrap the code in each action method that retu...
[ "asp.net-mvc" ]
12
10
4,319
3
0
2008-09-21T00:32:48.847000
2008-09-21T17:45:28.147000
109,916
110,169
Regular expression to match only the first file in a RAR file set
To see what file to invoke the unrar command on, one needs to determine which file is the first in the file set. Here are some sample file names, of which - naturally - only the first group should be matched: yes.rar yes.part1.rar yes.part01.rar yes.part001.rar no.part2.rar no.part02.rar no.part002.rar no.part011.rar ...
The short answer is that it's not possible to construct a single regex to satisfy your problem. Ruby 1.8 does not have lookaround assertions (the (? 1) Use more than one regex to do it. def is_first_rar(filename) if ((filename =~ /part(\d+)\.rar$/) == nil) return (filename =~ /\.rar$/)!= nil else return $1.to_i == 1 en...
Regular expression to match only the first file in a RAR file set To see what file to invoke the unrar command on, one needs to determine which file is the first in the file set. Here are some sample file names, of which - naturally - only the first group should be matched: yes.rar yes.part1.rar yes.part01.rar yes.part...
TITLE: Regular expression to match only the first file in a RAR file set QUESTION: To see what file to invoke the unrar command on, one needs to determine which file is the first in the file set. Here are some sample file names, of which - naturally - only the first group should be matched: yes.rar yes.part1.rar yes.p...
[ "ruby", "regex", "rar" ]
1
3
2,132
4
0
2008-09-21T01:14:46.873000
2008-09-21T03:31:40.227000
109,934
109,992
linq equivalent of 'select *' sql for generic function?
I've got a generic<> function that takes a linq query ('items') and enumerates through it adding additional properties. How can I select all the properties of the original 'item' rather than the item itself (as the code below does)? So equivalent to the sql: select *, 'bar' as Foo from items foreach (var item in items)...
There's no easy way of doing what you're suggesting, as all types in C# are strong-typed, even the anonymous ones like you're using. However it's not impossible to pull it off. To do it you would have to utilize reflection and emit your own assembly in memory, adding a new module and type that contains the specific pro...
linq equivalent of 'select *' sql for generic function? I've got a generic<> function that takes a linq query ('items') and enumerates through it adding additional properties. How can I select all the properties of the original 'item' rather than the item itself (as the code below does)? So equivalent to the sql: selec...
TITLE: linq equivalent of 'select *' sql for generic function? QUESTION: I've got a generic<> function that takes a linq query ('items') and enumerates through it adding additional properties. How can I select all the properties of the original 'item' rather than the item itself (as the code below does)? So equivalent...
[ "c#", "linq", "generics", "anonymous-types" ]
6
5
3,864
5
0
2008-09-21T01:25:30.887000
2008-09-21T01:55:54.667000
109,948
109,966
Xcode: 'Generics are not supported in -source 1.3' compiler error?
just a quick question: I am a CS undergrad and have only had experience with the Eclipse, and Net Beans IDEs. I have recently acquired a Macbook and was wanting to recompile a recent school project in Xcode just to test it out. Right after the line where I declare a new instance of an ArrayList: dictionary = new ArrayL...
Java support in Xcode is obsolete and unmaintained; it's the only bit of Xcode that still uses the "old" build system inherited from Project Builder. Even Apple suggests using Eclipse instead. For Java, both Eclipse and NetBeans work quite well on the Mac; if you want to try native Mac programming, use Objective-C and ...
Xcode: 'Generics are not supported in -source 1.3' compiler error? just a quick question: I am a CS undergrad and have only had experience with the Eclipse, and Net Beans IDEs. I have recently acquired a Macbook and was wanting to recompile a recent school project in Xcode just to test it out. Right after the line wher...
TITLE: Xcode: 'Generics are not supported in -source 1.3' compiler error? QUESTION: just a quick question: I am a CS undergrad and have only had experience with the Eclipse, and Net Beans IDEs. I have recently acquired a Macbook and was wanting to recompile a recent school project in Xcode just to test it out. Right a...
[ "java", "xcode", "compiler-construction" ]
2
8
5,256
3
0
2008-09-21T01:32:54.613000
2008-09-21T01:41:22.957000
109,970
110,100
How should I organize my ASP.Net themes and common CSS files
I am currently working on a project where a programmer who fancied themselves a graphic designer attempted their hand at ASP.Net themes. The CSS is pretty bad, but that is another question altogether. What I really need help with is the best way to organize ASP.Net Themes and the CSS that lies within them. Imagine that...
You should just include the standard/common css in the website and include it in the head of the masterpage instead of placing it in themes.
How should I organize my ASP.Net themes and common CSS files I am currently working on a project where a programmer who fancied themselves a graphic designer attempted their hand at ASP.Net themes. The CSS is pretty bad, but that is another question altogether. What I really need help with is the best way to organize A...
TITLE: How should I organize my ASP.Net themes and common CSS files QUESTION: I am currently working on a project where a programmer who fancied themselves a graphic designer attempted their hand at ASP.Net themes. The CSS is pretty bad, but that is another question altogether. What I really need help with is the best...
[ "asp.net", "css", "themes" ]
6
8
2,743
4
0
2008-09-21T01:42:12.313000
2008-09-21T02:54:30.767000
109,976
109,996
Why should I use RSpec or shoulda with Rails?
I am setting up a rails app and I just finished making some unit tests and my friend said that apparently fixtures are no longer cool and people are now using RSpec or shoulda. I was wondering what the actual benefits are to use these other toolkits. Any information at all is appreciated. -fREW
RSpec and similar frameworks are tooling designed to aid in Behavior Driven Development. They're not just a prettier way to write tests, though they do help with that. There is plenty of information on BDD here: http://behaviour-driven.org/ And wikipedia: http://en.wikipedia.org/wiki/Behavior_Driven_Development There a...
Why should I use RSpec or shoulda with Rails? I am setting up a rails app and I just finished making some unit tests and my friend said that apparently fixtures are no longer cool and people are now using RSpec or shoulda. I was wondering what the actual benefits are to use these other toolkits. Any information at all ...
TITLE: Why should I use RSpec or shoulda with Rails? QUESTION: I am setting up a rails app and I just finished making some unit tests and my friend said that apparently fixtures are no longer cool and people are now using RSpec or shoulda. I was wondering what the actual benefits are to use these other toolkits. Any i...
[ "ruby-on-rails", "ruby", "unit-testing", "testing", "shoulda" ]
33
17
12,827
8
0
2008-09-21T01:47:01.147000
2008-09-21T01:57:42.433000
109,993
110,025
How can I get a hardware-based screen capture?
In the past, some of my projects have required me to create a movie version of a fullscreen Flash application. The easiest way to do this has been to get a screen capture. However, capturing anything over 1024x768 has resulted in choppy video, which is unacceptable. I understand that there are hardware based solutions ...
Various professional products support full HD capture: http://www.decklink.com/products/hd/ http://www.aja.com/ There are others. Capturing the full, uncompressed digital or analog stream is a pretty heavy requirement. -Adam
How can I get a hardware-based screen capture? In the past, some of my projects have required me to create a movie version of a fullscreen Flash application. The easiest way to do this has been to get a screen capture. However, capturing anything over 1024x768 has resulted in choppy video, which is unacceptable. I unde...
TITLE: How can I get a hardware-based screen capture? QUESTION: In the past, some of my projects have required me to create a movie version of a fullscreen Flash application. The easiest way to do this has been to get a screen capture. However, capturing anything over 1024x768 has resulted in choppy video, which is un...
[ "flash", "video", "video-capture" ]
3
3
9,900
7
0
2008-09-21T01:55:57.227000
2008-09-21T02:16:01.563000
109,997
110,044
How do you protect your software from illegal distribution?
I am curious about how do you protect your software against cracking, hacking etc. Do you employ some kind of serial number check? Hardware keys? Do you use any third-party solutions? How do you go about solving licensing issues? (e.g. managing floating licenses) EDIT: I'm not talking any open source, but strictly comm...
There are many, many, many protections available. The key is: Assessing your target audience, and what they're willing to put up with Understanding your audience's desire to play with no pay Assessing the amount someone is willing to put forth to break your protection Applying just enough protection to prevent most peo...
How do you protect your software from illegal distribution? I am curious about how do you protect your software against cracking, hacking etc. Do you employ some kind of serial number check? Hardware keys? Do you use any third-party solutions? How do you go about solving licensing issues? (e.g. managing floating licens...
TITLE: How do you protect your software from illegal distribution? QUESTION: I am curious about how do you protect your software against cracking, hacking etc. Do you employ some kind of serial number check? Hardware keys? Do you use any third-party solutions? How do you go about solving licensing issues? (e.g. managi...
[ "security", "licensing", "software-distribution", "piracy" ]
94
78
20,533
22
0
2008-09-21T01:58:00.357000
2008-09-21T02:24:32.180000
110,008
110,212
Windows Licensing Question
This is slightly off topic of programming but still has to do with my programming project. I'm writing an app that uses a custom proxy server. I would like to write the server in C# since it would be easier to write and maintain, but I am concerned about the licensing cost of Windows Server + CALS vs a Linux server (ob...
If users will not be actually connecting to any MS server apps (such as Exchange, SQL Server, etc) and won't be using any OS features directly (i.e. connecting to UNC paths) then all that should be required is the server license for the machine to run the OS. You need Windows Server CALs when clients connect to shares,...
Windows Licensing Question This is slightly off topic of programming but still has to do with my programming project. I'm writing an app that uses a custom proxy server. I would like to write the server in C# since it would be easier to write and maintain, but I am concerned about the licensing cost of Windows Server +...
TITLE: Windows Licensing Question QUESTION: This is slightly off topic of programming but still has to do with my programming project. I'm writing an app that uses a custom proxy server. I would like to write the server in C# since it would be easier to write and maintain, but I am concerned about the licensing cost o...
[ "windows", "linux", "licensing" ]
0
2
649
7
0
2008-09-21T02:07:44.233000
2008-09-21T03:57:53.300000
110,015
110,364
Not getting event arguments in IHTMLElement event handler
I've added a callback to an IHTMLElement instance but when the IDispatch::Invoke is called for the event, there are never any arguments (i.e. the pDispParams->cArgs and pDispParams->cNamedArgs are always 0). For example, I add a callback for an onmouseup event. From what I can tell, a callback for this event is suppose...
Events arguments for all DOM events including onmouseup are stored in the parent window's event property ( IHTMLWindow2::event ) If you don't already have the parent window cached, IHTMLElement has a document property which returns an IHTMLDocument interface. From that you can query for IHTMLDocument2 which has a paren...
Not getting event arguments in IHTMLElement event handler I've added a callback to an IHTMLElement instance but when the IDispatch::Invoke is called for the event, there are never any arguments (i.e. the pDispParams->cArgs and pDispParams->cNamedArgs are always 0). For example, I add a callback for an onmouseup event. ...
TITLE: Not getting event arguments in IHTMLElement event handler QUESTION: I've added a callback to an IHTMLElement instance but when the IDispatch::Invoke is called for the event, there are never any arguments (i.e. the pDispParams->cArgs and pDispParams->cNamedArgs are always 0). For example, I add a callback for an...
[ "c++", "internet-explorer", "com", "mshtml" ]
4
6
1,743
1
0
2008-09-21T02:12:45.220000
2008-09-21T06:02:47.337000
110,016
110,042
Multiple column sort in JTable
I know that JTable can sort by a single column. But is it possible to allow for multiple column sort or do I need to write the code myself?
You can sort by multiple columns by specifying more than one sort key when calling setSortKeys in the RowSorter you're using.
Multiple column sort in JTable I know that JTable can sort by a single column. But is it possible to allow for multiple column sort or do I need to write the code myself?
TITLE: Multiple column sort in JTable QUESTION: I know that JTable can sort by a single column. But is it possible to allow for multiple column sort or do I need to write the code myself? ANSWER: You can sort by multiple columns by specifying more than one sort key when calling setSortKeys in the RowSorter you're usi...
[ "java", "swing", "jtable" ]
6
10
13,342
5
0
2008-09-21T02:13:04.597000
2008-09-21T02:24:20.340000
110,018
110,021
Best way to stamp an image with another image to create a watermark in ASP.NET?
Anyone know? Want to be able to on the fly stamp an image with another image as a watermark, also to do large batches. Any type of existing library or a technique you know of would be great.
This will answer your question: http://www.codeproject.com/KB/GDI-plus/watermark.aspx Good luck!
Best way to stamp an image with another image to create a watermark in ASP.NET? Anyone know? Want to be able to on the fly stamp an image with another image as a watermark, also to do large batches. Any type of existing library or a technique you know of would be great.
TITLE: Best way to stamp an image with another image to create a watermark in ASP.NET? QUESTION: Anyone know? Want to be able to on the fly stamp an image with another image as a watermark, also to do large batches. Any type of existing library or a technique you know of would be great. ANSWER: This will answer your ...
[ "asp.net", "graphics", "watermark", "stamp" ]
7
15
3,318
3
0
2008-09-21T02:14:21.003000
2008-09-21T02:15:19.753000
110,030
110,453
VisualStudio using BootCamp/VMWare on OS X
Just bought a 2.4GHz Intel Core 2 Duo iMac with 2GB of memory and a 320GB hard drive. I plan on doing some.net development on it using a BootCamp/VMWare combo since VMWare grants access to the bootcamp partition. What is a recommended size for a BootCamp partition and how much memory should I give VMWare? Any pitfalls ...
I use VMWare Fusion 2.0 on my MacBook Pro and I wouldn't have it any other way. I'd strongly recommend getting a min of 4gb RAM is you're going to run Windows + VS 2008 in virtualisation. I have a 2gb RAM for my VM and you do notice a bit of chugging, particularly when you are compiling a large solution, or when runnin...
VisualStudio using BootCamp/VMWare on OS X Just bought a 2.4GHz Intel Core 2 Duo iMac with 2GB of memory and a 320GB hard drive. I plan on doing some.net development on it using a BootCamp/VMWare combo since VMWare grants access to the bootcamp partition. What is a recommended size for a BootCamp partition and how much...
TITLE: VisualStudio using BootCamp/VMWare on OS X QUESTION: Just bought a 2.4GHz Intel Core 2 Duo iMac with 2GB of memory and a 320GB hard drive. I plan on doing some.net development on it using a BootCamp/VMWare combo since VMWare grants access to the bootcamp partition. What is a recommended size for a BootCamp part...
[ ".net", "visual-studio", "macos", "configuration", "vmware" ]
4
3
3,081
7
0
2008-09-21T02:20:49.243000
2008-09-21T07:09:24.120000
110,031
110,053
Is XSLT a functional programming language?
Several questions about functional programming languages have got me thinking about whether XSLT is a functional programming language. If not, what features are missing? Has XSLT 2.0 shortened or closed the gap?
XSLT is declarative as opposed to stateful. Although XSLT is based on functional programming ideas, it is not a full functional programming language, it lacks the ability to treat functions as a first class data type. It has elements like lazy evaluation to reduce unneeded evaluation and also the absence of explicit lo...
Is XSLT a functional programming language? Several questions about functional programming languages have got me thinking about whether XSLT is a functional programming language. If not, what features are missing? Has XSLT 2.0 shortened or closed the gap?
TITLE: Is XSLT a functional programming language? QUESTION: Several questions about functional programming languages have got me thinking about whether XSLT is a functional programming language. If not, what features are missing? Has XSLT 2.0 shortened or closed the gap? ANSWER: XSLT is declarative as opposed to stat...
[ "xslt", "functional-programming", "fxsl" ]
24
31
9,967
6
0
2008-09-21T02:21:44.793000
2008-09-21T02:29:02.763000
110,032
111,044
Star-Schema Design
Is a Star-Schema design essential to a data warehouse? Or can you do data warehousing with another design pattern?
Using star schemas for a data warehouse system gets you several benefits and in most cases it is appropriate to use them for the top layer. You may also have an operational data store (ODS) - a normalised structure that holds 'current state' and facilitates operations such as data conformation. However there are reason...
Star-Schema Design Is a Star-Schema design essential to a data warehouse? Or can you do data warehousing with another design pattern?
TITLE: Star-Schema Design QUESTION: Is a Star-Schema design essential to a data warehouse? Or can you do data warehousing with another design pattern? ANSWER: Using star schemas for a data warehouse system gets you several benefits and in most cases it is appropriate to use them for the top layer. You may also have a...
[ "database", "design-patterns", "data-warehouse", "star-schema", "dimensional-modeling" ]
63
97
36,614
8
0
2008-09-21T02:22:02.467000
2008-09-21T13:46:24.540000
110,078
110,834
What is the best way to store app specific configuration in rails?
I need to store app specific configuration in rails. But it has to be: reachable in any file (model, view, helpers and controllers environment specified (or not), that means each environment can overwrite the configs specified in environment.rb I've tried to use environment.rb and put something like USE_USER_APP = true...
I was helping a friend set up the solution mentioned by Ricardo yesterday. We hacked it a bit by loading the YAML file with something similar to this (going from memory here): require 'ostruct' require 'yaml' require 'erb' #config = OpenStruct.new(YAML.load_file("#{RAILS_ROOT}/config/config.yml")) config = OpenStruct.n...
What is the best way to store app specific configuration in rails? I need to store app specific configuration in rails. But it has to be: reachable in any file (model, view, helpers and controllers environment specified (or not), that means each environment can overwrite the configs specified in environment.rb I've tri...
TITLE: What is the best way to store app specific configuration in rails? QUESTION: I need to store app specific configuration in rails. But it has to be: reachable in any file (model, view, helpers and controllers environment specified (or not), that means each environment can overwrite the configs specified in envir...
[ "ruby-on-rails", "configuration" ]
6
4
4,623
6
0
2008-09-21T02:43:01.107000
2008-09-21T11:52:27.543000
110,081
110,102
LinearGradientBrush Artifact Workaround?
The LinearGradientBrush in.net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See here or here - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will start with a Black line and then with the proper White to B...
I have noticed this as well when using gradient brushes. The only effective workaround I have is to always create the gradient brush rectangle 1 pixel bigger on all edges than the area that is going to be painted with it. That protects you against the issue on all four edges. The downside is that the colors used at the...
LinearGradientBrush Artifact Workaround? The LinearGradientBrush in.net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See here or here - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will start with a Black...
TITLE: LinearGradientBrush Artifact Workaround? QUESTION: The LinearGradientBrush in.net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See here or here - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will ...
[ "c#", "gdi+" ]
9
9
1,950
5
0
2008-09-21T02:45:22.927000
2008-09-21T02:55:46.460000
110,083
110,389
Which loop has better performance? Why?
String s = ""; for(i=0;i<....){ s = some Assignment; } or for(i=0;i<..){ String s = some Assignment; } I don't need to use 's' outside the loop ever again. The first option is perhaps better since a new String is not initialized each time. The second however would result in the scope of the variable being limited to th...
Limited Scope is Best Use your second option: for (... ) { String s =...; } Scope Doesn't Affect Performance If you disassemble code the compiled from each (with the JDK's javap tool), you will see that the loop compiles to the exact same JVM instructions in both cases. Note also that Brian R. Bondy's "Option #3" is id...
Which loop has better performance? Why? String s = ""; for(i=0;i<....){ s = some Assignment; } or for(i=0;i<..){ String s = some Assignment; } I don't need to use 's' outside the loop ever again. The first option is perhaps better since a new String is not initialized each time. The second however would result in the s...
TITLE: Which loop has better performance? Why? QUESTION: String s = ""; for(i=0;i<....){ s = some Assignment; } or for(i=0;i<..){ String s = some Assignment; } I don't need to use 's' outside the loop ever again. The first option is perhaps better since a new String is not initialized each time. The second however wou...
[ "java", "performance", "string", "garbage-collection" ]
51
109
9,333
8
0
2008-09-21T02:46:43.393000
2008-09-21T06:24:46.287000
110,088
110,101
Is there set division in SQL?
I'm fully aware that set division can be accomplished through a series of other operations, so my question is: Is there a command for set division in SQL?
http://vadimtropashko.files.wordpress.com/2007/02/ch3.pdf From Page 32: Relational Division is not a fundamental operator. It can be expressed in terms of projection, Cartesian product, and set difference. So, no.:)
Is there set division in SQL? I'm fully aware that set division can be accomplished through a series of other operations, so my question is: Is there a command for set division in SQL?
TITLE: Is there set division in SQL? QUESTION: I'm fully aware that set division can be accomplished through a series of other operations, so my question is: Is there a command for set division in SQL? ANSWER: http://vadimtropashko.files.wordpress.com/2007/02/ch3.pdf From Page 32: Relational Division is not a fundame...
[ "sql", "database", "relational-algebra", "set-theory" ]
4
5
10,390
3
0
2008-09-21T02:47:09.147000
2008-09-21T02:54:56.913000
110,121
110,137
Logic and its application to Collections.Generic and inheritance
Everything inherits from object. It's the basis of inheritance. Everything can be implicitly cast up the inheritance tree, ie. object me = new Person(); Therefore, following this through to its logical conclusion, a group of People would also be a group of objects: List people = new List (); people.Add(me); people.Add(...
OK, everyone who has used generics in.net must have run into this at one point or another. Yes, intuitively it should work. No, in the current version of the C# compiler it doesn't. Eric Lippert has a really good explanation of this issue (it's in eleven parts or something and will bend you mind in places, but it's wel...
Logic and its application to Collections.Generic and inheritance Everything inherits from object. It's the basis of inheritance. Everything can be implicitly cast up the inheritance tree, ie. object me = new Person(); Therefore, following this through to its logical conclusion, a group of People would also be a group o...
TITLE: Logic and its application to Collections.Generic and inheritance QUESTION: Everything inherits from object. It's the basis of inheritance. Everything can be implicitly cast up the inheritance tree, ie. object me = new Person(); Therefore, following this through to its logical conclusion, a group of People would...
[ ".net", "inheritance", "collections" ]
3
5
654
6
0
2008-09-21T03:08:58.143000
2008-09-21T03:13:30.957000
110,124
110,162
Tips for getting started with SQL?
I've never had much need for programming with databases. Since their use is so widespread it seems like a good thing for me to learn. SQL seems like the place to start, possibly SQLite and maybe the Python bindings. What would you recommend for someone new to this? Libraries, tools and project ideas are all welcome.
Structure Query Language (SQL) is the language used to talk to database management systems (DBMS). While it's a good thing to learn, it's probably best to do it with a project in mind that you'd like to do. It's funny you say you've never had a need, because I'm the opposite, almost every program I've ever written has ...
Tips for getting started with SQL? I've never had much need for programming with databases. Since their use is so widespread it seems like a good thing for me to learn. SQL seems like the place to start, possibly SQLite and maybe the Python bindings. What would you recommend for someone new to this? Libraries, tools an...
TITLE: Tips for getting started with SQL? QUESTION: I've never had much need for programming with databases. Since their use is so widespread it seems like a good thing for me to learn. SQL seems like the place to start, possibly SQLite and maybe the Python bindings. What would you recommend for someone new to this? L...
[ "sql" ]
3
2
1,592
18
0
2008-09-21T03:09:44.193000
2008-09-21T03:28:23.697000
110,157
110,255
How to retrieve all keys (or values) from a std::map and put them into a vector?
This is one of the possible ways I come out: struct RetrieveKey { template typename T::first_type operator()(T keyValuePair) const { return keyValuePair.first; } }; map m; vector keys; // Retrieve all keys transform(m.begin(), m.end(), back_inserter(keys), RetrieveKey()); // Dump all keys copy(keys.begin(), keys.end...
While your solution should work, it can be difficult to read depending on the skill level of your fellow programmers. Additionally, it moves functionality away from the call site. Which can make maintenance a little more difficult. I'm not sure if your goal is to get the keys into a vector or print them to cout so I'm ...
How to retrieve all keys (or values) from a std::map and put them into a vector? This is one of the possible ways I come out: struct RetrieveKey { template typename T::first_type operator()(T keyValuePair) const { return keyValuePair.first; } }; map m; vector keys; // Retrieve all keys transform(m.begin(), m.end(), b...
TITLE: How to retrieve all keys (or values) from a std::map and put them into a vector? QUESTION: This is one of the possible ways I come out: struct RetrieveKey { template typename T::first_type operator()(T keyValuePair) const { return keyValuePair.first; } }; map m; vector keys; // Retrieve all keys transform(m.b...
[ "c++", "dictionary", "stl", "stdmap" ]
352
232
581,911
25
0
2008-09-21T03:23:58.233000
2008-09-21T04:38:34.450000
110,163
110,321
How do I save a model with this dynamically generated field?
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base has_many:ingredients attr_accessor:ingredients_string attr_accessible:title,:directions,:ingredients,:ingredients_string before_save:set_ingredients def ingredients_string ingredients.join("\n") end private def set_ingredients se...
Using these two together are probably causing your issues. Both are trying to define an ingredients_string method that do different things attr_accessor:ingredients_string def ingredients_string ingredients.join("\n") end Get rid of the attr_accessor, the before_save, set_ingredients method and define your own ingredi...
How do I save a model with this dynamically generated field? I have a rails model that looks something like this: class Recipe < ActiveRecord::Base has_many:ingredients attr_accessor:ingredients_string attr_accessible:title,:directions,:ingredients,:ingredients_string before_save:set_ingredients def ingredients_strin...
TITLE: How do I save a model with this dynamically generated field? QUESTION: I have a rails model that looks something like this: class Recipe < ActiveRecord::Base has_many:ingredients attr_accessor:ingredients_string attr_accessible:title,:directions,:ingredients,:ingredients_string before_save:set_ingredients def...
[ "ruby-on-rails" ]
0
0
161
3
0
2008-09-21T03:28:30.297000
2008-09-21T05:30:19.257000
110,175
110,185
How to access the current Subversion build number?
How can you automatically import the latest build/revision number in subversion? The goal would be to have that number visible on your webpage footer like SO does.
svn info or svn info --xml Then look at the result. For xml, parse /info/entry/@revision for the revision of the repository (151 in this example) or /info/entry/commit/@revision for the revision of the last commit against this path (133, useful when working with tags): http://myserver/svn/stumde/cmdtools http://myserve...
How to access the current Subversion build number? How can you automatically import the latest build/revision number in subversion? The goal would be to have that number visible on your webpage footer like SO does.
TITLE: How to access the current Subversion build number? QUESTION: How can you automatically import the latest build/revision number in subversion? The goal would be to have that number visible on your webpage footer like SO does. ANSWER: svn info or svn info --xml Then look at the result. For xml, parse /info/entry...
[ "svn" ]
22
14
32,754
16
0
2008-09-21T03:34:56.957000
2008-09-21T03:40:20.517000
110,186
110,275
Feedback on using Google App Engine?
Looking to do a very small, quick 'n dirty side project. I like the fact that the Google App Engine is running on Python with Django built right in - gives me an excuse to try that platform... but my question is this: Has anyone made use of the app engine for anything other than a toy problem? I see some good example a...
I have tried app engine for my small quake watch application http://quakewatch.appspot.com/ My purpose was to see the capabilities of app engine, so here are the main points: it doesn't come by default with Django, it has its own web framework which is pythonic has URL dispatcher like Django and it uses Django template...
Feedback on using Google App Engine? Looking to do a very small, quick 'n dirty side project. I like the fact that the Google App Engine is running on Python with Django built right in - gives me an excuse to try that platform... but my question is this: Has anyone made use of the app engine for anything other than a t...
TITLE: Feedback on using Google App Engine? QUESTION: Looking to do a very small, quick 'n dirty side project. I like the fact that the Google App Engine is running on Python with Django built right in - gives me an excuse to try that platform... but my question is this: Has anyone made use of the app engine for anyth...
[ "python", "django", "google-app-engine" ]
127
63
10,668
11
0
2008-09-21T03:41:19.500000
2008-09-21T04:52:12.543000
110,205
110,209
Want to download a Git repository, what do I need (windows machine)?
I want to download this open source application, and they are using Git. What do I need to download the code base? Update How do I change the working directory when I am using Git Bash? (I want to download the repo at a certain directory, using pwd tells me I will be downloading the repo where I don't want it.
Download Git on Msys. Then: git clone git://project.url.here
Want to download a Git repository, what do I need (windows machine)? I want to download this open source application, and they are using Git. What do I need to download the code base? Update How do I change the working directory when I am using Git Bash? (I want to download the repo at a certain directory, using pwd te...
TITLE: Want to download a Git repository, what do I need (windows machine)? QUESTION: I want to download this open source application, and they are using Git. What do I need to download the code base? Update How do I change the working directory when I am using Git Bash? (I want to download the repo at a certain direc...
[ "windows", "git" ]
71
98
141,005
4
0
2008-09-21T03:53:57.507000
2008-09-21T03:55:47.750000
110,229
110,231
Is "int?" somehow a reference type?
What is the behind-the-scenes difference between int? and int data types? Is int? somehow a reference type?
? wraps the value type (T) in a Nullable struct: http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx
Is "int?" somehow a reference type? What is the behind-the-scenes difference between int? and int data types? Is int? somehow a reference type?
TITLE: Is "int?" somehow a reference type? QUESTION: What is the behind-the-scenes difference between int? and int data types? Is int? somehow a reference type? ANSWER: ? wraps the value type (T) in a Nullable struct: http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx
[ "c#", "nullable" ]
24
43
35,518
4
0
2008-09-21T04:15:30.807000
2008-09-21T04:16:51.833000
110,232
112,685
CakePHP multi-model view
I am creating a website in CakePHP and I am kind of new on it. I couldn't find good resources on this matter, so there you go: I have a three table structure for registering users: Users, Addresses and Contacts. I have to build a view with info of all three tables like: Full Name: [ ] (from Users) Shipping Address: [ ]...
If your using the latest 1.2 code, check out Model::saveAll in the api eg. Your view might look something like this: echo $form->create('User', array('action' => 'add'); echo $form->input('User.name'); echo $form->input('Address.line_1'); echo $form->input('Contact.tel'); echo $form->end('Save'); Then in your Users con...
CakePHP multi-model view I am creating a website in CakePHP and I am kind of new on it. I couldn't find good resources on this matter, so there you go: I have a three table structure for registering users: Users, Addresses and Contacts. I have to build a view with info of all three tables like: Full Name: [ ] (from Use...
TITLE: CakePHP multi-model view QUESTION: I am creating a website in CakePHP and I am kind of new on it. I couldn't find good resources on this matter, so there you go: I have a three table structure for registering users: Users, Addresses and Contacts. I have to build a view with info of all three tables like: Full N...
[ "cakephp", "entity-relationship", "model-driven", "cakephp-1.2" ]
5
10
5,416
3
0
2008-09-21T04:19:28.753000
2008-09-22T00:44:59.230000
110,249
113,022
Building and deploying dll on windows: SxS, manifests and all that jazz
Since VS 2005, I see that it is not possible to simply build a dll against MS runtime and deploy them together ( http://www.ddj.com/windows/184406482 ). I am deeply confused by manifest, SxS and co: MSDN documentation is really poor, with circular references; specially since I am more a Unix guy, I find all those uninf...
We use a simple include file in all our applications & DLL's, vcmanifest.h, then set all projects to embedded the manifest file. vcmanifest.h /*----------------------------------------------------------------------------*/ #if _MSC_VER >= 1400 /*------------------------------------------------------------------------...
Building and deploying dll on windows: SxS, manifests and all that jazz Since VS 2005, I see that it is not possible to simply build a dll against MS runtime and deploy them together ( http://www.ddj.com/windows/184406482 ). I am deeply confused by manifest, SxS and co: MSDN documentation is really poor, with circular ...
TITLE: Building and deploying dll on windows: SxS, manifests and all that jazz QUESTION: Since VS 2005, I see that it is not possible to simply build a dll against MS runtime and deploy them together ( http://www.ddj.com/windows/184406482 ). I am deeply confused by manifest, SxS and co: MSDN documentation is really po...
[ "windows", "dll", "manifest", "sxs" ]
3
3
9,653
8
0
2008-09-21T04:33:47.910000
2008-09-22T03:20:49.027000
110,259
110,826
Which Python memory profiler is recommended?
I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory. Google search shows a commercial one is Python Memory Validator (Windows only). And open source ones are PySizer and Heapy. I haven't tried anyone, so I wanted to know w...
guppy3 is quite simple to use. At some point in your code, you have to write the following: from guppy import hpy h = hpy() print(h.heap()) This gives you some output like this: Partition of a set of 132527 objects. Total size = 8301532 bytes. Index Count % Size % Cumulative % Kind (class / dict of class) 0 35144 27 21...
Which Python memory profiler is recommended? I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory. Google search shows a commercial one is Python Memory Validator (Windows only). And open source ones are PySizer and Heapy. ...
TITLE: Which Python memory profiler is recommended? QUESTION: I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory. Google search shows a commercial one is Python Memory Validator (Windows only). And open source ones are P...
[ "python", "performance", "memory-management", "profiling" ]
766
313
351,842
8
0
2008-09-21T04:43:04.737000
2008-09-21T11:45:39.977000
110,263
110,351
how do i add project references to swcs in FlashDevelop
I am trying to add a project reference or swc to papervision in FlashDevelop but intellisense isn't picking it up. I've done it before but i forgot how. Thanks.
Add your swc to the lib folder of your project. Then right-click it and mark "Add To Library".
how do i add project references to swcs in FlashDevelop I am trying to add a project reference or swc to papervision in FlashDevelop but intellisense isn't picking it up. I've done it before but i forgot how. Thanks.
TITLE: how do i add project references to swcs in FlashDevelop QUESTION: I am trying to add a project reference or swc to papervision in FlashDevelop but intellisense isn't picking it up. I've done it before but i forgot how. Thanks. ANSWER: Add your swc to the lib folder of your project. Then right-click it and mark...
[ "apache-flex", "flash", "actionscript-3", "actionscript", "flashdevelop" ]
8
26
8,983
2
0
2008-09-21T04:45:09.363000
2008-09-21T05:53:01.400000
110,271
110,285
Is using Dexter's character sprite okay, or do I have to
. Inspiration -- Southpark game (very popular if you see download count on download.com,,, did he ask for permission??) I am making a 2d game based on dexter's lab theme. I've got the sprite of dexter from GSA. basically I'm not an artist, so I have to depend on already available sprites, backgrounds, sfx on websites l...
I am not a lawyer. This is not legal advice. If you made the sprite yourself, you'd be fine. If you got a release to use it from the creator, you'd be fine. If it was released into the public domain, you'd be fine. Anything else, you'd have a definate problem with. There's also the possible problem you'd have even if y...
Is using Dexter's character sprite okay, or do I have to . Inspiration -- Southpark game (very popular if you see download count on download.com,,, did he ask for permission??) I am making a 2d game based on dexter's lab theme. I've got the sprite of dexter from GSA. basically I'm not an artist, so I have to depend on ...
TITLE: Is using Dexter's character sprite okay, or do I have to QUESTION: . Inspiration -- Southpark game (very popular if you see download count on download.com,,, did he ask for permission??) I am making a 2d game based on dexter's lab theme. I've got the sprite of dexter from GSA. basically I'm not an artist, so I ...
[ "graphics", "2d", "media" ]
1
5
907
3
0
2008-09-21T04:50:18.603000
2008-09-21T04:56:59.787000
110,274
110,326
VMware ESX vs. VMware Workstation
I'm using VMware Workstation 6.0 for simulation of tight clusters of "blades" in a "chassis". Both the host and target OSs are Linux. Each "chassis" uses a vmnet switch as a virtual backplane, to which the virtual blades connect. Other vmnet switches are used to mediate point-to-point connections between mutiple virtua...
The first thing you'll gain by switching will be a substantially more powerful platform that's running directly on the bare-metal of your server. From my experience, moving up the VMware application stack has never been problematic (Server to Workstation to ESX). However, I would verify this by exporting all of your VM...
VMware ESX vs. VMware Workstation I'm using VMware Workstation 6.0 for simulation of tight clusters of "blades" in a "chassis". Both the host and target OSs are Linux. Each "chassis" uses a vmnet switch as a virtual backplane, to which the virtual blades connect. Other vmnet switches are used to mediate point-to-point ...
TITLE: VMware ESX vs. VMware Workstation QUESTION: I'm using VMware Workstation 6.0 for simulation of tight clusters of "blades" in a "chassis". Both the host and target OSs are Linux. Each "chassis" uses a vmnet switch as a virtual backplane, to which the virtual blades connect. Other vmnet switches are used to media...
[ "vmware", "virtualization", "simulation" ]
3
4
7,957
4
0
2008-09-21T04:51:56.273000
2008-09-21T05:33:55.627000
110,279
110,387
How do you find media resources for game-dev?
I've been wondering, as a lone game developer, or to say a part of team which has only got programmers and people who like to play games... How do I manage the void created by lack of artists (sprites/tiles/animations) in such a situation??? What do you do in that case? and suppose I am a student, with no money to hire...
For images there is also several sites like freespace pointed out for instance http://commons.wikimedia.org/ another great resource for getting artwork/images for your projects is to reach out to art schools or other locations that you know artists frequent and permit them to sign or get credit for any creation you use...
How do you find media resources for game-dev? I've been wondering, as a lone game developer, or to say a part of team which has only got programmers and people who like to play games... How do I manage the void created by lack of artists (sprites/tiles/animations) in such a situation??? What do you do in that case? and...
TITLE: How do you find media resources for game-dev? QUESTION: I've been wondering, as a lone game developer, or to say a part of team which has only got programmers and people who like to play games... How do I manage the void created by lack of artists (sprites/tiles/animations) in such a situation??? What do you do...
[ "resources", "media" ]
3
1
451
4
0
2008-09-21T04:54:52.600000
2008-09-21T06:22:11.440000
110,281
110,291
How is style inherited
How can I make a style have all of the properties of the style defined in.a.b.c except for background-color (or some other property)? This does not seem to work..a.b.c { background-color: #0000FF; color: #ffffff; border: 1px solid #c0c0c0; margin-top: 4px; padding: 3px; text-align: center; font-weight: bold; }.a.b.c.d ...
You would add the.d class selector as a selector for your first rule, then add a rule to redefine the background color for.d:.a.b.c,.d { background-color: #0000FF; color: #ffffff; border: 1px solid #c0c0c0; margin-top: 4px; padding: 3px; text-align: center; font-weight: bold; }.d { background-color: green; } That is th...
How is style inherited How can I make a style have all of the properties of the style defined in.a.b.c except for background-color (or some other property)? This does not seem to work..a.b.c { background-color: #0000FF; color: #ffffff; border: 1px solid #c0c0c0; margin-top: 4px; padding: 3px; text-align: center; font-w...
TITLE: How is style inherited QUESTION: How can I make a style have all of the properties of the style defined in.a.b.c except for background-color (or some other property)? This does not seem to work..a.b.c { background-color: #0000FF; color: #ffffff; border: 1px solid #c0c0c0; margin-top: 4px; padding: 3px; text-ali...
[ "css" ]
1
1
258
5
0
2008-09-21T04:56:08.043000
2008-09-21T05:04:34.123000
110,305
131,103
Internet Explorer ol numbers appear at bottom of li instead of top as expected
I'm working on a page has an ol with nested p's, div's, and li's. Internet Explorer 6 and 7 both render the numbers for the ol tag after the p element at the end (at the very, very bottom of the li tag) rather than at the top of the outermost li as expected. I'm working on a PowerPC Mac and can't do any testing. Is the...
Congratulations, you are the victim of IE's hasLayout property. Short version: You've got it easy this time. Changes these rules:... ol { font-size: 1.1em; }... li.main_item { width: 700px; clear: right; }... To this:... ol { font-size: 1.1em; width: 700px; }... li.main_item { clear: right; }... And it's all good. ...
Internet Explorer ol numbers appear at bottom of li instead of top as expected I'm working on a page has an ol with nested p's, div's, and li's. Internet Explorer 6 and 7 both render the numbers for the ol tag after the p element at the end (at the very, very bottom of the li tag) rather than at the top of the outermos...
TITLE: Internet Explorer ol numbers appear at bottom of li instead of top as expected QUESTION: I'm working on a page has an ol with nested p's, div's, and li's. Internet Explorer 6 and 7 both render the numbers for the ol tag after the p element at the end (at the very, very bottom of the li tag) rather than at the t...
[ "html", "internet-explorer", "rendering", "haslayout" ]
4
12
6,065
4
0
2008-09-21T05:19:11.777000
2008-09-25T02:05:48.450000
110,313
110,619
How to make sure my git repo code is safe?
If our organisation were to switch from a central-server VCS like subversion to a distributed VCS like git, how do I make sure that all my code is safe from hardware failure? With a central-server VCS I just need to backup the repository every day. If we were using a DVCS then there'd be loads of code branches on all t...
I think that you will find that in practice developers will prefer to use a central repository than pushing and pulling between each other's local repositories. Once you've cloned a central repository, while working on any tracking branches, fetching and pushing are trivial commands. Adding half a dozen remotes to all ...
How to make sure my git repo code is safe? If our organisation were to switch from a central-server VCS like subversion to a distributed VCS like git, how do I make sure that all my code is safe from hardware failure? With a central-server VCS I just need to backup the repository every day. If we were using a DVCS then...
TITLE: How to make sure my git repo code is safe? QUESTION: If our organisation were to switch from a central-server VCS like subversion to a distributed VCS like git, how do I make sure that all my code is safe from hardware failure? With a central-server VCS I just need to backup the repository every day. If we were...
[ "git", "backup", "dvcs" ]
7
12
2,671
7
0
2008-09-21T05:25:29.767000
2008-09-21T09:21:16.097000
110,314
131,551
LINQ to entities - Building where clauses to test collections within a many to many relationship
So, I am using the Linq entity framework. I have 2 entities: Content and Tag. They are in a many-to-many relationship with one another. Content can have many Tags and Tag can have many Contents. So I am trying to write a query to select all contents where any tags names are equal to blah The entities both have a collec...
After reading about the PredicateBuilder, reading all of the wonderful posts that people sent to me, posting on other sites, and then reading more on Combining Predicates and Canonical Function Mapping.. oh and I picked up a bit from Calling functions in LINQ queries (some of these classes were taken from these pages)....
LINQ to entities - Building where clauses to test collections within a many to many relationship So, I am using the Linq entity framework. I have 2 entities: Content and Tag. They are in a many-to-many relationship with one another. Content can have many Tags and Tag can have many Contents. So I am trying to write a qu...
TITLE: LINQ to entities - Building where clauses to test collections within a many to many relationship QUESTION: So, I am using the Linq entity framework. I have 2 entities: Content and Tag. They are in a many-to-many relationship with one another. Content can have many Tags and Tag can have many Contents. So I am tr...
[ "c#", "linq", "entity-framework", "lambda", "many-to-many" ]
18
19
20,533
6
0
2008-09-21T05:28:03.690000
2008-09-25T05:04:08.910000
110,325
110,372
Get millions of records from fixed-width flat file to SQL 2000
Obviously I can use BCP but here is the issue. If one of the records in a Batch have an invalid date I want to redirect that to a separate table/file/whatever, but keep the batch processing running. I don't think SSIS can be installed on the server which would have helped.
Create a trigger that processes on INSERT. This trigger will do a validation check on your date field. If it fails the validation, then do an insert into your separate table, and you can also choose to continue the insert or not allow it to go through. an important note: by default triggers do not fire on bulk inserts ...
Get millions of records from fixed-width flat file to SQL 2000 Obviously I can use BCP but here is the issue. If one of the records in a Batch have an invalid date I want to redirect that to a separate table/file/whatever, but keep the batch processing running. I don't think SSIS can be installed on the server which wo...
TITLE: Get millions of records from fixed-width flat file to SQL 2000 QUESTION: Obviously I can use BCP but here is the issue. If one of the records in a Batch have an invalid date I want to redirect that to a separate table/file/whatever, but keep the batch processing running. I don't think SSIS can be installed on t...
[ "c#", "sql-server" ]
0
5
543
4
0
2008-09-21T05:32:43.790000
2008-09-21T06:10:50.407000
110,328
110,612
How much business logic should Value objects contain?
One mentor I respect suggests that a simple bean is a waste of time - that value objects 'MUST' contain some business logic to be useful. Another says such code is difficult to maintain and that all business logic must be externalized. I realize this question is subjective. Asking anyway - want to know answers from mor...
The idea of putting data and business logic together is to promote encapsulation, and to expose as little internal state as possible to other objects. That way, clients can rely on an interface rather than on an implementation. See the "Tell, Don't Ask" principle and the Law of Demeter. Encapsulation makes it easier to...
How much business logic should Value objects contain? One mentor I respect suggests that a simple bean is a waste of time - that value objects 'MUST' contain some business logic to be useful. Another says such code is difficult to maintain and that all business logic must be externalized. I realize this question is sub...
TITLE: How much business logic should Value objects contain? QUESTION: One mentor I respect suggests that a simple bean is a waste of time - that value objects 'MUST' contain some business logic to be useful. Another says such code is difficult to maintain and that all business logic must be externalized. I realize th...
[ "java", "oop", "data-transfer-objects" ]
18
35
15,416
6
0
2008-09-21T05:34:46.047000
2008-09-21T09:18:16.227000
110,332
110,343
filtering NSArray into a new NSArray in Objective-C
I have an NSArray and I'd like to create a new NSArray with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a BOOL. I can create an NSMutableArray, iterate through the source array and copy over the objects that the filter function accepts and then create a...
NSArray and NSMutableArray provide methods to filter array contents. NSArray provides filteredArrayUsingPredicate: which returns a new array containing objects in the receiver that match the specified predicate. NSMutableArray adds filterUsingPredicate: which evaluates the receiver’s content against the specified predi...
filtering NSArray into a new NSArray in Objective-C I have an NSArray and I'd like to create a new NSArray with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a BOOL. I can create an NSMutableArray, iterate through the source array and copy over the object...
TITLE: filtering NSArray into a new NSArray in Objective-C QUESTION: I have an NSArray and I'd like to create a new NSArray with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a BOOL. I can create an NSMutableArray, iterate through the source array and co...
[ "objective-c", "cocoa", "nsarray" ]
129
145
126,581
9
0
2008-09-21T05:36:29.413000
2008-09-21T05:43:47.087000
110,336
111,276
Closing a minimized/iconized process from C#
Here's my issue: I need to close a process, already running, from a C# program. The problem is that the process now runs as an icon (minimized to taskbar), and unless the user opens it at least once (which will never happen on unattended machines), it'll never have a main window. The other requirement that I have is th...
Here are some answers and clarifications: rpetrich: Tried your method before and the problem is, I don't know the window name, it differs from user to user, version to version - just the exe name remains constant. All I have is the process name. And as you can see in the code above the MainWindowHandle of the process i...
Closing a minimized/iconized process from C# Here's my issue: I need to close a process, already running, from a C# program. The problem is that the process now runs as an icon (minimized to taskbar), and unless the user opens it at least once (which will never happen on unattended machines), it'll never have a main wi...
TITLE: Closing a minimized/iconized process from C# QUESTION: Here's my issue: I need to close a process, already running, from a C# program. The problem is that the process now runs as an icon (minimized to taskbar), and unless the user opens it at least once (which will never happen on unattended machines), it'll ne...
[ "c#", "winapi", "process", "kill" ]
3
0
4,353
4
0
2008-09-21T05:40:50.463000
2008-09-21T15:53:48.913000
110,344
110,365
Algorithm to calculate the number of divisors of a given number
What would be the most optimal algorithm (performance-wise) to calculate the number of divisors of a given number? It'll be great if you could provide pseudocode or a link to some example. EDIT: All the answers have been very helpful, thank you. I'm implementing the Sieve of Atkin and then I'm going to use something si...
Dmitriy is right that you'll want the Sieve of Atkin to generate the prime list but I don't believe that takes care of the whole issue. Now that you have a list of primes you'll need to see how many of those primes act as a divisor (and how often). Here's some python for the algo Look here and search for "Subject: math...
Algorithm to calculate the number of divisors of a given number What would be the most optimal algorithm (performance-wise) to calculate the number of divisors of a given number? It'll be great if you could provide pseudocode or a link to some example. EDIT: All the answers have been very helpful, thank you. I'm implem...
TITLE: Algorithm to calculate the number of divisors of a given number QUESTION: What would be the most optimal algorithm (performance-wise) to calculate the number of divisors of a given number? It'll be great if you could provide pseudocode or a link to some example. EDIT: All the answers have been very helpful, tha...
[ "performance", "algorithm", "pseudocode" ]
183
78
162,337
26
0
2008-09-21T05:44:34.010000
2008-09-21T06:03:34.293000
110,354
110,361
Can an element's CSS class be set via JavaScript?
I want to do this: e.className = t; Where t is the name of a style I have defined in a stylesheet.
If e is a reference to a DOM element and you have a class like this:.t {color:green;} then you want reference the class name as a string: e.className = 't';
Can an element's CSS class be set via JavaScript? I want to do this: e.className = t; Where t is the name of a style I have defined in a stylesheet.
TITLE: Can an element's CSS class be set via JavaScript? QUESTION: I want to do this: e.className = t; Where t is the name of a style I have defined in a stylesheet. ANSWER: If e is a reference to a DOM element and you have a class like this:.t {color:green;} then you want reference the class name as a string: e.clas...
[ "javascript", "css" ]
3
19
2,838
5
0
2008-09-21T05:54:09.323000
2008-09-21T06:00:57.373000
110,362
110,829
How can I find the current OS in Python?
As the title says, how can I find the current operating system in python?
I usually use sys.platform to get the platform. sys.platform will distinguish between linux, other unixes, and OS X, while os.name is " posix " for all of them. For much more detailed information, use the platform module. This has cross-platform functions that will give you information on the machine architecture, OS a...
How can I find the current OS in Python? As the title says, how can I find the current operating system in python?
TITLE: How can I find the current OS in Python? QUESTION: As the title says, how can I find the current operating system in python? ANSWER: I usually use sys.platform to get the platform. sys.platform will distinguish between linux, other unixes, and OS X, while os.name is " posix " for all of them. For much more det...
[ "python", "cross-platform", "platform-specific" ]
352
347
436,194
5
0
2008-09-21T06:01:06.153000
2008-09-21T11:49:19.687000
110,378
110,414
Change the width of form elements created with ModelForm in Django
How can I change the width of a textarea form element if I used ModelForm to create it? Here is my product class: class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widget=forms.Textarea) class Meta: model = Product And the template code... {% for f in form %} ...
The easiest way for your use case is to use CSS. It's a language meant for defining presentation. Look at the code generated by form, take note of the ids for fields that interest you, and change appearance of these fields through CSS. Example for long_desc field in your ProductForm (when your form does not have a cust...
Change the width of form elements created with ModelForm in Django How can I change the width of a textarea form element if I used ModelForm to create it? Here is my product class: class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widget=forms.Textarea) class ...
TITLE: Change the width of form elements created with ModelForm in Django QUESTION: How can I change the width of a textarea form element if I used ModelForm to create it? Here is my product class: class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widget=form...
[ "python", "html", "django", "django-forms", "django-templates" ]
60
130
67,213
5
0
2008-09-21T06:15:13.517000
2008-09-21T06:44:02.057000
110,384
110,630
Setting result for IAuthorizationFilter
I am looking to set the result action from a failed IAuthorizationFilter. However I am unsure how to create an ActionResult from inside the Filter. The controller doesn't seem to be accible from inside the filter so my usual View("SomeView") isn't working. Is there a way to get the controler or else another way of crea...
You can instantiate the appropriate ActionResult directly, then set it on the context. For example: public void OnAuthorization(AuthorizationContext context) { if (!context.HttpContext.User.Identity.IsAuthenticated) { context.Result = new ViewResult { ViewName = "Whatever" }; } }
Setting result for IAuthorizationFilter I am looking to set the result action from a failed IAuthorizationFilter. However I am unsure how to create an ActionResult from inside the Filter. The controller doesn't seem to be accible from inside the filter so my usual View("SomeView") isn't working. Is there a way to get t...
TITLE: Setting result for IAuthorizationFilter QUESTION: I am looking to set the result action from a failed IAuthorizationFilter. However I am unsure how to create an ActionResult from inside the Filter. The controller doesn't seem to be accible from inside the filter so my usual View("SomeView") isn't working. Is th...
[ "asp.net-mvc" ]
2
1
2,545
2
0
2008-09-21T06:20:03.643000
2008-09-21T09:32:02.870000
110,385
110,398
Limiting a group of checkboxes to a certain amount of checks
I have a group of checkboxes that I only want to allow a set amount to be checked at any one time. If the newly checked checkbox pushes the count over the limit, I'd like the oldest checkbox to be automatically unchecked. The group of checkboxes all use the same event handler shown below. I have achieved the functional...
I think you are looking for a LinkedList. Use AddLast instead of Enqueue and RemoveFirst instead of Dequeue and for removing something in the middle, just use a normal Remove.
Limiting a group of checkboxes to a certain amount of checks I have a group of checkboxes that I only want to allow a set amount to be checked at any one time. If the newly checked checkbox pushes the count over the limit, I'd like the oldest checkbox to be automatically unchecked. The group of checkboxes all use the s...
TITLE: Limiting a group of checkboxes to a certain amount of checks QUESTION: I have a group of checkboxes that I only want to allow a set amount to be checked at any one time. If the newly checked checkbox pushes the count over the limit, I'd like the oldest checkbox to be automatically unchecked. The group of checkb...
[ ".net", "winforms", "user-interface" ]
0
2
671
6
0
2008-09-21T06:20:04.143000
2008-09-21T06:29:02.360000
110,393
110,425
TinyXML: Save document to char * or string
I'm attempting to use TinyXML to read and save from memory, instead of only reading and saving files to disk. It seems that the documnent's parse function can load a char *. But then I need to save the document to a char * when I'm done with it. Does anyone know about this? Edit: The printing & streaming functions aren...
I'm not familiar with TinyXML, but from the documentation it seems that by using operator << to a C++ stream (so you can use C++ string streams ) or a TiXMLPrinter class you can get an STL string without using a file. See TinyXML documentation (look for the "Printing" section)
TinyXML: Save document to char * or string I'm attempting to use TinyXML to read and save from memory, instead of only reading and saving files to disk. It seems that the documnent's parse function can load a char *. But then I need to save the document to a char * when I'm done with it. Does anyone know about this? Ed...
TITLE: TinyXML: Save document to char * or string QUESTION: I'm attempting to use TinyXML to read and save from memory, instead of only reading and saving files to disk. It seems that the documnent's parse function can load a char *. But then I need to save the document to a char * when I'm done with it. Does anyone k...
[ "c++", "tinyxml" ]
14
10
21,393
4
0
2008-09-21T06:27:11.910000
2008-09-21T06:56:25.913000
110,430
110,461
How many unit tests should I write per function/method?
Do you write one test per function/method, with multiple checks in the test, or a test for each check?
One test per check and super descriptive names, per instance: @Test public void userCannotVoteDownWhenScoreIsLessThanOneHundred() {... } Both only one assertion and using good names gives me a better report when a test fails. They scream to me: "You broke THAT rule!".
How many unit tests should I write per function/method? Do you write one test per function/method, with multiple checks in the test, or a test for each check?
TITLE: How many unit tests should I write per function/method? QUESTION: Do you write one test per function/method, with multiple checks in the test, or a test for each check? ANSWER: One test per check and super descriptive names, per instance: @Test public void userCannotVoteDownWhenScoreIsLessThanOneHundred() {......
[ "unit-testing" ]
33
45
21,269
12
0
2008-09-21T06:58:48.467000
2008-09-21T07:16:07.520000