instruction stringlengths 0 30k ⌀ |
|---|
|regex|xhtml| |
How would you programmacially abbriviate XHTML to an arbitrary number of words without leaving unclosed or corrupting tags?
E.g. this:
<p>
Proin tristique dapibus neque. Nam eget purus sit amet leo
tincidunt accumsan.
</p>
<p>
Proin semper, orci at mattis blandit, augue ju... |
How would you programmacially abbriviate XHTML to an arbitrary number of words without leaving unclosed or corrupted tags?
E.g. this:
<p>
Proin tristique dapibus neque. Nam eget purus sit amet leo
tincidunt accumsan.
</p>
<p>
Proin semper, orci at mattis blandit, augue jus... |
Check out "Writing Efficient Ruby Code" from Addison Wesley Professional:
[http://safari.oreilly.com/9780321540034][1]
I found some very helpful and interesting insights in this short work. And if you sign up for the free 10-day trial you could read it for free. (It's 50 pages and the trial gets you (AFAIR) 1... |
Parsing manually is a lot of fun... at the beginning:)
In practice if commands aren't very sophisticated you can treat them the same way as those used in command line interpreters. There's a list of libraries that you can use: [http://java-source.net/open-source/command-line](http://java-source.net/open-source/comm... |
How do you handle white space in your HTML |
|html| |
One of my biggest typographical frustrations about HTML is the way that it mangles conjoined whitespace. For example if I have:
<span>Following punctuation rules. With two spaces after the period. </span>
One of the two spaces following the period will be considered to be insignificant whitespace and be re... |
Generating a good hash is easier said than done. Remember, you're basically representing n bytes of data with m bits of information. The larger your data set and the smaller m is, the more likely you'll get a collision ... two pieces of data resolving to the same hash.
The simplest hash I ever learned was simply X... |
You could drop off the constructor and just put them in each individual class. Then what you have is each class has its own __construct, which is probably the same depending on if it is a shipper or vendor. If you want to only have those constructs defined once I don't think you want to go down that route.
What I t... |
You can use a styled pre block to preserve whitespace. Most WYSIWYG editors also insert &nbsp; for you...
Overall, it's good that the browser ignores whitespace. Just view the source on this website for yourself and imagine how crazy the site would look if every space was displayed. |
I really like the [Apache Felix tutorials][1]. However, I think in general leveraging OSGi in your application isn't one of those "let's use this framework, because it's hype" decision. It's more of a design question, but then everything that OSGi gives you in terms of design, you can have with vanilla Java as well.
... |
In Firebird writers never block readers and there are no dirty-reads. Only read-commited and snapshot isolation levels.
It uses a multi-generational engine (like oracle i believe) instead of simple page or record locking. |
Favicon must be an [.ico file](http://en.wikipedia.org/wiki/ICO_%28icon_image_file_format%29) to work properly on all browsers.
Modern browsers also support PNG and GIF images.
I've found that in general the easiest way to create one is to use a freely available web service such as [favicon.cc](http://favicon.cc/... |
Favicon must be an [.ico file](http://en.wikipedia.org/wiki/ICO_%28icon_image_file_format%29) to work properly on all browsers.
Modern browsers also support PNG and GIF images.
I've found that in general the easiest way to create one is to use a freely available web service such as [favicon.cc](http://favicon.cc/... |
Use an interface that runs each response in a separate interpreter, such as `mod_wsgi` for Python. This lets multi-threading be used without encountering the GIL.
EDIT: Apparently, `mod_wsgi` no longer supports multiple interpreters per process because idiots couldn't figure out how to properly implement extension m... |
I use [Subversion][1].
As an easy way to reference the website version (production, testing, development), I use a very simple trick. I add the revision number somewhere on the site (eg in the admin footer). Something like this:
<?php print("$Revision: 1 $"); ?>
Each time you checkout (development versions) ... |
I use a proportional font too. They seem good for the same reasons they work in books and magazines: the more variation between characters, the easier it is for the brain to distinguish them; and you can fit more on the screen. Indentation still works fine: 6 leading spaces is still twice as wide as 3 leading spaces.... |
I'm not totally sure which problem you want so solve, but if you deploy your python/django application via an apache prefork MPM using mod_python apache will start several worker processes for handling different requests.
If one request needs so much resources, that you want to use multiple cores have a look at [pyp... |
Caching MySQL queries |
|php|mysql|caching| |
Is there a simple way to cache MySQL queries in PHP or failing that, is there a small class set that someone has written and made available that will do it? I can cache a whole page but that won't work as some data changes but some does not, I want to cache the part that does not. |
I'm surprised that someone who has used Subversion in the past would even have a want/need for TFS source control.
My experience with TFS (2005) has been pretty horrible. I've read all kinds of whitepapers & guidance as to how to properly structure your source for various development needs.
Our simple situation,... |
> s/[^:]\bBoolean\b(?!")/bool/g
This does not match strings where Boolean is at that the beginning of the line becuase [^:] is "match a character that is not :". |
It works just fine. I have worked with source code from my "home" folder on many different systems (NFS, Samba, AD) and never had any problems. The only drawback is that you might experience somewhat longer compile times if your network is slow or there is much traffic on the network. Under normal circumstances this is... |
In SP1 does the foo.Bar property get properly deserialized?
In pre SP1 you wouldn't be able to deserialize the object because the set method of the Bar property is private so the XmlSerializer doesn't have a way to set that value. I'm not sure how SP1 is pulling it off.
You could try adding this to your web.conf... |
Flex ComboBox, default value and dataproviders |
|apache-flex|data-binding| |
I have a Flex ComboBox that gets populated by a dataprovider all is well...
I would now like to add a default " -- select a item --" option at the 0 index, how can I do this and still use a dataprovider? I have not seen any examples of such, but I can't imagine this being hard...
|
Normally you would do this with a 3x3 Matrix, but the Matrix class only lets you specify 6 values instead of 9. You might be able to do this in Direct X. |
Let's combine the culture-safe answer and the extension method answer:
public static class DateTimeExtensions
{
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
{
System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCult... |
If your pages are "updatable," they must be compiled before use. That means, yes, on first request the assemblies are loaded, compiled, and made ready for accessing. Whenever these files are changed (even some virus software can trigger this by changing the modified date of the files!), the appdomain gets recycled.
... |
How can I make flash cs3, actionscript send events to javascript? |
|javascript|flash|actionscript| |
I'm using Flash to play an .flv movieclip on my site, but I want to have the .swf send trigger an event in my javascript when it start loading, starts playing and ends playing.
What is the best way to do that in Flash CS3 using Actionscript 3.0 ? |
What browser/ ad-on do you have? it may be your browser or some other software (may be even the web server) is blocking the sessions from http://www.myIsv.com/myWebSite/ with in the frame, thinking its an XSS attack.
If the session works at http://www.myIsv.com/myWebSite/ with out the frame you could always us a red... |
What browser/ ad-on do you have? it may be your browser or some other software (may be even the web server) is blocking the sessions from http://www.myIsv.com/myWebSite/ working from with-in the frame, as its located on a different site, thinking its an XSS attack.
If the session works at http://www.myIsv.com/myWebS... |
How you expose a collection depends entirely on how users are intended to interact with it.
**1)** If users will be adding and removing items from an object's collection, then a simple get-only collection property is best (option #1 from the original question):
private readonly Collection<T> myCollection_ = n... |
If you really want your white space to be preserved, try the css property: white-space: pre;
Or, you could just use a <pre> tag in your markup.
By the way, it's a good thing that HTML browsers ignore white space in general, it allows us to have clearly formatted source code, without affecting the output. |
The following is an example of a template that would produce the required output in XSLT 1.0:
<xsl:template name="getExtension">
<xsl:param name="filename"/>
<xsl:choose>
<xsl:when test="contains($filename, '.')">
<xsl:call-template name="getExtension">
<xsl:with-param ... |
How do I generate a hashcode from a byte array in c# |
|c#|hash| |
Say I have an object that stores a byte array and I want to be able to efficiently generate a hashcode for it. I've used the cryptographic hash functions for this in the past because they are easy to implement, but they are doing a lot more work than they should to be cryptographically oneway and I don't care about th... |
Say I have an object that stores a byte array and I want to be able to efficiently generate a hashcode for it. I've used the cryptographic hash functions for this in the past because they are easy to implement, but they are doing a lot more work than they should to be cryptographically oneway and I don't care about th... |
As far as web development, especially for javascript, I find [Firebug][1] to be invaluable. [Web developer toolbar][2] is also very useful.
[1]: http://getfirebug.com/
[2]: https://addons.mozilla.org/en-US/firefox/addon/60 |
[Web Developer][1] for web development. [Scribefire][2] if you're a blogger-progammer
[1]: https://addons.mozilla.org/en-US/firefox/addon/60
[2]: https://addons.mozilla.org/en-US/firefox/addon/1730 |
I'd also recommend the [Web Developer][1] extension by Chris Pederick.
[1]: https://addons.mozilla.org/en-US/firefox/addon/60 |
PHP best practices? |
|php| |
What is a good way to remove the code from display pages when developing with PHP. Often the pages I work on need to be editted by an outside person. This person is often confused by lots of blocks of PHP, and also likes to break my code.
I've tried moving blocks of code out into functions, so now there are function... |
|php| |
I guess it's silly to mention Firebug -- doubt any of us could live without it. Other than that I use the following (only listing dev-related):
- Console<sup>2</sup>: next-generation error console
- DOM inspector: as the title might indicate, allows you to browse the DOM
- Edit Cookies: change cookies on the fly
... |
There's a lot that can be said on this topic but a very basic starting point would be to move as much code as possible out into separate files and then use include statements. |
I don't believe ST_GeomFromText() is particularly expensive, although in the past I've optimized PostGIS queries by creating a function, declaring a variable and then assigning the result of ST_GeomFromText to the variable.
Have you tried checking the execution plan for you query with a variety of different paramete... |
I don't believe ST_GeomFromText() is particularly expensive, although in the past I've optimized PostGIS queries by creating a function, declaring a variable and then assigning the result of ST_GeomFromText to the variable.
Have you tried checking the execution plan for you query with a variety of different paramete... |
|c++|program-entry-point|return-values| |
I'm pretty sure VC++ just inserts a return 0 if you don't include one in main functions. The same thing can happen with functions too, but in those cases at least you'll get a warning. |
This is part of the C++ language standard. An implicit return 0 is generated for you if there's no explicit return statement in main. |
I wrote a script to do this a little while back. The script (Compare-QueryResults.ps1) is available [here][1] and you will also need my Run-SQLQuery script (available [here][2]) or you can replace that with a script or function of your own.
Basically, what the script does is take the results of each of your queries... |
Check out the [dbdeploy][1], there are Java and .net tools already available, you could follow their standards for the SQL file layouts and schema version table and write your python version.
[1]: http://dbdeploy.com/ |
> 3.6.1 Main function
>
> ....
>
> 2 An implementation shall not
> predefine the main function. This
> function shall not be overloaded. It
> shall have a return type of type int,
> but otherwise its type is
> implementation-defined. All
> implementations shall allow both of
> the following definitions of ... |
My company decided to buy the Infragistics NetAdvantage for .NET. We will be using their Gantt control.
Thanks for your answers. |
What are the naming conventions of an AS3 class? |
|actionscript-3|convention|naming| |
I'm trying to write a RegEx to determine a proper class or package name of an AS3 class.
I know
- Must start with a letter (capital or otherwise)
- any other digit can be alphanumeric
- cannot have spaces
Is there anything else? |
Sounds like robocopy is what you need.
Very powerful replication command.
Details : http://en.wikipedia.org/wiki/Robocopy
Full command switch guide : http://atlex.nl/tmp/robocopy_switches.txt
Batch scripting guide: http://www.tacktech.com/display.cfm?ttid=307 |
It may not be very elegant, but I apply CSS to a <pre> tag.
There's always the "white-space" CSS attribute, but it can be a bit hit and miss. |
what about the *ObjectContext.SavingChanges* event? See also <http://www.thedatafarm.com/blog/2008/07/13/OverridingObjectContextSaveChanges.aspx>. |
Take a look at the [pre tag](http://www.w3schools.com/TAGS/tag_pre.asp). It might do what you want. |
This won't solve your problem, but if you only needed lat/long data for these addresses, the Google Maps API will parse non-formatted addresses pretty well. |
Are there any standards at all in the way that the addresses are recorded? For example:
1. Are there always commas or new-lines separating street1 from street2 from city from state from zip?
2. Are address types (road, street, boulevard, etc) always spelled out? always abbreviated? Some of each?
3. Define "e... |
You'd better use white-space: pre-wrap than white-space: pre or &nbsp;
With your example, the latter solutions can start a new line on "rules.&nbsp;" just because your **n**on-**b**reakable **sp**ace hit the end of the line. |
Add the error to a hidden list with that users name. Set the visibility on the list (for users) to only read/write their own values. Then use a custom web part or FlexListViewer to view the contents of that list and display it to the user. Once they acknowledge that error, remove it from the list.
If necessary, you ... |
Add the error to a hidden list with that users name. Set the visibility on the list (for users) to only read/write their own values. Then use a custom web part or FlexListViewer to view the contents of that list and display it to the user. Once they acknowledge that error, remove it from the list.
If necessary, you ... |
I would leave the onClick and set it as the trigger for the updatePanel.
That's odd that it works in FF and not IE. That is opposite from the behavior we experience. |
Seems like the best you could do is to iterate through the list, for every item add it to a list of "seen" items or else remove it from the "seen" if it's already there, and at the end your list of "seen" items will include the singular element. This is O(n) in regards to time and n in regards to space (in the worst ca... |
Seems like the best you could do is to iterate through the list, for every item add it to a list of "seen" items or else remove it from the "seen" if it's already there, and at the end your list of "seen" items will include the singular element. This is O(n) in regards to time and n in regards to space (in the worst ca... |
Optimizing Sharepoint Search Crawling |
|sharepoint|.net|c#| |
With SharePoint Server 2007, there is also a Search Feature and a Crawler. However, the Crawler is somewhat limited in that it only supports Basic Auth when crawling external sites and that there is no way to tell it to ignore noindex,nofollow attributes.
Now, there is a site i'd like to index, unfortunately this si... |
Optimizing/Customizing Sharepoint Search Crawling |
|c#|.net|sharepoint| |
Would building an application using a Sql Server Database File (mdf) be a terrible idea? |
|asp.net|sql|sql-server|mysql| |
I'm working on a side project that would be a simple web application to maintain a list of classes and their upcoming schedules.
I would really like to use Linq to SQL for this project, but unfortunately the server environment I'm developing for only has MySql available. I've dabbled briefly with Subsonic but it jus... |
Rewrite or repair? |
This is a great overview of how to cache queries in MySQL:
- [The MySQL Query Cache][1]
[1]: http://www.petefreitag.com/item/390.cfm |
I've been using cntlm ([http://cntlm.sourceforge.net/][1]) at work. Configuration is very similar to ntlmaps.
- gem install --http-proxy http://localhost:3128 _name_of_gem_
Works great, and also allows me to connect my Ubuntu box to the ISA proxy.
Check out [http://cntlm.wiki.sourceforge.net/][2] for more i... |
Why not take the approach that GMail uses and show the number of messages in the page title?
Sometimes users don't want to be distracted when a new message arrives.
|
Personally, I just use comma-separed selector, but there some solution for writing css programmatically. Maybe this is a little overkill for you simpler needs, but take a look at [CleverCSS][1] (Python)
[1]: http://pypi.python.org/pypi/CleverCSS/ |
This should do the trick:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim path As String
path="/AbosoluteVitualPath/OutputCached.aspx"
HttpResponse.RemoveOutputCacheItem(path)
End Sub
|
Make Browser Window Blink in Task Bar |
|javascript|browser| |
How do I make a user's browser blink/flash/highlight in the task bar using JavaScript? For example, if I make an AJAX request every 10 seconds to see if the user has any new messages on the server, I want the user to know it right away, even if he is using another application at the time. |
How do I make a user's browser blink/flash/highlight in the task bar using JavaScript? For example, if I make an AJAX request every 10 seconds to see if the user has any new messages on the server, I want the user to know it right away, even if he is using another application at the time.
*Edit: These users do want ... |
The `@page` rule is supposed to allow this, but is only implemented in Opera. |
[CSS Variables][1], if it ever becomes implemented in all major browsers, may one day resolve this issue.
Until then, you'll either have to copy and paste, or use a preprocessor of whatever sort, like others have suggested (typically using server-sider scripting).
[1]: http://disruptive-innovations.com/zoo/cs... |
Iterable<T> only has the method Iterator<T> get() or somesuch. So no need to build any query or execute any code until you actually start iterating. It does make the execute in your example redundant. However, the thread will be locked until the first result is available, so you might consider using an Executor to run ... |
Clearing Page Cache in ASP.NET |
|asp.net|csharp|outputcache| |