instruction stringlengths 0 30k ⌀ |
|---|
How about:
tagreg=/\[(.?)?(b|u|i|s|center|code)\]/gi;
"[b][i]helloworld[/i][/b]".replace(tagreg, "<$1$2>");
"[b]helloworld[/b]".replace(tagreg, "<$1$2>");
For me the above produces:
<b><i>helloworld</i></b>
<b>helloworld</b>
This appears to do what you want, and has the advantage ... |
If you already have a data API that's exposed as sprocs, you'd need to justify a major architectural overhaul to go to ORM.
For a green-fields build, I'd evaluate several things:
1. If there's a dedicated DBA on the team, I'd lean to sprocs
2. If there's more than one application touching the same DB I'd lean ... |
If you're looking for something as nice as Python's x[-1] notation, I think you're out of luck. The standard idiom is
x[length(x)]
but it's easy enough to write a function to do this:
last <- function(x) { return( x[length(x)] ) }
This missing feature in R annoys me too! |
The browser prints your pages. If you need to tweak the page so it looks better on the printer, use CSS @media selectors. |
I would guess that fCSQLDate function is culture-specific - i.e. it will parse the date based on the user's locale settings. That's why you see the problem.
Anyway, using queries with concatenated strings is always a bad idea (injection attacks). You are better off if you use parameters. |
Unfortunately, I don't believe there is. The WAL logging operates on the page level, which is much lower than the table level and doesn't even know which page holds data from which table. In fact, the WAL files don't even know which pages belong to which *database*.
You might consider moving your high activity table... |
Beware of any file based database, they are all likely to have the same problems. Your situation really calls for a Client/Server solution.
From SQLite FAQ
> A good rule of thumb is that you
> should avoid using SQLite in
> situations where the same database
> will be accessed simultaneously from
> many com... |
> So, my question is, is there a way to have some kind of process explorer, or task manager sort of thing for Firefox 3?
Because of the way Firefox is built this is not possible at the moment. But the new Internet Explorer 8 Beta 2 and the just announced Google Chrome browser are heading in that direction, so I supp... |
Another way to sanitize the input is to make sure that only allowed characters (no "/", ".", ":", ...) are in it. However don't use a blacklist for *bad* characters, but a whitelist for allowed characters:
$page = preg_replace('[^a-zA-Z0-9]', '', $page);
... followed by a file_exists.
That way you can make... |
I don't think this is best practice.
The simple truth is that an interface is nothing more than a contract that a method is implemented. It is *not* a contract on either a.) how the method should be implemented and b.) what that method should be doing exactly (it only guarantees the return type), the two reasons th... |
the question assumes the context of the answer, and thus creates a false dilemma
the 'spreadsheet conundrum' is a false dichotomy in this example: rows and columns are the presentation layer, not necessarily the data layer. The comments below tell me i misunderstood the analogy, but i don't think so - saying 'should... |
Couldn't you use [Polymorphic Associations][1]?
I'm about to hit this in my app with attachment\_fu, so I'm not exactly sure on attachment\_fu, but for the old school [File Column][2] plugin, I would use Polymorphic Associations.
My "file" model would be:
class FileUpload < ActiveRecord::Base
... |
http://blogs.msdn.com/jkowalski/archive/2008/09/09/persistence-ignorance-poco-adapter-for-entity-framework-v1.aspx
The main problem is that the entity framework was not designed with persistence ignorance in mind. I would honestly look at using something other than entity framework.
|
OMG - it turns out that the cause was a total WTF?
all our tile responses were being served by a homegrown servlet that was ignoring the
`<%@ page contentType="text/html; charset=UTF-8" %>`
directive (and who know what else).
`TilesDispatchExtensionServlet` : bloody architecture astronauts, i shake my fist... |
I don't think this is possible just using the color setting in SpriteBatch, so I'm trying to work out a simple shader that would take every pixel and make it white, while respecting the alpha value of the pixel.
The answer Joel Martinez gave looks right, but how do I incorporate that when I draw the sprite with Spri... |
$sTime = '04:20:00';
$oTime = new DateTime($sTime);
echo $oTime->format('G:i:s') . '<br />';
// OR
echo $oTime->format('G') . ':' . $oTime->format('i') . ':' . $oTime->format('s') . '<br />';
// OR
$aParsed = date_parse($sTime);
echo $aParsed['hour'] . ':' . $aParsed['minute'] . ':' . $aParsed['second'] ... |
Why bother with regex or explodes when php handles time just fine?
$sTime = '04:20:00';
$oTime = new DateTime($sTime);
$aOutput = array();
if ($oTime->format('G') > 0) {
$aOutput[] = $oTime->format('G');
}
$aOutput[] = $oTime->format('i');
$aOutput[] = $oTime->format('s');
echo implode(':', $aO... |
Why bother with regex or explodes when php handles time just fine?
$sTime = '04:20:00';
$oTime = new DateTime($sTime);
$aOutput = array();
if ($oTime->format('G') > 0) {
$aOutput[] = $oTime->format('G') . ' hours';
}
$aOutput[] = $oTime->format('i') . ' minutes';
$aOutput[] = $oTime->format('s') ... |
I don't know why you need NOT to use a JDBC driver, but there's another possible "solution" depending on your software requirements. In FF3, type in the address bar about:config
Alter the value of property: browser.bookmarks.autoExportHTML to true.
This will export your bookmarks in an HTML whenever you close FF.... |
instead of trying to fake transactions with table locks, why not switch to innodb tables where you get actual transactions? just make sure to set the default transaction isolation level to REPEATABLE READ. |
If the variable is already on the stack, you can go ahead and just emit the method call.
If you are looking at the debug version of the outputted IL, it creates temporary variables to aid in debugging. Switch to release mode to see more optimized IL. |
If the variable is already on the stack, you can go ahead and just emit the method call.
It seems that the constructor doesn't push the variable on the stack in a typed form. After digging into the IL a bit, it appears there are two ways of using the variable after constructing it.
You can load the variable ... |
You could look into this:
http://www.codeproject.com/KB/showcase/pdfrasterizer.aspx
It's not completely free, but it looks very nice.
Alex |
It depends how you define "serious development". One big thing missing from the express (and even standard) editions is the lack of support for mobile development. You also miss the convenience of grouping different project types in a solution.
I think you also miss some of the project types (windows services, Sql... |
And a quick answer to part 2 of my own question...
I would imagine I could rename the directory, delete the file, and rename the directory back to it's original again.
... I would still be interested to see what other people come up with.
JB |
The *single best* regex that rejects all input is due to @aku above
$.^
This is as close to a flat contradiction as you can get in a plain (i.e., no lookahead or back-references) regex pattern: "a string with a character after its end and before its beginning."
It's possible that some regex implementations... |
The *best* standard regexs (i.e., no lookahead or back-references) that reject all inputs are (after @aku above)
.^
and
$.
These are flat contradictions: "a string with a character before its beginning" and "a string with a character after its end."
It's possible that some regex implementations ... |
The *best* standard regexs (i.e., no lookahead or back-references) that reject all inputs are (after @aku above)
.^
and
$.
These are flat contradictions: "a string with a character before its beginning" and "a string with a character after its end."
NOTE: It's possible that some regex implementa... |
I haven't afforded the full version of VS2008 at home yet so I have Express and use it for some intermediate application development (no web stuff). I find it quite good enough, it's got most of the stuff I use. I tried SharpDevelop but it wouldn't allow more than one start up project so I ditched it for Express.
Mo... |
Your regex is badly chosen on several points:
1. Instead of matching the slashes, you match any character at all (presumably because you don’t know how to match slashes when you’re also using them as delimiters).
Within a slash-delimited regex literal, `//`, you can match slashes simply by protecting them with... |
I assume that you could configure your Windows guest to use the host as its default gateway, and set up NAT via the wireless interface on the host. So the signal flow would look like this:
1. Windows software opens connections to a host on the internets.
2. Windows routes the packet via the default gateway, i.e. th... |
Take a look at Dojo/Dijit/Dojox ([http://dojotoolkit.org][1]). They have a lot of cool special effects, and a lot more that will come in handy to anyone working with Javascript.
They also keep docs and related articles at [http://dojocampus.org/][2]
[1]: http://dojotoolkit.org
[2]: http://dojocampus.org/ |
SQL Server Express 64 bit prerequisite to include in setup deployment project. |
|sql-server| |
Where can I obtain the SQL Server Express 64 bit prerequisite to include in a Visual Studio 2008 setup deployment project. The prerequisite that comes with Visual Studio 2008 is 32 bit only.
|
It depends on the scrollbars you want to show, and if `WordWrap` is true or false. Do you want to have both scrollbars hidden initially, and displayed only when needed? |
I also made some experiments, and found that the vertical bar will always show if you enable it, and the horizontal bar always shows as long as it's enabled and `WordWrap == false`.
I think you're not going to get exactly what you want here. However, I believe that users would like better Windows' default behavior t... |
Are you using Flex 3? If so, you can set a breakpoint when the webservice is executed and actually step through the Flex framework as it encodes your request. Look in mx.rpc.soap.SoapEncoder and you'll be able to see exactly what is going to be sent over the wire. |
Found a [nice article that covers this here][1]:
> Most applications do not require administrator privileges at run time. If your application doesn't maintain cross-session state while it executes and doesn't do something like modifying the local security policy, it should be just fine running with a standard-user t... |
Another possible solution (assuming you actually need reliable address data and you're not just using addresses as a way to prevent duplicate accounts) is to use a third-party web service to standardize the addresses provided by your users.
It works this way -- your system accepts a user's address via an online for... |
You can also use a component like activePDF's [DocConverter][1] to convert a **lot** formats to PDF.
[1]: http://activepdf.com/products/serverproducts/docconverter/index.cfm |
I think what you mean is you want to use PHP as your templating language and structs as your middleware (actions etc).
I would imaging the answer would be no, not without some kind of bridge between the structs session and the PHP.
If you say change x to 3 in java in a structs action, you couldn't just go <?ph... |
What SPN do I need to set for a net.tcp service? |
|spns|wcf|security| |
I have a wcf application hosted in a windows service running a local windows account. Do I need to set an SPN for this account? If so, what's the protocol the SPN needs to be set under? I know how to do this for services over HTTP, but have never done it for net.tcp. |
|security|wcf|spn| |
For testing/development purposes, you can download Oracle JRockit Mission Control for free from [this][1] site. (Requires Login, but accounts can be set up with any email adress)
Docs [Here][2]. It will allow you to find hotspots, memory leaks and much more.
[1]: http://www.oracle.com/technology/software/prod... |
Strategy for Fixing Layout Bugs in IE6? |
|internet-explorer-6|principles|strategies| |
Generally, what's the best way to tackle a layout bug in IE6? What are the most common bugs or problems that one should look for when trying to figure out why your page suddenly looks like a monkey coded it?
|
Does any one know any good resouces for creating Visual Slick macros? |
|slickedit| |
Does any one know any good resouces for creating Visual Slick macros? |
In your **svn\repos\test\conf** folder you will find 2 files **authz** and **passwd** these are the 2 you need to adjust.
In the **passwd** file you need to add some username and passwords. I assume you have already done this since you have people using it
[users]
User1=password1
User2=password2
... |
In your **svn\repos\YourRepo\conf** folder you will find 2 files **authz** and **passwd** these are the 2 you need to adjust.
In the **passwd** file you need to add some username and passwords. I assume you have already done this since you have people using it
[users]
User1=password1
User2=password2... |
They happen in constant time. I'm looking at page 466 of the ISO/IEC 14882:2003 standard:
**Table 65 - Container Requiments**
a.begin(); *(constant complexity)*
a.end(); *(constant complexity)*
**Table 66 - Reversible Container Requirements**
a.rbegin(); *(constant complexity)*
a.rend(); *(... |
Who's responsibility is it, anyway? A design question. |
|single-responsibility-principle| |
In the application I am writing I have a Policy class. There are 4 different types of Policy. Each Policy is weighted against the other Policies such that PolicyA > PolicyB > PolicyC > PolicyD.
Who's responsibility is it to implement the logic to determine whether one Policy is greather than another? My initial t... |
If it ain't broke don't fix it.
Just write a quick test, but bear in mind that each language will be faster with certain functions then the other. |
That is how we're doing it in our team, without the RelativeSource search, rather by naming the UserControl and referencing properties by the UserControl's name.
<UserControl x:Class="WpfApplication3.UserControl1" x:Name="UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
... |
* Whole team (being empowered to deliver)
* Small releases
* Coding standards
* Collective code ownership
But then, I do work in a mission-critical development team that's quite conservative. I don't necessarily thing XP is a good way to develop, you must find a way that's right for you and ignore the dogma. |
If you have access to your apache install and trust third-party code, you can use the [apache upload progress module](http://drogomir.com/blog/2008/6/18/upload-progress-bar-with-mod_passenger-and-apache) (if you use apache; there's also a [nginx upload progress module](http://wiki.codemongers.com/NginxHttpUploadProgres... |
The way I've done this kind of thing is to include seperate build files depending on the type of build using the [nant task][1]. A possible alternative might be to use the [iniread task in nantcontrib][2].
[1]: http://nant.sourceforge.net/release/latest/help/tasks/nant.html
[2]: http://nantcontrib.sourceforge... |
Adobe Reader Error Codes |
|pdf|pdf-generation| |
I am programmatically creating PDFs, and a recent change to my generator is creating documents that crash both Mac Preview and Adobe Reader on my Mac. Before Adobe Reader crashes, it reports:
> There was an error processing a page.
> There was a problem reading this document (18).
I suspect that that "18" might... |
You only need a cluster if you know what you want to do. Come back with an actual requirement, and someone will suggest a solution. |
Which is faster, python webpages or php webpages? |
Your regex is badly chosen on several points:
1. Instead of matching two slashes specifically, you use `..` to match two characters that can be anything at all, presumably because you don’t know how to match slashes when you’re also using them as delimiters. (Actually, almost anything, as we’ll see in #3.)
Wit... |
Your regex is badly chosen on several points:
1. Instead of matching two slashes specifically, you use `..` to match two characters that can be anything at all, presumably because you don’t know how to match slashes when you’re also using them as delimiters. (Actually, dots match *almost* anything, as we’ll see in #... |
If you really care about the speed of this make sure your compiler is generating the FIST instruction. In MSVC you can do this with /QIfist, [see this MSDN overview][1]
You can also consider using SSE intrinsics to do the work for you, see this article form Intel: [http://softwarecommunity.intel.com/articles/eng/20... |
If you really care about the speed of this make sure your compiler is generating the FIST instruction. In MSVC you can do this with /QIfist, [see this MSDN overview][1]
You can also consider using SSE intrinsics to do the work for you, see this article from Intel: [http://softwarecommunity.intel.com/articles/eng/20... |
How has no answer mentioned [Testivus][1] yet? All you need to know right there :)
[1]: http://www.artima.com/weblogs/viewpost.jsp?thread=203994 |
Like this:
FRUITS="apple orange kiwi"
for FRUIT in $FRUITS; do
echo $FRUIT
done
Notice this won't work if there are spaces in the names of your fruits. |
Like this:
FRUITS="apple orange kiwi"
for FRUIT in $FRUITS; do
echo $FRUIT
done
Notice this won't work if there are spaces in the names of your fruits. In that case, see [this answer][1] instead, which is slightly less portable but much more robust.
[1]: http://stackoverflow.com/questi... |
Process handles are waitable. They are signalled - will release any waiting thread - when the process exits. You can use them with WaitForSingleObject, WaitForMultipleObjects, etc. |
On windows, you can do it easily in three ways:
require 'win32console'
puts "\e[31mHello, World!\e[0m"
Now you could extend String with a small method called `red`
require 'win32console'
class String
def red
"\e[31m#{self}\e[0m"
end
end
puts "Hello, W... |
for SQL 2005:
SELECT col1 from
(select col1, dense_rank(col1) over (order by col1 desc) ranking
from t1) subq where ranking between 2 and @n
|
There are no **good** reasons *not* to use them... unless orphaned rows aren't a big deal to you I guess. |
Embedding Live Video from an IP WebCam |
|video|streaming|webcam|sony| |
We are using a Sony SNC-RZ30N IP-based webcam to monitor osprey nests and would like to stream the video feed via our own webserver.
Rather than use the built-in webserver of the camera (which requires either ActiveX or Java on the client side) to display the live feed, I would like to weed out just the live feed an... |
Another <I>gotcha</I>.<P>
Since const really only works with basic data types, if you want to work with a class, you may feel "forced" to use ReadOnly. However, beware of the trap! ReadOnly means that you can not replace the object with another object (you can't make it refer to another object). But any process tha... |
Access uses # as date field delimiter. The format should be #mm/dd/yyyy# probably the #mm-dd-yyyy# will also work fine. |
As far as I know there is no mechanism for doing this in JUnit, however you could try subclassing Suite and overriding the run() method with a version that does provide hooks. |
I do not believe there is any command-line option to do that.
You can however set the default behavior by setting the registry-value HKEY\_CURRENT\_USER\Software\Microsoft\Notepad\fWrap to 0.
Depending on your exact requirements, you might be able to solve your problem by making a bat-file that modifies the regis... |
Well the SP's are already there. It doesn't make sense to can them really. I guess does it make sense to use a mapper with SP's? |
You could just use Wordpad instead of Notepad, it has word wrap off by default. |
I'd like to add that div-based layouts are easer to mantain, evolve, and refactor. Just some changes in the CSS to reorder elements and it is done. From my experience, redesign a layout that uses tables is a nightmare (more if there are nested tables).
Your code also has a meaning from a [semantic][1] point of vie... |
To echo Nate:
In older versions, I've had it corrupt databases - so a good backup regime is essential. I wouldn't code anything into your app to do that automatically. However, if a customer finds that their database is running really slow, your tech support people could talk them through it if need be (with appropria... |
I have done a similar conversion, but for different reasons. It was because we needed better ACID support, and the ability to have web users see the same data they could via other DB tools (one ID for both).
Here are the things that bit us:
1. MySQL does not enforce constraints
as strictly as PostgreSQL. ... |
You might be missing the point of the database in this instance. Its job is to return the data to you that satisfies the conditions you gave it. I think you will want to implement the highlighting probably using regex in your web control.
Here is something a quick search would reveal.
http://www.dotnetjunkies.c... |
The above script simply deletes everything related to Mono on your system -- and since the developers wrote it, I'm sure they didn't miss anything :) Unlike some other operating systems made by software companies that rhyme with "Macrosoft", uninstalling software in OS X is as simple as deleting the files, 99% of the t... |
@foxxtrot
Actually, the standard shell is Bourne shell (`sh`). `/bin/sh` on Linux is actually `bash`, but if you're aiming for cross-platform scripts, you're better off sticking to features of the original Bourne shell or writing it in something like `perl`.
|
You could simply use the bash shell arguments, like this:
#!/bin/bash
# This is move.sh
mv backup/gem/$1 gem/
mv backup/doc/$1 doc/
# ...
and then execute it as:
sudo ./move.sh foo
Be sure make the script executable, with
chmod +x move.sh |
[Antlr][1] would do the trick.
[1]: http://www.antlr.org |
Altova XmlSpy does this well - you can find an overview [here][1]
[1]: http://www.altova.com/products/xmlspy/dtd_editor.html |
Just as an advise: the method using strings as indices is actually *very* slow. A much more efficient but otherwise equivalent solution would be to use vectors/arrays. There's absolutely no need to write the indices in a string.
typedef vector<size_t> index_t;
struct index_cmp_t : binary_function<index_t,... |
Accessing Datasource from Outside A Web Container (through JNDI) |