instruction
stringlengths
0
30k
Never used Mediawiki but that sort of problem in my experience is indicative of a php error that occurred but was suppressed either with the @ operator or because php error output to screen is turned off. I hate to resort to this debugging method but when absolutely and utterly frustrated in php I will just start putting echo statements every few lines (always with a marker so I remember to remove them later), to figure out exactly where the error is coming from. Eventually you'll get to the bottom of the rabbit hole and figure out exactly what the problematic line of code is.
In the Rails world, there's the concept of migrations, scripts in which changes to the database are made in Ruby rather than a database-specific flavour of SQL. Your Ruby migration code ends up being converted into the DDL specific to your current database; this makes switching database platforms very easy. For every change you make to the database, you write a new migration. Migrations typically have two methods: an "up" method in which the changes are applied and a "down" method in which the changes are undone. A single command brings the database up to date, and can also be used to bring the database to a specific version of the schema. In Rails, migrations are kept in their own directory in the project directory and get checked into version control just like any other project code. [This Oracle guide to Rails migrations][1] covers migrations quite well. Developers using other languages have looked at migrations and have implemented their own language-specific versions. I know of **[Ruckusing][2]**, a PHP migrations system that is modelled after Rails' migrations; it might be what you're looking for. [1]: http://www.oracle.com/technology/pub/articles/kern-rails-migrations.html "Oracle guide to Ruby on Rails migrations" [2]: http://code.google.com/p/ruckusing/ "Ruckusing"
If you are using C#, have a look at Subsonic, a very useful ORM tool, but is also generates sql script to recreated your scheme and\or data. These scripts can then be put into source control. [http://subsonicproject.com/][1] [1]: http://subsonicproject.com/
If you are quite happy with MSBuild, then I would stick with MSBuild. This may be one of those cases where the tool you learn first is the one you will prefer. I started with NAnt and can't quite get used to MSBuild. I'm sure they will both be around for quite some time. There are some fundamental differences between the two, probably best highlighted by [this conversation between some NAnt fans and a Microsoftie][1]. Interestingly, [Jeremy Miller][2] asked the exact opposite question [on his blog][3] last year. [1]: http://forums.msdn.microsoft.com/en-US/msbuild/thread/994761a3-ea9d-40c7-8d4f-4c208b2023f6/ [2]: http://codebetter.com/blogs/jeremy.miller/default.aspx [3]: http://codebetter.com/blogs/jeremy.miller/archive/2007/09/20/is-there-a-good-reason-to-switch-to-msbuild.aspx
**By default, always just create new folder within the same project** - You will get single assembly (without additional ILMerge gymnastic) - Easier to obfuscate (because you will have less public types and methods, ideally none at all) Separating your source code into multiple projects makes only sense if you... - Have some portions of the source code that are part of the project but not deployable by default or at all (unit tests, extra plugins etc.) - More developers involved and you want to treat their work as consumable black box. - If you can clearly separate your project into isolated layers/modules and you want to make sure that they can't consume eachothers **internal** members.
By default, always just create new folder within the same project - You will get single assembly (without additional ILMerge gymnastic) - Easier to obfuscate (because you will have less public types and methods, ideally none at all) Separating your source code into multiple projects makes only sense if you... - Have some portions of the source code that are part of the project but not deployable by default or at all (unit tests, extra plugins etc.) - More developers involved and you want to treat their work as consumable black box. - If you can clearly separate your project into isolated layers/modules and you want to make sure that they can't consume eachothers **internal** members. If you think that some portion of your source code would be reusable, still don't create it as a new project. Just wait until you will really need to reuse it in another solution and isolate it out of original project as needed. Programming is not a lego, reusing is usually very difficult and usually won't happen as planned.
Bytecode creates an extra level of indirection. The advantages of this extra level of indirection are: - Platform independence - Can create any number of programming languages (syntax) and have them compile down to the same bytecode. - Could easily create cross language converters - x86, x64, and IA64 no longer need to be compiled as seperate binaries. Only the proper virtual machine needs to be installed. - Each OS simply needs to create a virtual machine and it will have support for the same program. - Just in time compilation allows you to update a program just by replacing a single patched source file. (Very beneficial for web pages) Some of the disadvantages: - Performance - Easier to decompile
Configure static routes on Windows
|windows|networking|
There is a "netsh" and a "route" command on Windows. From their help text it looks like both can be used to configure static routes. When should you use one and not the other? Is IPv6 a distinguishing factor here?
The performance of essentially any program will improve if it is compiled, executed with profiling, and the results fed back into the compiler for a second pass. The code paths which are actually used will be more aggressively optimized, loops unrolled to exactly the right degree, and the hot instruction paths arranged to maximize I$ hits. All good stuff, yet it is almost never done because it is annoying to go through so many steps to build a binary. This is the advantage of running the bytecode for a while before compiling it to native code: profiling information is automatically available. The result after Just-In-Time compilation is highly optimized native code for the specific data the program is processing. Being able to run the bytecode also enables more aggressive native optimization than a static compiler could safely use. For example if one of the arguments to a function is noted to always be NULL, all handling for that argument can simply be omitted from the native code. There will be a brief validity check of the arguments in the function prologue, if that argument is not NULL the VM aborts back to the bytecode and starts profiling again.
Here: http://slashdot.org/developers/02/01/31/013247.shtml Go see what the geeks of Slashdot have to say about it! Little dated, but very good comments!
A magic number is a direct usage of a number in the code. public class Foo { public void setPassword(String password) { // don't do this if (password.length() > 7) { throw new InvalidArgumentException("password"); } } This should be refactored to: public class Foo { public static final MAX_PASSWORD_SIZE = 7; public void setPassword(String password) { if (password.length() > MAX_PASSWORD_SIZE) { throw new InvalidArgumentException("password"); } } It improves readability of the code and it's easier to maintain. Imagine the case where I set the size of the password field in the GUI. If I use a magic number, whenever the max size changes, I have to change in to code locations. If I forget one, this will lead to inconsistencies. The JDK is full of examples like in Integer, Character and Math classes. PS.: Static analysis tools like FindBugs and PMD detects the use of magic numbers in your code and suggests the refactoring.
Does anyone know if you can and how to start off a scheduled Windows task on a Remote Server from within a SQL Server Integration Services (SSIS) package? Cheers Nigel
It should be possible as the Task Scheduler has a scriptable [COM API][1] that can be used for interactoing with tasks. You could therefore either create a custom task that uses COM interop to call the Task Scheduler API, or it'd probably be quicker to use an Active X Script task to do your dirty work. [1]: http://msdn.microsoft.com/en-us/library/aa383614%28VS.85%29.aspx
It should be possible as the Task Scheduler has a scriptable [COM API][1] that can be used for interacting with tasks. You could therefore either create a custom task that uses COM interop to call the Task Scheduler API, or it'd probably be quicker to use an Active X Script task to do your dirty work. [1]: http://msdn.microsoft.com/en-us/library/aa383614%28VS.85%29.aspx
How to do crossdomain calls from Silverlight?
|silverlight|
What's needed to succesfully make a crossdomain call from Silverlight?
|web-services|silverlight|
Integrating InstantRails with Aptana or any other IDE
|ruby|ruby-on-rails|ide|aptana|radrails|
So I've been using InstantRails to check out Ruby on rails. I've been using Notepad++ for the editing. Now I don't want to install Ruby or Rails on my machine. Is there any walk through/tutorial on how to integrate Radrails or Netbeans with InstantRails?
Don't make it a religion or faith discussion. Those are hard to win (and is not what you want anyway) Don't frame it the way you just did in your question. The issue is not getting anyone to agree that this way or that way is the general way they should work. You should talk about how each one needs to think in order to make the right choice at any given time. give an example for when to use dataSet, and when not to. I had developers using dataTables to store data they fetched from the database and then have business logic code using that dataTable... And I showed them how I reduced the time to load a page from taking 7 seconds of 100% CPU (on the web server) to not being able to see the CPU line move at all.. by changing the memory object from dataTable to Hash table. So take an example or case that you thing is better implemented differently, and win that battle. Don't fight the a high level war...
It may be complete overkill for what you're attempting, but have a look at [eAccelerator](http://eaccelerator.net/) or [memcache](http://www.danga.com/memcached/). If you have queries that will change regularly and queries that won't, you may not want all of your db queries cached for the same length of time by mysql. Caching engines like the above allow you to decide, on a query-by-query basis, how long the data should be cached for. So say you've data in your header that will change infrequently, you can check if it's currently in the cache - if so, return it, otherwise do the query, and put it into cache with a lifetime of N, so for the next N seconds every page load will pull the data from cache without going near MySQL. You're then free to pull your other data "live" from the db as and when required, by-passing the cache.
Save yourself problems and use stored procedures with prepared statements or parameterized queries. Stored procedures are good practice anyway, as they act like an interface to the database, so you can change what happens behind the scenes (inside the stored proc) but the signature remains the same. The prepared statements help take care of injection protection.
The purpose of an interface is to define an abstract pattern that at type must implement. It would be better implement as: public interface ISomething public class Something1 : ISomething public class Something2 : ISomething You do not gain anything in the form of code reusability or scalable design by creating multiple versions of the same interface.
It may seem weird, but I got started writing code by automating the tasks and data analysis at my former job. This was accomplished by recording then studying the code an Excel macro generated. Of course this approach assumes you can learn via VB.
I don't know why people downvote your post. I think that good naming guidelines are **very** important. If you need to maintain compatibility with prev. version of the same interface consider using inheritance. If you need to introduce new version of interface consider following rule: > Try to add meaningful suffix to you > interface. If it's not possible to > create concise name, consider adding > version number.
Check out: http://bobpowell.net/onebit.htm You need this conversion as CCITT3 and CCITT4 don't support color (if I remember right).
Are we talking about something like this: JavaScript: <body> ... ... <script type="text/javascript"> <!-- document.write("Hello World!") //--> </script> <noscript>Your browser does not support JavaScript!</noscript> ... ... </body>
I would create a Windows Service (a visual studio 2005 project type) that handles the OnSessionChange event as shown below: protected override void OnSessionChange(SessionChangeDescription changeDescription) { if (changeDescription.Reason == SessionChangeReason.SessionLock) { //I left my desk } else if (changeDescription.Reason == SessionChangeReason.SessionUnlock) { //I returned to my desk } } What and how you log the activity at that point is up to you, but a Windows Service provides quick and easy access to windows events like startup, shutdown, login/out, along with the lock and unlock events.
Linker order - GCC
|c++|gcc|linker|
Why does the order in which libraries are linked sometimes cause errors?
You need to put from project import Project in `controllers/__init__.py`. Note that when [Absolute imports][1] become the default (Python 2.7?), you will need to add a dot before the module name to import from within the current package, i.e., from .project import Project [1]: http://docs.python.org/whatsnew/pep-328.html
The worksheet formula, =CELL("color",D3) returns 1 if the cell is formatted with colour for negative values (else returns 0). You can solve this with a bit of VBA. Insert this into a VBA code module: Function CellColor(xlRange As Excel.Range) CellColor = xlRange.Cells(1, 1).Interior.ColorIndex End Function Then use the function =CellColor(D3) to display the colorIndex of D3
How do I size a UITextView to it's content?
|iphone|cocoa|
Is there a good way to adjust the size of a UITextView to conform to it's content? Say for instance I have a UITextView that contains one line of text: "Hello world" I then add another line of text: "Goodbye world" Is there a good way in Cocoa Touch to get the rect that will hold all of the lines in the text view so that I can adjust the parent view accordingly? As another example, look at the Notes field for events in the Calendar application--note how the cell (and the UITextView it contains) expands to hold all lines of text in the notes string.
Can I prevent user pasting Javascript into Design Mode IFrame?
|javascript|iframe|
I'm building a webapp that contains an IFrame in design mode so my user's can "tart" their content up and paste in content to be displayed on their page. Like the WYSIWYG editor on most blog engines or forums. I'm trying to think of all potential security holes I need to plug, one of which is a user pasting in Javascript: &lt;script type="text/javascript"&gt; // Do some nasty stuff &lt;/script&gt; Now I know I can strip this out at the server end, before saving it and/or serving it back, but I'm worried about the possibility of someone being able to paste some script in and run it there and then, without even sending it back to the server for processing. Am I worrying over nothing? Any advice would be great, couldn't find much searching Google. Anthony
I like [ProFont TT >tweaked<][1] It's clean and there is a clear difference between 1, l and I and 0 and O.It works best at 9pt. It doesn't scale up very well. ![ProFont Windows 9pt][2] [1]: http://www.tobias-jung.de/seekingprofont/ [2]: http://farm3.static.flickr.com/2195/2840832152_af1d5cff6a.jpg?v=0
Mediawiki custom tag Stops page parsing.
|php|mediawiki|
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I will post my code below, but the problem is after it hits the first custom tag in the page, it calls it, and prints the response, but does not get anything that comes after it in the wikitext. It seems it just stops parsing the page. Any Ideas? <pre><code>if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { $wgHooks['ParserFirstCallInit'][] = 'tagregister'; } else { // Otherwise do things the old fashioned way $wgExtensionFunctions[] = 'tagregister'; } function tagregister(){ global $wgParser; $wgParser->setHook('tag1','tag1func'); $wgParser->setHook('tag2','tag2func'); return true; } function tag1func($input,$params) { return "It called me"; } function tag2func($input,$params) { return "It called me -- 2"; }</code></pre>
By default, **always just create new folder** within the same project - You will get single assembly (without additional ILMerge gymnastic) - Easier to obfuscate (because you will have less public types and methods, ideally none at all) Separating your source code into multiple projects makes only sense if you... - Have some portions of the source code that are part of the project but not deployable by default or at all (unit tests, extra plugins etc.) - More developers involved and you want to treat their work as consumable black box. (not very recommended) - If you can clearly separate your project into isolated layers/modules and you want to make sure that they can't cross-consume **internal** members. (also not recommended because you will need to decide which aspect is the most important) If you think that some portions of your source code could be reusable, still don't create it as a new project. Just wait until you will really want to reuse it in another solution and isolate it out of original project as needed. Programming is not a lego, reusing is usually very difficult and often won't happen as planned.
@John Downey: ["Let's Build a Compiler"](http://compilers.iecc.com/crenshaw/) is awesome, but it's a bit outdated. (I'm not saying it makes it even a little bit less valid)
How do I calculate these statistics?
|statistics|
I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called SPSS. Part of the output that they care about looks like this: ![Part of the SPSS output](http://img204.imageshack.us/img204/9596/spssfg1.png) They're really only concerned about the 'F' and 'Sig.' values. My problem is that I have no background in stats, and I can't figure out what the tests are called, or how to calculate them. I thought the 'F' value might be the result of the [F-test](http://en.wikipedia.org/wiki/F-test#Table_on_F-test), but after following the steps given on Wikipedia, I got a result that was different from what SPSS gives.
I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called [SPSS](http://en.wikipedia.org/wiki/Spss). Part of the output that they care about looks like this: ![Part of the SPSS output](http://img204.imageshack.us/img204/9596/spssfg1.png) They're really only concerned about the 'F' and 'Sig.' values. My problem is that I have no background in stats, and I can't figure out what the tests are called, or how to calculate them. I thought the 'F' value might be the result of the [F-test](http://en.wikipedia.org/wiki/F-test#Table_on_F-test), but after following the steps given on Wikipedia, I got a result that was different from what SPSS gives.
How can I modify .xfdl files?
|xfdl|language-agnostic|
The .XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications. I know how to view XFDL files using a file viewer I found <a href = "http://www.e-publishing.af.mil/viewerdownload.asp">here</a>. I'd like, however, to modify these files on the fly. Any suggestions?
A magic number is a direct usage of a number in the code. public class Foo { public void setPassword(String password) { // don't do this if (password.length() > 7) { throw new InvalidArgumentException("password"); } } This should be refactored to: public class Foo { public static final MAX_PASSWORD_SIZE = 7; public void setPassword(String password) { if (password.length() > MAX_PASSWORD_SIZE) { throw new InvalidArgumentException("password"); } } It improves readability of the code and it's easier to maintain. Imagine the case where I set the size of the password field in the GUI. If I use a magic number, whenever the max size changes, I have to change in two code locations. If I forget one, this will lead to inconsistencies. The JDK is full of examples like in Integer, Character and Math classes. PS.: Static analysis tools like FindBugs and PMD detects the use of magic numbers in your code and suggests the refactoring.
it looks like it's answered in this post: [http://forums.mysql.com/read.php?52,198596,198717#msg-198717][1] With mysqli PHP API: Assume sproc myproc( IN i int, OUT j int ): $mysqli = new mysqli( "HOST", "USR", "PWD", "DBNAME" ); $ivalue=1; $res = $mysqli->multi_query( "CALL myproc($ivalue,@x);SELECT @x" ); if( $res ) { $results = 0; do { if ($result = $mysqli->store_result()) { printf( "<b>Result #%u</b>:<br/>", ++$results ); while( $row = $result->fetch_row() ) { foreach( $row as $cell ) echo $cell, "&nbsp;"; } $result->close(); if( $mysqli->more_results() ) echo "<br/>"; } } while( $mysqli->next_result() ); } $mysqli->close(); [1]: http://forums.mysql.com/read.php?52,198596,198717#msg-198717
Returning from a finally block in Java
|java|
I was surprised recently to find that it's possible to have a return statement in a finally block in Java. It seems like lots of people think it's a bad thing to do as described in '[Don't return in a finally clause][1]'. Scratching a little deaper, I also found '[Java's return doesn't always][2]' which shows some pretty horrible examples of other types of flow control in finally blocks. So, my question is, can anyone give me an example where a return statement (or other flow control) in a finally block produces better / more readable code? [1]: http://weblogs.java.net/blog/staufferjames/archive/2007/06/_dont_return_in.html [2]: http://www.cs.arizona.edu/projects/sumatra/hallofshame/
|java|exception|
Furthermore if you need to look at the .NET/unmanaged stack just donwload [Process Explorer][1] and look at your w3wp.exe processes to examine memory and other stats without having to do a remote/local debugging (just look at the .NET Tab on the properties of the process). It will show all the .NET performance counters for that particular process. Awesome tool! [1]: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
`route` is a very old and basic tool for displaying and modifying the entries in the local IP routing table while `netsh` is the newer, more robust command-line **scripting utility** that allows you to, either locally or **remotely**, manipulate the network configuration. `netsh` has a zillion more features than route; it can even save your current settings as a script that another instance of netsh can parse. Check out [Using `netsh`][1] to see the giant feature set and compare it to how very basic and simple `routes` is. [1]: http://technet.microsoft.com/en-us/library/bb490939.aspx
Often you use constraints in a database to ensure data to be "unique" in the data-based sense. Regarding "isomorphisms" I think you are on your own, ie writing the code your self. If in the database you could use a trigger.
I believe it's not possible to keep xml comments in sync with autogenerated code automatically. However, xml comments can leave in separate file (just set "XML documentation file" option on "Project properties"->"Build" tab). You can create initial version of XML documentation file and update in manually if necessary
Queue alternatives to MSMQ on Windows?
|.net|soa|messaging|msmq|
If you want to use a queuing product for durable messaging under Windows, running .NET 2.0 and above, which alternatives to MSMQ exist today? I know of ActiveMQ (http://activemq.apache.org/), and I've seen references to WSMQ (pointing to http://wsmq.net), but the site seems to be down. Are there any other alternatives?
Take a look at this - that might explain it: [http://weblogs.asp.net/owscott/archive/2006/02/21/ASP.NET-v2.0-_2D00_-AppDomain-recycles_2C00_-more-common-than-before.aspx#440333][1] [1]: http://weblogs.asp.net/owscott/archive/2006/02/21/ASP.NET-v2.0-_2D00_-AppDomain-recycles_2C00_-more-common-than-before.aspx#440333 In general. What is called "first hit" on an ASP.NET Website is usually taking longer time, due to compilation, and creation of an AppDomain. Whenever you deploy a site - make sure to use the "Publish Website" function in Visual Studio, to pre-compile your website. Then the "first hit" penalty is reduced. And remember to set the configuration to Release, and not Debug!
What abour SQL 2005's [service broker][1]? [1]: http://msdn.microsoft.com/en-us/library/ms345108.aspx
The earlier you can stop people, the easier it'll be in the long run! Not being too familiar with your db schema or data entry form, I'd suggest a route something like the following: * have distinct fields in your db for each address "part", e.g. street, city, postal code, Länder, etc. * have your data entry form broken down similarly, e.g. street, city, etc The reasoning behind the above is that each part will likely have it's own particular "rules" for checking slightly-changed addressed, ("Quellenstrasse"->"Quellenstr.", "66/11"->"66a-11" above) so your validation code can check if the values as presented for each field exist in their respective db field. If not, you can have a class that applies the transformation rules for each given field (e.g. "strasse" stemmed to "str") and checks again for duplicates. Obviously the above method has it's drawbacks: * it can be slow, depending on your data set, leaving the user waiting * users may try to get around it by putting address "Parts" in the wrong fields (appending post code to city, etc). but from experience we've found that introducing even simple checking like the above will prevent a large percentage of users from entering pre-existing addresses. Once you've the basic checking in place, you can look at optimising the db accesses required, refining the rules, etc to meet your particular schema. You might also take a look at [MySQL's match() function](http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html#function_match) for working out similar text.
|php|mediawiki|
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I will post my code below, but the problem is after it hits the first custom tag in the page, it calls it, and prints the response, but does not get anything that comes after it in the wikitext. It seems it just stops parsing the page. Any Ideas? <pre><code>if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { $wgHooks['ParserFirstCallInit'][] = 'tagregister'; } else { // Otherwise do things the old fashioned way $wgExtensionFunctions[] = 'tagregister'; } function tagregister(){ global $wgParser; $wgParser->setHook('tag1','tag1func'); $wgParser->setHook('tag2','tag2func'); return true; } function tag1func($input,$params) { return "It called me"; } function tag2func($input,$params) { return "It called me -- 2"; }</code></pre> Update: @George Mauer -- I have seen that as well, but this does not stop the page from rendering, just the Mediawiki engine from parsing the rest of the wikitext. Its as if hitting the custom function is signalling mediawiki that processing is done. I am in the process of diving into the rabbit hole but was hoping someone else has seen this behaviour.
As the previous poster mentioned, the transplant extension can be used for cherry-picking individual changes from one branch to another. If, however, you always want to pull *all* the latest changes, the `hg merge` command will get you there. The simplest case is when you're using clones to implement branching (since that's the use case Mercurial is designed around). Assuming you've turned on the built-in [fetch][1] extension in your `.hgrc` / `Mercurial.ini`: cd ~/src/development # hack hack hack hg commit -m "Made some changes" cd ../production hg fetch ../development If you're using local branches: hg update -C development # hack hack hack hg commit -m "Made some changes" hg update -C production hg merge development hg commit -m "Merged from development" [1]: http://www.selenic.com/mercurial/wiki/index.cgi/FetchExtension
multithreading in asp.net
|asp.net|multithreading|
What kind of multi-threading issues do you have to be careful for in asp.net?
Multithreading in asp.net
> ...I'm worried about the possibility of someone being able to paste some script in and run it there and then, without even sending it back to the server for processing. > > Am I worrying over nothing? Firefox has a plug-in called Greasemonkey that allows users to arbitrarily run JavaScript against any page that loads into their browser, and there is nothing you can do about it. Firebug allows you to modify web pages as well as run arbitrary JavaScript. AFAIK, you really only need to worry once it gets to your server, and then potentially hits other users.
How about this? You could expand this pattern to do "years" messages, and you could put in a check for "1 day" or "1 hour" so it wouldn't say "1 days ago"... I like the CASE statement in SQL. drop function dbo.time_diff_message GO create function dbo.time_diff_message ( @input_date datetime ) returns varchar(200) as begin declare @msg varchar(200) declare @hourdiff int set @hourdiff = datediff(hour, @input_date, getdate()) set @msg = case when @hourdiff < 0 then ' from now' else ' ago' end set @hourdiff = abs(@hourdiff) set @msg = case when @hourdiff > 24 then convert(varchar, @hourdiff/24) + ' days' + @msg else convert(varchar, @hourdiff) + ' hours' + @msg end return @msg end GO select dbo.time_diff_message('Dec 7 1941')
To what extent should a developer learn database?
|database|
Modern Databases systems today come with loads of feature. And you would agree with me that to learn one database you must unlearn the concepts you learned in another database. For e.g. each database would implement locking differently than other. So to carry the concepts of one database to another would be a recipe for failure. And there could be other examples where two database would perform very very differently. So while developing the database driven systems should the programmers need to know the database in detail so that they code for performance? I don't think it would be appropriate to have the DBA called for performance later as his job is to only maintain the database and help out the developer in case of emergency but not on a regular basis. What do you think should be the extent the developer needs to gain an insight into the database? Thanks.
I've just been recently turned on to MVC and Linq to Sql for Asp.Net. I'm still learning both, and I'm really enjoying them both. There are quite a few screen casts on <http://www.asp.net/learn/>.
I think a developer should have a fairly good grasp of how their database system works, not matter which one it is. When making design and architecture decisions, they need to understand the possible implications when it comes to the database.
I can share a SQL Server Reporting Services Data SOURCE... what about a Data SET?
|sql-server-reporting-ser|
I am developing a Reporting Services solution for a DOD website. Frequently I'll have a report and want to have as a parameter the Service (in addition to other similar mundane, but repetitive parameters like Fiscal Year, Data Effective Date, etc). Basically everything I've seen of SSRS 2005 says it can't be done... but I personally refuse to believe that MS would be so stupid/naive/short-sited to leave something like sharing datasets out of reporting entirely. Is there a clunky (or not so clunky way) to share datasets and still keep the reporting server happy? Will SSRS2008 do this?
|sql-server-reporting-ser|
I am developing a Reporting Services solution for a DOD website. Frequently I'll have a report and want to have as a parameter the Service (in addition to other similar mundane, but repetitive parameters like Fiscal Year, Data Effective Date, etc). Basically everything I've seen of SSRS 2005 says it can't be done... but I personally refuse to believe that MS would be so stupid/naive/short-sited to leave something like sharing datasets out of reporting entirely. Is there a clunky (or not so clunky way) to share datasets and still keep the reporting server happy? Will SSRS2008 do this? EDIT: I guess I worded that unclearly. I have a stack of reports. Since I'm in a DoD environment, one common parameter for these reports is Service (army, navy, etc. for those non US users). Since "Business rules" cause me to not be able to use stored procedures; is there a way I can make 1 dataset and link to it from the various reports? Will Reporting 2008 support something like this? I'm getting sick of re-typing the same query in a bunch of reports.
A quick answer: Use the Repository pattern (see Domain Driven Design by Evans) to fetch your entities. Each repository will cache the things it will hold, ideally by letting each instance of the repository access a singleton cache (each thread/request will instantiate a new repository but there can be only one cache). The above answer works on one machine only. To be able to use this on many machines, use memcached as your caching solution. Good luck!
You could use the [Google GeoCode API][1] Wich in fact gives results for both of your examples, just tried it. That way you get structured results that you can save in your database. If the lookup fails, ask the user to write the address in another way. [1]: http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct
> `return fabs(a - b) < EPSILON; This is fine if: - the order of magnitude of your inputs don't change much - very small numbers of opposite signs can be treated as equal But otherwise it'll lead you into trouble. Double precision numbers have a resolution of about 16 decimal places. If the two numbers you are comparing are larger in magnitude than EPSILON*1.0E16, then you might as well be saying: return a==b; I'll examine a different approach that assumes you need to worry about the first issue and assume the second is fine your application. A solution would be something like: #define VERYSMALL (1.0E-150) #define EPSILON (1.0E-8) bool AreSame(double a, double b) { double absDiff = fabs(a - b); if (absDiff < VERYSMALL) { return true; } double maxAbs = max(fabs(a) - fabs(b)); return (absDiff/maxAbs) < EPSILON; } This is expensive computationally, but it is sometimes what is called for. This is what we have to do at my company because we deal with an engineering library and inputs can vary by a few dozen orders of magnitude. Anyway, the point is this (and applies to practically every programming problem): Evaluate what your needs are, then come up with a solution to address your needs -- don't assume the easy answer will address your needs. If after your evaluation you find that `fabs(a-b) < EPSILON` will suffice, perfect -- use it! But be aware of its shortcomings and other possible solutions too.
Problems passing special chars with observe_field
|ruby-on-rails|ajax|
I am working on a rails project. Using the tag observe_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars. 1. ? => causes the variable not to be found in the params object 2. (pound) => causes an invalid authenticity error 3. % => stops the div from being updated 4. & => every thing after the & is no longer passed into the variable on the server. Is there a way to solve this?
I am working on a rails project. Using the tag observe_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars. 1. ? => causes the variable not to be found in the params object 2. (pound) => causes an invalid authenticity error 3. % => stops the div from being updated 4. & => every thing after the & is no longer passed into the variable on the server. Is there a way to solve this? --- code sample --- this is the view. ( 'postbody' is a text area) <%= observe_field 'postbody', :update => 'preview', :url => {:controller => 'blog', :action => 'textile_to_html'}, :frequency => 0.5, :with => 'postbody' -%> this is the controller that is called def textile_to_html text = params['postbody'] if text == nil then @textile_to_html = '<br/>never set' else r = RedCloth.new text @textile_to_html = r.to_html end render :layout => false end
The .XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications. I know how to view XFDL files using a file viewer I found <a href = "http://www.e-publishing.af.mil/viewerdownload.asp">here</a>. I'd like, however, to modify these files on the fly. Any suggestions? Is this even possible?
The .XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications. I know how to view XFDL files using a file viewer I found <a href = "http://www.e-publishing.af.mil/viewerdownload.asp">here</a>. I can also modify and save these files by doing File:Save/Save As. I'd like, however, to modify these files on the fly. Any suggestions? Is this even possible?