instruction stringlengths 0 30k ⌀ |
|---|
[Lua][1] was designed to be a programming language where the syntax lets you easily use it as a markup language as well, so that you include data files as if they were code. Many computer games use it for their scripting, such as World of Warcraft due to its speed and ease of use. However it's originally designed and m... |
This is the sort of thing <a href="http://oauth.net/">OAuth</a> was designed for. <a href="http://groups.google.com/group/oauth/msg/0cf50121f946a889">Google have started to adopt it</a>. It doesn't have the same trust issues as the more typical scraping.
Unfortunately, for the time being, people tend to just ask f... |
Assume I have an "images" folder directory under the root of my application. How can I, from within a .css file, reference an image in this directory using an ASP.NET app relative path.
Example:
When in development, the path of **~/Images/Test.gif** might resolve to **/MyApp/Images/Test.gif** while, in product... |
I've found that doing validation in the application, rather than in the database, works well. Of course then, all the interaction needs to go through your application. If you have other applications that work with your data, your application will need to support some sort of API (hopefully REST). |
Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. It's not quite perfect but ought to work for you.
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyTextBox : TextBox {
... |
It doesn't actually look like you're using it as described in the docs:
http://search.cpan.org/~lds/CGI.pm-3.42/CGI.pm#COMPATIBILITY_WITH_CGI-LIB.PL
If you must use it, then CGI::ReadParse(); seems more sensible and less crufty syntax. Although I can't see it making much difference in this situation, but then it is... |
In case you didn't know you could do this...
If you give a relative path to a resource in a CSS it's relative to the CSS file, not file including the CSS.
background-image: url(../images/test.gif);
So this might work for you. |
Inside of the .css file you can use relative paths; so in your example, say you put your css file in ~/Styles/mystyles.css. You can use url(../Images/Test.gif) as an example. |
Steve Cooper answered the first part. For the second part, you can use:
.../xsl:template/xsl:choose/xsl:when[@test="@name='First Name'"]/xsl:call-template/@name
Which will match specifically the xsl:when in your above snippet. If you want it to match generally, then you can use:
.../xsl:template/xsl:... |
As per the docs, use 0 to denote no maximum or minimum size. |
As per the docs, use 0 to denote no maximum or minimum size. Tho, I just tried it and it didn't like 0 at all. So I used int.MaxValue like you did and it worked. What version of the the framework you using? |
IMHO, wxWidgets is better than any of those. For example, I know of many people that converted their projects from MFC to wx. wxWidgets has all the MFC has (in early wx versions, a lot of classes were clones of MFC classes), and a lot more. It is not just a GUI library, but you have wrappers for all kinds of common tas... |
An arbitrary set of tags - so I can mark a test as, for example "integration, UI, admin".
(you knew I was going to ask for this didn't you :-) |
1. Top is the distance from the top of the html element or, if this is within another element with absolute position, from the top of that.
2. & 3. It depends on the width of the image but it might be for centering the image horizontally (if the width of the image is 890px). There are other ways to center an image h... |
try avoid using string-literals in your HTML and use javascript to bind javascript events.
also, avoid 'href=#' unless you *really* know what you're doing, it breaks so much usability for compulsive middleclickers.( tab opener )
<a id="tehbutton" href="somewhereToGoWithoutWorkingJavascript.com">Select</a>
... |
try avoid using string-literals in your HTML and use javascript to bind javascript events.
also, avoid 'href=#' unless you *really* know what you're doing, it breaks so much usability for compulsive middleclickers.( tab opener )
<a id="tehbutton" href="somewhereToGoWithoutWorkingJavascript.com">Select</a>
... |
How to determine order for new item? |
|php|mysql| |
I have a members table in MySQL
CREATE TABLE `members` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(65) collate utf8_unicode_ci NOT NULL,
`order` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
And I would like to let users or... |
This is somewhat of a stab in the dark...but I believe there are some drivers with MDAC that aren't available in x64 windows. I think you may be able to install the normal 32-bit MDAC but it will install to the x86 folder. |
I didn't try to reproduce the "bug" (I think we can consider this as a bug if it is the actual behavior), but maybe you could get over it.
The PHP Doc says that the default comportement is to write the result to a file, and that the default file is STDOUT (the browser's window). What you want is to get the same resu... |
Sorry for blowing my own trumpet, but you might be interested to have a look some slides I did for a short presentation about [Graphing With Perl][1].
It mentions some of the suggestions here, but also gives you some code snippets that you might be able to use to help you get the most of what you're doing.
[1... |
You could always have it send messages via Jabber (or whatever IM network you choose). |
Just get the value of the property and then cast it into an IEnumerable. Here is some (untested) code to give you an idea:
ClassWithListProperty obj = new ClassWithListProperty();
obj.List.Add(1);
obj.List.Add(2);
obj.List.Add(3);
Type type = obj.GetType();
PropertyInfo listPropert... |
It is a good pattern to use, that way what ever implements the event can find what was sending it.
Also overriding the EventArgs and passing data through them is the best method. The EventArgs are a base class. If you look at various controls that call events, they have overridden EventArgs which gives you more ... |
Everything I said originally is WRONG! The point in time at which the side-affect is calculated **is** unspecified. Visual C++ will perform the increment after the call to foo() if test is a local variable, but if test is declared as static or global it will be incremented before the call to foo() and produce different... |
I've not tried it myself but [LineCounterAddin][1] is visual studio plugin that includes the step-by-step guide to it's creation. It supports the formats you're asking about (VB and ASPX) as well as heaps more (e.g. XML, XSD, TXT, JS, SQL...).
[1]: http://www.codeproject.com/KB/macros/LineCounterAddin.aspx |
How sure are you that calling a member function via a pointer is slower than just calling it directly? Can you measure the difference?
In general, you should not rely on your intuition when making performance evaluations. Sit down with your compiler and a timing function, and actually *measure* the different choices... |
How sure are you that calling a member function via a pointer is slower than just calling it directly? Can you measure the difference?
In general, you should not rely on your intuition when making performance evaluations. Sit down with your compiler and a timing function, and actually *measure* the different choices... |
Set operation in .NET C# |
|c#|.net|data-structures|set| |
I'm working on a something related to roughset right now. The project uses alot of sets operation and manipulation. I've been using string operations as a stop gap measure for set operation. It has worked fine until we need to process some ungodly amount of data ( 500,000 records with about 40+ columns each ) through t... |
Don't throw away your code!
It's the single worst mistake you can make (on a large codebase). See [Things You Should Never Do, Part 1][1].
You've invested a lot of effort into that old code and worked out many bugs. Throwing it away is a classic developer mistake (and one I've done many times). It makes you fe... |
In general, as the (decision version of the) Hamiltonian Path problem is NP-complete, you cannot hope to get a polynomial-time algorithm for finding Hamiltonian paths. You can slightly speed it up with the usual N! → N<sup>2</sup>2<sup>N</sup> dynamic programming trick (compute hp[v][w][S] = "is there a path that ... |
If you make your project a war or ear type maven will copy the dependencies. |
If you're familiar with Python, it's pretty easy to write a script for this.
[Activestate Python][1] (which is free) exposes the relevant parts of the Win32 API through the [win32process][2] module.
You can also check out [all win32 related modules][3] or use [gotAPI][4] to browse the Python standard libs.
... |
Good explanation of "Combinators" (For non mathematicians) |
|combinators| |
Anyone got agood explanation of "combinators" (Y-combinators etc. and NOT the company)
I'm looking for one for the practical programmer who understands recursion and higher-order functions, but doesn't have a strong theory or math background. |
Anyone got a good explanation of "combinators" (Y-combinators etc. and NOT the company)
I'm looking for one for the practical programmer who understands recursion and higher-order functions, but doesn't have a strong theory or math background.
(Note that I'm talking about these things : http://en.wikipedia.org/wi... |
For classic ASMX services you definitely get a new instance with each request, just like an ASPX request. For a WCF service (.SVC) you do have more options, such as running as a singleton.
If you are interested in doing work with a singleton and pooling you can use the ASMX service simply as the lightweight proxy to... |
Declare a separate function in the <head> section and invoke that in your onClick method. |
Declare separate functions in the <head> section and invoke those in your onClick method. If you have lots you could use a naming scheme that numbers them, or pass an integer in in your onClicks and have a big fat switch statement in the function.
Or you could have javascript that binds onClick handlers to ea... |
Declare separate functions in the <head> section and invoke those in your onClick method. If you have lots you could use a naming scheme that numbers them, or pass an integer in in your onClicks and have a big fat switch statement in the function. |
In XSLT 2.0, and with Saxon, you can do this with the `collection()` function:
<xsl:for-each select="file:///path/to/directory">
<!-- process the documents -->
</xsl:for-each>
See [http://www.saxonica.com/documentation/sourcedocs/collections.html][1] for more details.
[1]: http://www.saxonica.c... |
The only solution I know is to create a complete backup of your active database and restore this backup to a copy of the database in a 'warm backup' state. First create a backup from the active db:
backup database activedb to disk='somefile'
Then restore the backup on another sql server. If needed you can use... |
I don't know about CVS, but if going to SVN is an option, there's always [Ankh][1].
[1]: http://ankhsvn.open.collab.net/ |
If you have your application open and you want a popup to appear, you could have a javascript timer that does an ajax style poll of your server every so often to see if there is a notification it needs to post. You could then throw up a pop up with the notification? |
I can't drag anything int SWF you linked, just zoom via mouseWheel.
You can make more than one movieClip dragging at once using events mousedown, mouseMove and mouseUp.
Add event handler for events via Mouse.addListener(object).
- In mouseDown set some flag and remeber current mouse position.
- In mouseMove i... |
As others said, you cannot do it in a platform-independent way. In .NET world, you could create a custom XmlResolver so that document('dir://c:/foo/') would return the list of files in the 'c:\foo' directory in an arbitrary format you wish. See the following links for more information on custom XmlResolver's:
<a hre... |
"I realize how and what parameters should be passed to javac, the problem is the IDE doesn't seem to allow these to be set anywhere."
I realized now that you know how to pass the right arguments ONLY not where/how to pass those arguments :-(
How about this : Can you locate where is the JAVA_HOME/bin directory... |
You can use Linq to Objects in C# 3.0. |
Check out the [Railscast][1] covering exactly this topic. It builds on the previous episode which discusses Restful Authentication.
[1]: http://railscasts.com/episodes/68-openid-authentication |
You ever think about sing F#? This seems like a job for a functional programming language. |
Yes, I'd go for ImageMagick definitely. I'd give http://midimick.com/magicknet/ a shot if I were you.. |
Function pointers are almost always better than chained-ifs. They make cleaner code, and are nearly always faster. |
Function pointers are almost always better than chained-ifs. They make cleaner code, and are nearly always faster (except perhaps in a case where its only a choice between two functions and is always correctly predicted). |
I should think that the pointer would be faster.
Modern CPUs prefetch instructions; mis-predicted branches flush the cache, which means it stalls while it refills the cache. A pointer doens't do that. |
I should think that the pointer would be faster.
Modern CPUs prefetch instructions; mis-predicted branches flush the cache, which means it stalls while it refills the cache. A pointer doens't do that.
Of course, you should measure both. |
I would take a look at [Kevin's Bag-o-tricks][1]
[1]: http://j832.com/BagOTricks/ |
Hidden markov models implementation in .net? |
|.net|hiddenmarkhovmodels|hidden-markov-models| |
Does anyone know of any HMM implementation in .net?
I've some stuff that I did that was basicly reverse engineered from what little knowledge that I have regarding the subject and some c++ code of a very domain specific application that one of my professors did.
I want to improve it somewhat and having another's... |
I generally need to diff codes from subversion repositories and so far eclipse has worked really nicely for me... I use KDiff3 for other works. |
.NET 3.5 already has a native set data type: [HashSet][1]. You might also want to look at [HashSet and LINQ set operators][2] for the operations.
In .NET 1.0, there was a third party Set data type: [Iesi.Collections][3] which was extended with .NET 2.0 generics with [Iesi.Collections.Generic][4].
You might want t... |
The more plugins you have, the more memory Eclipse will consume. 3.4 includes more plugins by default than 3.3, and so on, and so on, as more and more developers clamor for features to be included.
Go to Window->Show View, and start typing "plug in", and one of the options will be the Plug In Registry. Open that v... |
Have you looked at [Starling][1]? It's the server used by twitter to handle their messages. It's a persistent queue server that allows you to delegate jobs to workers.
[1]: http://rubyforge.org/projects/starling/ |
Bypass GeneratedValue in Hibernate |
|java|hibernate|jboss| |
Is it possible to bypass @GeneratedValue for an ID in hibernate, we have a case where, most of the time we want the ID to be set using GeneratedValue, but in certain cases would like to set the ID manually.
Is this possible? |
You have three options:
1. Redesign the application so that you don't have two different processes (both with database connections) writing to the database and roll it into a single app.
2. Create application C that handles all the database transactions for A and B.
3. Roll your own two phase commit. Applicati... |
I also hate Access, but you must play with the cards you are dealt.
Continuous forms are a wonderful thing in Access, until you run into any sort of complexity as is commonly the case, like in this instance.
Here is what I would do when faced with this situation (and I have implemented similar workarounds before):... |
Try this
%in = ReadParse();
but i doubt that. Are you trying to get query parameters or something?
|
The sort you mention in Approach 1 can be reduced to linear time (from log-linear as you describe it) because the two input lists are already sorted. Just perform the merge step of merge-sort. With an appropriate representation for the input span vectors (for example singly-linked lists) this can be done in-place.
... |
You could use this to find out who the process owner is, then once you have that you can use Win32_Process to kill the process by the process ID.
[MSDN Win32_Process class details][1]
[MSDN Terminating a process with Win32_Process][2]
[1]: http://msdn.microsoft.com/en-us/library/aa394372.aspx
[2]: ht... |
You can HtmlEncode text box content but unfortunately that won't stop the exception from happening. In my experience there is no way around and you have to disable page validation. By doing that you're saying: "I'll be careful, I promise." |
You can [HtmlEncode][1] text box content but unfortunately that won't stop the exception from happening. In my experience there is no way around and you have to disable page validation. By doing that you're saying: "I'll be careful, I promise."
[1]: http://msdn.microsoft.com/en-us/library/w3te6wfz.aspx "HttpServer... |
"Google Maps Hacks" has a hack, ["Hack 30. Stay Out of Traffic Jams"][1], on that.
[1]: http://safari.oreilly.com/0596101619/googlemapshks-CHP-4-SECT-3 |
"Google Maps Hacks" has a hack, ["Hack 30. Stay Out of Traffic Jams"][1], on that.
You can also find out how to get U.S. traffic info from John Resig's ["Traffic Conditions Data"][2] article.
[1]: http://safari.oreilly.com/0596101619/googlemapshks-CHP-4-SECT-3
[2]: http://ejohn.org/blog/traffic-conditions-... |
In SQL 2005:
select object_name(object_id), name
from sys.columns
where is_identity = 1
|
[ElementTree 1.3][1] (unfortunately not 1.2 which is the one included with Python) [supports XPath][2] like this:
import elementtree.ElementTree as xml
def getValues(tree, category):
parent = tree.find(".//parent[@name='%s']" % category)
return [child.get('value') for child in parent]
... |
[ElementTree 1.3][1] (unfortunately not 1.2 which is the one included with Python) [supports XPath][2] like this:
import elementtree.ElementTree as xml
def getValues(tree, category):
parent = tree.find(".//parent[@name='%s']" % category)
return [child.get('value') for child in parent]
... |
How can I tell if a Windows application (command line or GUI) is running on locked workstation or while user is logged out |
|windows|command-line| |
I have several applications that are part of a suite of tools that various developers at our studio use. these applications are mainly command line apps that open a DOS cmd shell. These apps in turn start up a GUI application that tracks output and status (via sockets) of these command line apps.
The command line ... |
With much thanks to Jim, the exact solution I was looking for is:
p.properties()[s].get_value_for_datastore(p)
To all the other respondents, thank you for your help. I also would have expected the Model class to implement the python standard way of doing this, but for whatever reason, it doesn't. |
This has probably been done in order to center the element on the page (using the ["dead center"](http://www.wpdfd.com/editorial/thebox/deadcentre4.html) technique).
It works like this: Assuming the element is 890px wide, it's set to `position:absolute` and `left:50%`, which places its **left-hand edge** in the **ce... |
private bool _isSelected = true;
private void textBox_Validated(object sender, EventArgs e)
{
_isSelected = false;
}
private void textBox_MouseClick(object sender, MouseEventArgs e)
{
if (!_isSelected)
{
_isSelected = true;
textBox.Sele... |
private bool _isSelected = true;
private void textBox_Validated(object sender, EventArgs e)
{
_isSelected = false;
}
private void textBox_MouseClick(object sender, MouseEventArgs e)
{
SelectAllText(textBox);
}
private void textBox_Enter(object sender, EventAr... |
private bool _isSelected = false;
private void textBox_Validated(object sender, EventArgs e)
{
_isSelected = false;
}
private void textBox_MouseClick(object sender, MouseEventArgs e)
{
SelectAllText(textBox);
}
private void textBox_Enter(object sender, EventA... |
What about:
,([^@]+@[^,]+),
Where the group contains the email address. |
What about:
,([^@]+@[^,:]+)
Where the group contains the email address.
**[Updated based upon comment that address doesn't always get terminated by a comma]** |
This is a good article:
http://www.dreamsongs.com/NewFiles/WhyOfY.pdf
The code examples are in scheme, but they shouldn't be hard to follow. |
I <a href="http://tedlogan.com/techblog3.html">wrote all about tabs in vim</a>, which gives a few interesting things you didn't ask about. To automatically indent braces, use:
:set cindent
To indent two spaces (instead of one tab of eight spaces, the vim default):
:set shiftwidth=2
To keep vim from ... |
I would say this practice promotes concentrating your efforts on the 'problem space' rather than the 'solution space'. Driving an emergent solution (the design) by studying and really getting to know and understand the domain. One of the practices (taken from XP) would be the writing of stories that occur in the proble... |
I would say this practice promotes concentrating your efforts on the 'problem space' rather than the 'solution space'. Driving an emergent solution (the design) by studying and really getting to know and understand the domain. One of the practices (taken from XP) would be the writing of stories that occur in the proble... |
I use single letters only when the loop counter is an index. I like the thinking behind the double letter, but it makes the code quite unreadable. |
I've started using perlisms in php.
if its a singular iteration, <code>$_</code> is a good name for those who know its use. |
How you setup a greenfield project |
|build-process|build-automation|build|continuous-integration| |