instruction stringlengths 0 30k ⌀ |
|---|
Is there a way to combine named scopes into a new named scope? |
@Justin:
2 + (2)
can be represented by two methods:
- you can add a PAREN node that just has a single value
- when building the tree, you can collapse to 2 + 2. This works in all the cases, since the parens only affect the order of evaluation and therefore the building of the tree.
|
@Justin:
Look at my note on representing the nodes. If you use that scheme, then
2 + (2)
can be represented as
.
/ \
2 ( )
|
2 |
parsing raw email in php |
|php|email| |
i'm looking for good/working/simple to use php code for parsing raw email into parts.
i've written a couple of brute force solutions, but everytime, one small change/header/space/something comes along and my whole parser fails and the project falls apart.
and before i get pointed at PEAR/PECL, i need actual code.... |
You could go out and buy a bunch of books and start reading them and quickly get overwhelmed in the seemingly massive learning curve it takes to go from nowhere, which is where it appears you are, to a rich internet entrepreneur, which is where you want to be.
Alternatively, and what I would suggest is, you could de... |
I know this is a bit tangential, but have you tried seeing if there are more indexes you can add?
I don't have a lot of DB background, but I am working with databases a lot recently, and I've been finding that a lot of the queries can be improved just by adding indexes.
We are using DB2, and there is a command ca... |
I've never used a public computer, but carry a keyboard and(/or, if you are good enough) just change the settings on the machine. |
I would say no. I have used both, and they are different for very good reason (warning, history lesson)
The Dvorak keyboard is optimal, the qwerty layout was designed so that the pegs on a typewrier would not collide (so letters that often come next to each other are split up)
Because these are so different, its ... |
How to remote shell scripts from ASP pages? |
|asp|vbscript|remote-scripting| |
I need to create and ASP page (not .NET, yes I know its ancient) should run remote shell scripts on a UNIX server and then capture the output into variables in VBScript within the page itself.
I ahve never done ASP or VBScipt before. I have tried to google this stuff, but all I find are references to remote server s... |
How to run remote shell scripts from ASP pages? |
I need to create and ASP page (not .NET, yes I know its ancient), which should run remote shell scripts on a UNIX server and then capture the output into variables in VBScript within the page itself.
I have never done ASP or VBScipt before. I have tried to google this stuff, but all I find are references to remote s... |
|asp|vbscript|remote-scripting|server-side-scripting| |
Thanks for the answers guys.
@Theo:
I tried the replace several different ways. For some reason it would never error, but never update the list.
@Matt:
I figured out a solution. The issue wasn't coming from what you suggested, but from how the delete works with Lists (at least how I have it in this instance).... |
Are you using ASP.NET Website or ASP.NET Web Project? The difference is significant enough to solve or promote this problem.
Websites, love to scan the file system and auto checkin.
Projects, checkin only what you tell them to.
Also Visual Source Safe is pretty out dated, most recent source control systems allo... |
You can use the [eval][1] command for this. I would recommend against this though, because there's a lot of pitfalls using this approach. Debugging is hard(er), it implies some security risks (bad content in the DB gets executed, uh oh).
See (blogpost by a random person) [Eval is Evil][2] for instance. Google for Ev... |
You can use the [eval][1] command for this. I would recommend against this though, because there's a lot of pitfalls using this approach. Debugging is hard(er), it implies some security risks (bad content in the DB gets executed, uh oh).
See (blogpost by a random person) [Eval is Evil][2] for instance. Google for Ev... |
IMO, there are more pitfalls in normal web forms scenarios than with just MVC. Viewstate and databinding can be tricky at times.
But for MVC, it's just plain simple form post/render things old-school way. Not that it is bad, it is just different, and cleaner too. |
Best way to sort an array in delphi |
|delphi|arrays|sorting| |
Say I have an array of records which I want to sort based on one of the fields in the record. What's the best way to achieve this?
TExample = record
SortOrder : integer;
SomethingElse : string;
end;
var SomeVar : array of TExample;
|
Excluding a folder from source control in an ASP.NET project? |
|asp.net|visual-sourcesafe| |
Right now I am working with an ASP.NET website that automatically generates images and stores them in a temporary folder. When working on my local system these go going into a temporary folder that gets picked up by Visual Source Safe which then wants to check them in. As such, I am wondering if there is a way to just ... |
Write migration scripts for all db changes and keep them in a repository. Enforce a policy of making all changes to the db only by running a script; that way there is a record of what has been done, and a way to revert it. Investigate whether there's a migrations framework available for your favorite language/db combin... |
I asked this one yesterday and got some nice responses:
http://stackoverflow.com/questions/77172/stored-proceduresdb-schema-in-source-control
|
It's implied by nsayer's answer, but it's worth noting that the OPs for(..) syntax will work when "someList" is _anything_ that implements java.lang.Iterable -- it doesn't have to be a list, or some collection from java.util. Even your own types, therefore, can be used with this syntax. |
There's ILMerge. [Link][1]
[1]: http://research.microsoft.com/~mbarnett/ILMerge.aspx |
Possibly silly questions, but just in case... have you refreshed the SP list? Have you checked for a stored procedure of that name under a different owner? If you created the stored procedure without specifying the owner then it could be in the list under your ownership (or not at all if the list is filtered to only "d... |
C# 3.0 in a Nutshell is a fantastic reference book with examples just big enought to grasp the concept without feeling bloated. |
There is [Mono][1] on linux, but in practice .Net is pretty much a Windows-only platform.
[1]: http://www.mono-project.com/Main_Page |
There is [Mono][1] which runs on Linux, Solaris and OS X. In practice .Net is still pretty much a Windows-only platform. It's not really in Microsoft's interests to push it to be WORA, on the contrary. Appearing to be cross-platform however is. A lot of people have been really paranoid about Mono on Linux. MS's suppose... |
You may not have permission to see all the objects in the database |
JConsole Config |
|jconsole| |
in JBoss' run.bat, add:
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9987 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
To start jconsole:
JDK/bin>jconsole localhost:9987 |
Using a state machine. It's fairly easy to do, and even works if the data stream is interrupted (you just have to keep the state and the partial result). You can also use a parser generator (if you're doing something more complex). |
I use Visual Studio 2008 Pro create Database projects (Other project types -> Database). We already use SVN as a code repository, so a project with a bunch of .sql files representing your stored procedures is just another thing to put in the repository - you can see diffs/history etc. This works the same with VSS or ... |
|ruby-on-rails|named-scope|dry| |
I have
class Foo < ActiveRecord::Base
named_scope :a, lambda { |a| :conditions => { :a => a } }
named_scope :b, lambda { |b| :conditions => { :b => b } }
end
I'd like
class Foo < ActiveRecord::Base
named_scope :ab, lambda { |a,b| :conditions => { :a => a, :b => b } }
end
... |
|ruby-on-rails|named-scope| |
Examine the [Debug.Write][1] method. It is marked with the
[Conditional("DEBUG")]
attribute.
The MSDN help for [ConditionalAttribute][2] states:
> Indicates to compilers that a method
> call or attribute should be ignored
> unless a specified **conditional
> compilation symbol is defined**.
... |
Use a command-line XSLT processor to parse the XML and generate CSV. Here's [an example][1], which for your case is the stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match=... |
Use a command-line XSLT processor such as [xsltproc][1], [saxon][2] or [xalan][3] to parse the XML and generate CSV. Here's [an example][4], which for your case is the stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:ou... |
SharePoint SPContext.List in a custom application page |
|sharepoint|applicationpage|spcontext| |
I have a custom SharePoint application page deployed to the _layouts folder. It's a custom "new form" for a custom content type. During my interactions with this page, I will need to add an item to my list. When the page first loads, I can use SPContext.Current.List to see the current list I'm working with. But aft... |
I'm not a Java programmer, but getting away from Java and just thinking in terms that are more language agnostic - a cleaner way to do it might be to use either constants or enumerated types. This should work in any langauge that supports multi-dimensional arrays.
If using named constants, where, for example:
... |
I'm not a Java programmer, but getting away from Java and just thinking in terms that are more language agnostic - a cleaner way to do it might be to use either constants or enumerated types. This should work in any langauge that supports multi-dimensional arrays.
If using named constants, where, for example:
... |
MySQL 5 does support [views][1], which may be helpful in this scenario. It sounds like you've already done a lot of optimizing, but if not you can use MySQL's [EXPLAIN][2] syntax to see what indexes are actually being used and what is slowing down your queries.
As far as going about normalizing data (whether you're... |
I know this might sound a little arcanine but why not just stat the directory that contains the database. |
Source: [http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1313431,00.html][1]
Works with SQL2000,2005,2008
USE master;
GO
IF OBJECT_ID('dbo.sp_SDS', 'P') IS NOT NULL
DROP PROCEDURE dbo.sp_SDS;
GO
CREATE PROCEDURE dbo.sp_SDS
@TargetDatabase sysname = NULL... |
You might also want to consider selecting into a temporary table and then performing queries on that temporary table. This would avoid the need to rejoin your tables for every single query you issue (assuming that you can use the temporary table for numerous queries, of course). This basically gives you denormalized ... |
Excluding a folder from source control in an ASP.NET website? |
|asp.net|visual-sourcesafe| |
Is there a class to generate a sample XML document from XSD schema in .NET |
|xml|xsd|.net| |
In Visual Studio you can create a template XML document from an existing schema. The new XML Schema Explorer (<http://msdn.microsoft.com/en-us/library/cc716766.aspx>) in VS2008 SP1 takes this a stage further and can create a sample XML document complete with data.
Is there a class library in .NET to do this automatica... |
|.net|xml|xsd| |
In Visual Studio you can create a template XML document from an existing schema. The new [XML Schema Explorer](http://msdn.microsoft.com/en-us/library/cc716766.aspx) in VS2008 SP1 takes this a stage further and can create a sample XML document complete with data.
Is there a class library in .NET to do this automatical... |
Two design approaches to consider
The [essence](http://www.hillside.net/plop/plop98/final_submissions/P10.pdf) pattern
The [fluent interface](http://java.dzone.com/news/factories-builders-and-fluent-) pattern |
Two design approaches to consider
The [essence](http://www.hillside.net/plop/plop98/final_submissions/P10.pdf) pattern
The [fluent interface](http://java.dzone.com/news/factories-builders-and-fluent-) pattern
These are both similar in intent, in that we slowly build up an intermediate object, and then create o... |
Turn viewstate off by default, it will be a night and day difference on even the most simple pages. |
The other major player would be DevExpress and their CodeRush and Refactor products. [Found here.][1]
[1]: http://www.devexpress.com/Products/Visual_Studio_Add-in/Refactoring/ |
1. [Script Combining in .net 3.5 SP1](http://weblogs.asp.net/scottgu/archive/2008/05/12/visual-studio-2008-and-net-framework-3-5-service-pack-1-beta.aspx)
2. [Best Practices for fast websites](http://developer.yahoo.com/performance/rules.html)
3. HTTP Compression (gzip)
4. Compress JS / CSS (different than http comp... |
1. [Script Combining in .net 3.5 SP1](http://weblogs.asp.net/scottgu/archive/2008/05/12/visual-studio-2008-and-net-framework-3-5-service-pack-1-beta.aspx)
2. [Best Practices for fast websites](http://developer.yahoo.com/performance/rules.html)
3. HTTP Compression (gzip)
4. Compress JS / CSS (different than http comp... |
I think you really need to be able to get some actual PerfMon data/telemetry from the app whilst running in production to be able to make an enlightened decision about what to optimise.
As a throw away tip I'd make sure your app is deployed as a *Release* build and set debug="false" in the '*compilation*' section o... |
If you are using Firefox to test your website, you might want to try a nifty Firefox extension from Yahoo! called [YSlow](https://addons.mozilla.org/en-US/firefox/addon/5369).
It analyzes your web pages and provides grades from A-F (A being the Best and F being the worst) for each of the best practices, for high pe... |
Aside from trying out Visual AssistX, the only other one I've tried is ReSharper (which I highly recommend). If you do decide to go for ReSharper, you'll likely notice that it's missing a spell checker for code though - however the [Agent Smith plugin][1] fixes that.
[1]: http://www.agentsmithplugin.com/ |
I use apache mod_proxy and mod_proxy_balancer. Works awesome running 5 domains a cluster of 4 web boxes. |
As others have mentioned, doing an if statement in two lines without braces can lead to confusion:
if (a == b)
DoSomething();
DoSomethingElse(); <-- outside if statement
so I place it on a single line if I can do so without hurting readability:
if (a == b) DoSomething();
and at all... |
you can also use the following code snipet
USE AdventureWorks2008;
GO
SELECT SprocName=name, create_date, modify_date
FROM sys.objects
WHERE type = 'P'
AND name = 'uspUpdateEmployeeHireInfo'
GO
|
you can also use the following code snipet
USE AdventureWorks2008;
GO
SELECT SprocName=name, create_date, modify_date
FROM sys.objects
WHERE type = 'P'
AND name = 'uspUpdateEmployeeHireInfo'
GO
|
Django has this built in. See <a href="http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites">the sites framework</a>. |
Django has this built in. See <a href="http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites">the sites framework</a>.
As a general technique, include a 'host' column in your database schema attached to the data you want to be host-specific, then include the `Host` HTTP header in the query when ... |
The problem with the Ole/Com Object Viewer packaged with Visual Studio and Windows SDKs is that it produces a broken .IDL out of the .DLL, which can't further be compiled by MIDL into a .H/.CPP pair.
Wine's own reimplementation of OleViewer is currently unstable and crashes when trying to use those libraries.
|
The easiest way to move a Database would be to use SQL Server Management Studio to Export the database to another server, or if that doesn't work, make a backup like other's had suggested and restore it elsewhere.
If you are looking for a way to dump the table structure to SQL as well as create insert scripts for th... |
Adding to the previous answers, it could also be under "System Stored Procedures", and if the name of the stored procedure begins with "sp_", it could also be in the master database. |
Maybe you can add an additional server/subdomain that provides the images without https? |
Look into scripting languages. I'd recommend Python or Perl. |
There is no such an option, as others pointed out, the only option is to restore from a backup.
When you are trying to restore a content database to a different box both should have the same set of updates installed, otherwise you might experience all kind of problems.
|
Check out the ILMerge tool found [here][1].
[1]: http://research.microsoft.com/~mbarnett/ILMerge.aspx |
I use CherryPy as my web server (which comes bundled with Turbogears), and I simply run multiple instances of the CherryPy web server on different ports bound to localhost. Then I configure Apache with mod_proxy and mod_rewrite to transparently forward requests to the proper port based on the HTTP request. |
Don't try to be as dynamic as PHP is. You could try to first **define** what you need.
interface Season
{
public string getDays();
}
interface User
{
public Season getWinter();
public Season getSpring();
public Season getSummer();
public Season g... |
Ok, it looks like there are a couple of issues here. As far as I can tell, there is no such thing as a "droppable" in mootools. This means your events like 'enter', 'leave' and 'drop' won't work. (These are events on the drag object)
If you change those names to events that elements in mootools have (as in, DOM even... |
Ok, it looks like there are a couple of issues here. As far as I can tell, there is no such thing as a "droppable" in mootools. This means your events like 'enter', 'leave' and 'drop' won't work. (These are events on the drag object)
If you change those names to events that elements in mootools have (as in, DOM even... |
If you just want the name attributes of any element, here is a quick but incomplete solution.
(Your example text is in the file *example*)
> grep "name" example | cut -d"\"" -f2,2
> | xargs -I{} echo "{}," |
I have switched between several IDEs and the one that I believe has the best GUI builder in terms of use and performance would have to be Netbeans. |
CPU utilization by database? |
|mssql|sql-server| |
*I've always thought the answer to this was "no", but let's give CrackOverflow a shot...*
Is it possible to get a breakdown of CPU utilization **by database**? I'm ideally looking for a task manager type interface for SQL server, but instead of looking at the CPU utilization of each PID (like taskmgr) or each SPID (... |
|mssql|sql-server|monitoring| |
|sql-server|monitoring| |
Why does SQL Server work faster when you index a table after filling it? |
|sql-server|tsql| |
I have a sproc that puts 750K records into a temp table through a query as one of its first actions. If I create indexes on the temp table before filling it, the item takes about twice as long to run compared to when I index after filling the table. (The index is an integer in a single column, the table being indexed... |
|sql-server|performance|indexing|mssql| |