instruction
stringlengths 0
30k
β |
---|
Sounds to me like you're trying to combine things that shouldn't be combined. If you need to do different processing in your view depending on if it's a User or Group object you're trying to look at then you should use two different view functions.
On the other hand there can be common idioms you'd want to extract out of your object_detail type views... perhaps you could use a decorator or just helper functions?
-Dan |
Is a GUID unique 100% of the time? |
|.net|guid| |
Is a GUID unique 100% of the time?
Will it stay unique over multiple threads?
|
|language-agnostic|guid| |
What do you call the tags in Subversion and CVS that add automatic content? |
|cvs|svn|tags| |
Things like <code>@log</code> and <code>@version</code> which add data upon check-in to the file. I'm interested in seeing the other ones and what information they can provide, but I can't get much info unless I know what they are called. Thanks. |
|svn|cvs|tags| |
Things like <code>$log$</code> and <code>$version$</code> which add data upon check-in to the file. I'm interested in seeing the other ones and what information they can provide, but I can't get much info unless I know what they are called. Thanks. |
I've been able to debug some control designer issues by running a second instance of VS, then from your first VS instance do a "Debug -> Attach to Process" and pick "devenv".
The first VS instance is where you'll set your breakpoints. Use the second instance to load up the designer to cause the "designer" code to run. |
How do I do multiple updates in a single SQL query? |
|php|sql| |
Okay, here's the case: I have an SQL query like this:
UPDATE foo
SET flag=true
WHERE id=?
Now, I have a PHP array, which has a list of IDs. Is there a neat way of doing this, outside parsing something like:
foreach($list as $item){
$querycondition = $querycondition . " OR " . $item;
}
and using that in the where clause?
|
Assuming you're joining on columns with no duplicates, which is by far the most common case:
- An inner join of A and B gives the result of A intersect B, i.e. the inner part of a venn diagram intersection.
- An outer join of A and B gives the results of A union B, i.e. the outer parts of a venn diagram union.
**Examples**
Suppose you have two Tables, with a single column each, and data as follows:
A B
- -
1 3
2 4
3 5
4 6
Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.
**inner join**
An inner join using either of the equivalent queries gives the intersection of the two tables, i.e. the two rows they have in common.
select * from a INNER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b;
a | b
--+--
3 | 3
4 | 4
**left outer join**
A left outer join will give all rows in A, plus any common rows in B.
select * from a LEFT OUTER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b(+);
a | b
--+-----
1 | null
2 | null
3 | 3
4 | 4
**full outer join**
A full outer join will give you the union of A and B, i.e. All the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.
select * from a FULL OUTER JOIN b on a.a = b.b;
a | b
-----+-----
1 | null
2 | null
3 | 3
4 | 4
null | 6
null | 5
|
> Because the Format method has nothing to do with a string's current value.
That's true for *all* string methods because .NET strings are immutable.
> If it was non-static, you would need a string to begin with.
It does: the format string.
I believe this is just another example of the many design flaws in the .NET platform (and I don't mean this as a flame; I still find the .NET framework superior to most other frameworks). |
I use it every time I refer to an instance variable, even if I don't need to. I think it makes the code more clear. |
I use it anywhere there might be ambiguity (obviously). Not just compiler ambiguity (it would be required in that case), but also ambiguity for someone looking at the code. |
I tend to underscore fields with _ so don't really ever need to use this. Also R# tends to refactor them away anyway... |
You should always use it, I use it to diferantiate private fields and parameters (because our naming conventions state that we don't use prefixes for member and parameter names (and they are based on information found on the internet, so I consider that a best practice)) |
I only use it when absolutely necessary, ie, when another variable is shadowing another. Such as here:
class Vector3
{
float x;
float y;
float z;
public Vector3(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
}
Or as Ryan Fox points out, when you need to pass this as a parameter. |
Any time you need a reference to the current object.
One particularly handy scenario is when your object is calling a function and wants to pass itself into it.
Example:
void onChange()
{
screen.draw(this);
} |
Since there are a bunch of different functional programming languages, it's hard to recommend books. But if you're interested in Common Lisp, recently I've been reading ["Practical Common Lisp"][1] by Peter Seibel, which you can [check out online for free][2] before dropping your hard earned cash on it. It's a pretty gentle introduction to CL, with great explanations and tons of examples. Seibel's a great writer (example: read [the story of Mac][3],) he's good at keeping you engaged, which is really where SICP falls down, I think. It's just so dry! But while Practical Common Lisp is pretty example-heavy, it doesn't really have challenges to work through, although the examples are mostly designed to let you continue to work and build on them.
Another good book, this one Scheme-oriented: [How to Design Programs][4]. ([Online][5])
I haven't had as much time with this book, being more of a Lisper than a Schemer myself, but it's well written, has good explanations and examples, and has lots of exercises to work on. It seems pretty popular in the Scheme crowd.
[1]: http://www.amazon.com/gp/product/1590592395?ie=UTF8&tag=gigamonkeys-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1590592395
[2]: http://gigamonkeys.com/book/
[3]: http://gigamonkeys.com/book/macros-defining-your-own.html
[4]: http://www.amazon.com/How-Design-Programs-Introduction-Programming/dp/0262062186
[5]: http://www.htdp.org/2003-09-26/ |
Is Visual Studio prompting you for the path to the source file? If it isn't then it doesn't think it has symbols for the callstack. Setting the source path should work without having to map the exact original location.
You can tell if symbols are loaded by looking at the 'modules' window in Visual Studio.
Assuming you are building a PDB then I don't think there are any options that control the amount of information in the PDB directly. You can change the type of optimizations performed by the compiler to improve debuggabilty, but this will cost performance -- as your co-worker points out, disabling inline will help make things more obvious in the crash file, but will cost at runtime.
Depending on the nature of your application I would recommend working with full dump files if you can, they are bigger, but give you all the information about the process ... and how often does it crash anyway :)
|
replace the last line from $CMD to just
wine '$EXEC' $ARGS
You'll note that the error is ''/home/chris/.wine/drive_c/Program' and not '/home/chris/.wine/drive_c/Program'
The single quotes are not being interpolated properly, and the string is being split by spaces. |
You can try preceeding the spaces with \ like so:
/home/chris/.wine/drive_c/Program Files/Microsoft\ Research/Z3-1.3.6/bin/z3.exe
You can also do the same with your \t problem - replace it with \\t. |
You can try preceeding the spaces with \ like so:
/home/chris/.wine/drive_c/Program Files/Microsoft\ Research/Z3-1.3.6/bin/z3.exe
You can also do the same with your \t problem - replace it with \\\t. |
I use passive view, a flavor of the [Model View Presenter][1] pattern, with any web forms like development (.NET) to increase testability/maintainability/etc
For example, your code-behind file might look something like this
Partial Public Class _Default
Inherits System.Web.UI.Page
Implements IProductView
Private presenter As ProductPresenter
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
MyBase.OnInit(e)
presenter = New ProductPresenter(Me)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
presenter.OnViewLoad()
End Sub
Private ReadOnly Property PageIsPostBack() As Boolean Implements IProductView.PageIsPostBack
Get
Return Page.IsPostBack
End Get
End Property
Public Property Products() As System.Collections.Generic.List(Of Product) Implements Library.IProductView.Products
Get
Return DirectCast(gridProducts.DataSource(), List(Of Product))
End Get
Set(ByVal value As System.Collections.Generic.List(Of Product))
gridProducts.DataSource = value
gridProducts.DataBind()
End Set
End Property
End Class
This code behind is acting as a very thin view with zero logic. This logic is instead pushed into a presenter class that can be unit tested.
Public Class ProductPresenter
Private mView As IProductView
Private mProductService As IProductService
Public Sub New(ByVal View As IProductView)
Me.New(View, New ProductService())
End Sub
Public Sub New(ByVal View As IProductView, ByVal ProductService As IProductService)
mView = View
mProductService = ProductService
End Sub
Public Sub OnViewLoad()
If mView.PageIsPostBack = False Then
PopulateProductsList()
End If
End Sub
Public Sub PopulateProductsList()
Try
Dim ProductList As List(Of Product) = mProductService.GetProducts()
mView.Products = ProductList
Catch ex As Exception
Throw ex
End Try
End Sub
End Class
[1]: http://msdn.microsoft.com/en-us/magazine/cc188690.aspx |
I'm not really sure what 'tag' is, but branch is a fairly common source control concept.
Basically, a branch is a way to work on changes to the code without affecting trunk. Say you want to add a new feature that's fairly complicated. You want to be able to check in changes as you make them, but don't want it to affect trunk until you're done with the feature.
First you'd create a branch. This is basically a copy of trunk as-of the time you made the branch. You'd then do all your work in the branch. Any changes made in the branch don't affect trunk, so trunk is still usable, allowing others to continue working there (like doing bugfixes or small enhancements). Once your feature is done you'd integrate the branch back into trunk. This would move all your changes from the branch to trunk.
There are a number of patterns people use for branches. If you have a product with multiple major versions being supported at once, usually each version would be a branch. Where I work we have a QA branch and a Production branch. Before releasing our code to QA we integrate changes to the QA branch, then deploy from there. When releasing to production we integrate from the QA branch to the Production branch, so we know the code running in production is identical to what QA tested.
Here's the [Wikipedia entry on branches][1], since they probably explain things better than I can. :)
[1]: http://en.wikipedia.org/wiki/Branching_(software) |
If having the revision numbers change based on other projects bothers you, then put the projects in separate repositories. That is the only way to make the revision numbers independent.
To me, the big reason to use different repositories is to provide separate access control for users and/or using different hook scripts. |
Hmm, not sure I agree with Nick re tag being similar to a branch. A tag is just a marker
- **Trunk** would be the main body of development, originating from the the start of the project until the present.
- **Branch** will be a copy of code derived from a certain point in the trunk that is used for applying major changes to the code while preserving the integrity of the code in the trunk. If the major changes work according to plan, they are usually merged back into the trunk.
- **Tag** will be a point in time on the trunk or a branch that you wish to preserve. The two main reasons for preservation would be that either this is a major release of the software, whether alpha, beta, RC or RTM, or this is the most stable point of the software before major revisions on the trunk were applied.
In open source projects, major branches that are not accepted into the trunk by the project stakeholders can become the bases for *forks* -- e.g., totally separate projects that share a common origin with other source code. |
How can I find the full path to a font from its display name on a Mac? |
|python|macos|font|photoshop| |
I am using the Photoshop's javascript API to find the fonts in a given PSD.
Given a font name returned by the API, I want to find the actual physical font file that that corresponds to on the disc.
This is all happening in a python program running on OSX so I guess I'm looking for one of:
* Some Photoshop javascript
* A Python function
* An OSX API that I can call from python |
Python and MySQL |
|python|mysql|postgresql| |
I can get Python to work with Postgresql but I cannot get it to work with MySQL. The main problem is that on the shared hosting account I have I do not have the ability to install things such as Django or PySQL, I generally fail when installing them on my computer so maybe it's good I can't install on the host.
I found [bpgsql][1] really good because it does not require an install, it's a single file that I can look at, read and then call the functions of. Does anybody know of something like this for MySQL?
[1]: http://barryp.org/software/bpgsql/ |
You can print from the command line using the following:
> rundll32.exe
> %WINDIR%\System32\mshtml.dll,PrintHTML
> "%1"
Where %1 is the file path of the html file to be printed.
If you don't need to print from memory (or can afford to write to the disk in a temp file) you can use:
using (Process printProcess = new Process())
{
string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
printProcess.StartInfo.FileName = systemPath + @"\rundll32.exe";
printProcess.StartInfo.Arguments = systemPath + @"\mshtml.dll,PrintHTML """ + fileToPrint + @"""";
printProcess.Start();
}
N.B. This only works on Windows 2000 and above I think. |
Just use ISO-8601. It's an international standard.
<http://en.wikipedia.org/wiki/ISO_8601> |
How do I use Python's itertools.groupby()? |
|python|iteration| |
I haven't been able to find an understandable explanation of how to actually use Python's itertools.groupby() function. What I'm trying to do is this: take a list - in this case, the children of an objectified lxml element - divide it into groups based on some criteria, and then later iterate over each of these groups separately.
I've reviewed the documentation (<http://docs.python.org/lib/itertools-functions.html>), and the examples, (<http://docs.python.org/lib/itertools-example.html>), but I've had trouble trying to apply them beyond a simple list of numbers.
So, how do I use of itertools.groupby()? Is there another technique I should be using? Pointers to good "prerequisite" reading would also be appreciated. |
Are you looking for a software package that'll do the work or actually doing the matrix operations and such and do each step?
The the first, a coworker of mine just used [Ocaml GLPK][1]. It is just a wrapper for the [GLPK][2], but it removes a lot of the steps of setting things up. It looks like you're going to have to stick with the GLPK, in C, though. For the latter, thanks to delicious for saving an old article I used to learn LP awhile back, [PDF][3]. If you need specific help setting up further, let us know and I'm sure, me or someone will wander back in and help, but, I think it's fairly straight forward from here. Good Luck!
[1]: http://ocaml-glpk.sourceforge.net/ "Ocaml GLPK"
[2]: http://www.gnu.org/software/glpk/ "GNU Linear Programming Kit"
[3]: http://www.math.ucla.edu/~tom/LP.pdf "Linear Programming" |
Can you show us your code?
The example on the Python docs is quite straight forward:
groups = []
uniquekeys = []
for k, g in groupby(data, keyfunc):
groups.append(list(g)) # Store group iterator as a list
uniquekeys.append(k)
So in your case, data is a list of nodes, keyfunc is where the logic of your criteria function goes and then groupby() groups the data. You must be careful to **sort the data** by the criteria before you call groupby or it won't work. groupby method actually just iterates through a list and whenever the key changes it creates a new group. |
Turn off javascript and make sure your site can still be navigated.
Even if you want to ignore the small but significant number of people who have it disabled, this will impact search engines as well. |
I learned from Jeffrey Ullman's <em>Elements of ML Programming</em>, which is pretty good. It loses points for being about Standard ML, when OCaml, F#, and Haskell are (seemingly) more popular. |
Netbeans is good becasue you can use it on Windows and OSX. |
You're doing this in c/c++... so you have an array of array of array... you don't have to visualize 20 dimensions since that isn't how the data is laid out in memory, for a 2 dimensional:
[1] --> [1,2,3,4,5,6,...]
[2] --> [1,2,3,4,5,6,...]
[3] --> [1,2,3,4,5,6,...]
[4] --> [1,2,3,4,5,6,...]
[5] --> [1,2,3,4,5,6,...]
. .
. .
. .
so, why can't you iterate across the first one summing it's contents? If you are trying to find the size, then `sizeof(array)/sizeof(int)` is a risky approach. You must know the dimension to be able to process this data, and set the memory up, so you know the depth of recursion to sum. Here is some pseudo code of what it seems you should do,
sum( n_matrix, depth )
running_total = 0
if depth = 0 then
foreach element in the array
running_total += elm
else
foreach element in the array
running_total += sum( elm , depth-1 )
return running_total
|
Not sure what the confusion is. Sites on your intranet are in the intranet zone, web sites are in the internet zone, and sites on your computer are in the local zone, unless you've specifically overridden something in the browser's preferences. |
I pretty much only use **this** when referencing a type property from inside the same type. As another user mentioned, I also underscore local fields so they are noticeable without needing **this**. |
It depends on the coding standard I'm working under. If we are using _ to denote an instance variable then "this" becomes redundant. If we are not using _ then I tend to use this to denote instance variable. |
I tend to use it everywhere as well, just to make sure that it is clear that it is instance members that we are dealing with. |
Behaviour is the same when a window finishes flashing for as long as it's supposed to: the taskbar button stays coloured. I don't think this is a bug. If you think about it, when you use FLASHW_STOP, the flashing does in fact stop, but the point of the flashing is to get the user's attention. The button stays coloured because the user still may not have looked down and discovered *which* window was trying to get her attention. Keeping the button coloured keeps that information available. |
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast with the procedural programming style that emphasizes changes in state. |
|python|macos|fonts|photoshop| |
The **trunk** is the development line that holds the latest source code and features. It should have the latest bug fixes in it as well as the latest features added to the project.
The **branches** are usually used to do something away from the trunk (or other development line) that would otherwise *break* the build. New features are often built in a branch and then merged back into the trunk. Branches often contain code that are not necessarily approved for the development line it branched from. For example, a programmer could try an optimization on something in a branch and only merge back in the development line once the optimization is satisfactory.
The **tags** are snapshots of the repository at a particular time. No development should occur on these. They are most often used to take a copy of what was released to a client so that you can easily have access to what a client is using.
Here's a link to a very good guide to repositories:
- [Source Control HOWTO][1]
The articles in Wikipedia are also worth reading.
[1]: http://www.ericsink.com/scm/source_control.html |
I have seen RSS used to syndicate gas prices from a service for a specific zip code. |
[Tomcat Documentation][1]
DBCP uses the Jakarta-Commons Database Connection Pool. It relies on number of Jakarta-Commons components:
* Jakarta-Commons DBCP
* Jakarta-Commons Collections
* Jakarta-Commons Pool
This attribute may help you out.
removeAbandonedTimeout="60"
I'm using the same connection pooling stuff and I'm setting these properties to prevent the same thing it's just not configured through tomcat.
But if the first thing doesn't work try these.
testWhileIdle=true
timeBetweenEvictionRunsMillis=300000
[1]: http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html |
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for hosting your OpenGL graphics then [FLTK](http://www.fltk.org/) is a nice choice. Otherwise, for rendering the GUI directly in OpenGL their are libraries like [Crazy Eddie's GUI](http://www.cegui.org.uk/wiki/index.php/Main_Page) that do just that and provide lots of [skinnable](http://en.wikipedia.org/wiki/Skinnable) [widgets](http://en.wikipedia.org/wiki/GUI_widget) that you won't have to reinvent. The window and OpenGL context could then be provide with a portable library like [SDL](http://www.libsdl.org/). |
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for hosting your OpenGL graphics then [FLTK](http://www.fltk.org/) is a nice choice. Otherwise, for rendering the GUI directly in OpenGL their are libraries like [Crazy Eddie's GUI](http://www.cegui.org.uk/wiki/index.php/Main_Page) that do just that and provide lots of [skinnable](http://en.wikipedia.org/wiki/Skinnable) [widgets](http://en.wikipedia.org/wiki/GUI_widget) that you won't have to reinvent. The window and OpenGL context could then be provide with a portable library like [SDL](http://www.libsdl.org/).
**EDIT**: Now that I've gone back and taken at look your [other post](http://stackoverflow.com/questions/7489/how-do-i-make-a-gui) I think I have a better understanding of what you are asking. For a GUI on an embedded system like the Nintendo DS, I would consider using an "immediate mode" GUI. [Jari Komppa](http://sol.gfxile.net/who.html) has a [good tutorial about them](http://sol.gfxile.net/imgui/), but you could use a more object-oriented approach with C++ than the C code he presents. |
Passing multidimensional arrays as function arguments in C |
|c| |
In C can I pass a multidimensional array to a function as a single argument ? |
In C can I pass a multidimensional array to a function as a single argument when I don't know what the dimensions of the array are going to be ? |
In C can I pass a multidimensional array to a function as a single argument when I don't know what the dimensions of the array are going to be ?
In addition my multidimensional array may contain types other than strings. |
Caching |
|language-agnostic|caching| |
Currently I know of only two ways to cache data (I use PHP but I assume that the same will apply to most languages).
1. Save the cache to a file
2. Save the cache to a large DB field
Are there any other (perhaps better) ways of caching or is it really just this simple? |
You can also cache in memory which is much more efficient. Try [memcached][1].
[1]: http://www.danga.com/memcached/ |
I've used WiX a little bit before, and generally I found that it's great once you figure out what to do but there is a steep learning curve. If you spend a solid day going over the WiX tutorial you should be be able to get 80% of your setup working.
[link text][1]
[1]: http://wix.sourceforge.net/tutorial.html |
I don't have it entirely implemented yet, but this web site seems to give a [good walkthrough][1] of setting up the certificates and the code.
[1]: http://developers.de/blogs/damir_dobric/archive/2006/08/01/897.aspx |
Hanselminutes
.NET Rocks,
StackOverflow,
SoftwareEngeneeringRadio
Are my favorites.
TWiT and CrankyGeeks I listen to if i want a laugh or get mad, they are horrible. |
Sybase Anywhere has a OLEDB provider for VFP tables. It states in the page that the server supports 64 bit Windows, don't know about the OLEDB provider:
> Support 64-bit Windows and Linux Servers
> In order to further enhance scalability, support for the x86_64 architecture was added to the Advantage Database Servers for Windows and Linux. On computers with an x86_64 processor and a 64 bit Operating System the Advantage Database Server will now be able to use memory in excess of 4GB. The extra memory will allow more users to access the server concurrently and increase the amount of information the server can cache when processing queries.
I didn't try it by myself, but [some people](http://weblogs.foxite.com/andykramek/archive/2008/01/05/5530.aspx) of the VFP newsgroups reports that it works OK.<p>
[Link to the Advantage Server / VFP Page](http://devzone.advantagedatabase.com/dz/webhelp/Advantage9.0/Advantage.htm) |
There's a [good explanation here](http://codebetter.com/blogs/karlseguin/archive/2008/04/27/foundations-of-programming-pt-7-back-to-basics-memory.aspx) for .NET.
A lot of people are surprise that reference objects are actually passed by value (in both C# and Java). It's a copy of a stack address. This prevents a method from changing where the object actually points to, but still allows a method to change the values of the object. In C# its possible to pass a reference by reference, which means you can change where an actual object points to. |
We're currently using Lucene 2.1.0 for our site search and we've hit a difficult problem: one of our index fields is being ignored during a targeted search. Here is the code for adding the field to a document in our index:
// Add market_local to index
contactDocument.add(
new Field(
"market_local"
, StringUtils.objectToString(
currClip.get(
"market_local"
)
)
, Field.Store.YES
, Field.Index.UN_TOKENIZED
)
);
Running a query ( * ) against the index will return the following results:
Result 1:
title: Foo Bar
market_local: Local
Result 2:
title: Bar Foo
market_local: National
Running a targeted query:
+( market_local:Local )
won't find any results.
I realize this is a highly specific question, I'm just trying to get information on where to start debugging this issue, as I'm a Lucene newbie.
--------
**UPDATE**
Installed Luke, checking out latest index... the Field *market_local* is available in searches, so if I execute something like:
market_local:Local
The search works correctly (in Luke). I'm going over our Analyzer code now, is there any way I could chalk this issue up to the fact that our search application is using Lucene 2.1.0 and the latest version of Luke is using 2.3.0? |
I believe *message* is used in smalltalk.
Java, C# etc. tend to use *method* or *instance method*. |
I've found this to be a language and programming-paradigm thing. One paradigm β OOP β refers to objects with member methods, which conceptually are how you send messages to those objects (this view is reflected in UML, for example).
Another paradigm β functional β may or may not involve classes of objects, but functions are merely the atomic unit of work.
In structured programming, you had sub-routines (notice that the prefix "sub" implies structure).
In imperative programming (which overlaps with structured quite a lot, but a slightly different way of looking at things), you have a more formulaic view of the world, and so 'functions' represent some operation (often mathematical).
All you have to do to not sound like a rube is to use the terminology used by the language reference for the language you're using. |
By the way: most programming languages would disagree with Python and give the result `-2`. Depending on the interpretation of modulus this is correct. However, the most agreed-upon mathematical definition states that the modulus of *a* and *b* is the (strictly positive) rest *r* of the division of *a* / *b*. More precisely, 0 <= *r* < *b* by definition. |
I am pretty sure (but a quick [Wikipedia][1] check seems to confirm this) that the `message passing' terminology comes from the Smalltalk community. I think it is more or less equivalent to a method call.
[1]: http://en.wikipedia.org/wiki/Smalltalk#Messages |
Here's some simplified definitions:
<strong>methods/subroutines/voids:</strong>
perform an action
<strong>functions:</strong>
perform an action and return a value
<strong>events:</strong>
are called when an object is acted upon
<strong>handlers:</strong>
are the functions/methods that handle the events
***
*PS: this is a perfect example of why SO should support DL/DT/DD tags.* |
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for hosting your OpenGL graphics then [FLTK](http://www.fltk.org/) is a nice choice. Otherwise, for rendering the GUI directly in OpenGL their are libraries like [Crazy Eddie's GUI](http://www.cegui.org.uk/wiki/index.php/Main_Page) that do just that and provide lots of [skinnable](http://en.wikipedia.org/wiki/Skinnable) [widgets](http://en.wikipedia.org/wiki/GUI_widget) that you won't have to reinvent. The window and OpenGL context could then be provide with a portable library like [SDL](http://www.libsdl.org/).
**EDIT**: Now that I've gone back and taken at look your [other post](http://stackoverflow.com/questions/7489/how-do-i-make-a-gui) I think I have a better understanding of what you are asking. For a GUI on an embedded system like the Nintendo DS, I would consider using an "immediate mode" GUI. [Jari Komppa](http://sol.gfxile.net/who.html) has a [good tutorial about them](http://sol.gfxile.net/imgui/), but you could use a more object-oriented approach with C++ than the C code he presents. The site is currently down, but a [cached version is available](http://64.233.167.104/search?q=cache:_3_VX9rbzfkJ:sol.gfxile.net/imgui/+sol+immediate+mode+gui&hl=en&ct=clnk&cd=2&gl=us&client=firefox-a). |
I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g [Qt](http://trolltech.com/), [wxWidgets](http://www.wxwidgets.org/), [GTK](http://www.gtk.org/), etc). If you just need a quick simple GUI for hosting your OpenGL graphics then [FLTK](http://www.fltk.org/) is a nice choice. Otherwise, for rendering the GUI directly in OpenGL their are libraries like [Crazy Eddie's GUI](http://www.cegui.org.uk/wiki/index.php/Main_Page) that do just that and provide lots of [skinnable](http://en.wikipedia.org/wiki/Skinnable) [widgets](http://en.wikipedia.org/wiki/GUI_widget) that you won't have to reinvent. The window and OpenGL context could then be provide with a portable library like [SDL](http://www.libsdl.org/).
**EDIT**: Now that I've gone back and taken at look your [other post](http://stackoverflow.com/questions/7489/how-do-i-make-a-gui) I think I have a better understanding of what you are asking. For a GUI on an embedded system like the Nintendo DS, I would consider using an "immediate mode" GUI. [Jari Komppa](http://sol.gfxile.net/who.html) has a [good tutorial about them](http://sol.gfxile.net/imgui/), but you could use a more object-oriented approach with C++ than the C code he presents. |
http://www.immobilienscout24.com/
they use RSS feeds for updates on your search. |
I mainly code ColdFusion or PHP (and JS/CSS/xHTML), but have dabbled in a bit of RoR. RadRails/Apatana has been great for me, because it's built on Eclipse, which I was already using for my other work. It also integrates with Subversion via the Subclipse plugin.
The Eclipse platform is so extensible that it's worth investing a bit of time in to learn, but then again I like having a single IDE rather than having to switch between different apps.
I briefly looked at Netbeans, but TBH Eclipse just felt better for me, and Aptana itself is great when you come to do anything in JavaScript.
YMMV... |
[Cramer's Rule](http://en.wikipedia.org/wiki/Cramers_rule)
and
[Gaussian Elimination](http://en.wikipedia.org/wiki/Gaussian_elimination)
are two good, general-purpose algorithms (also see [Simultaneous Linear Equations](http://en.wikipedia.org/wiki/Simultaneous_linear_equations)). If you're looking for code, check out [GiNaC](http://en.wikipedia.org/wiki/GiNaC), [Maxima](http://maxima.sourceforge.net/), and [SymbolicC++](http://issc.uj.ac.za/symbolic/symbolic.html) (depending on your licensing requirements, of course). |
[Cramer's Rule](http://en.wikipedia.org/wiki/Cramers_rule)
and
[Gaussian Elimination](http://en.wikipedia.org/wiki/Gaussian_elimination)
are two good, general-purpose algorithms (also see [Simultaneous Linear Equations](http://en.wikipedia.org/wiki/Simultaneous_linear_equations)). If you're looking for code, check out [GiNaC](http://en.wikipedia.org/wiki/GiNaC), [Maxima](http://maxima.sourceforge.net/), and [SymbolicC++](http://issc.uj.ac.za/symbolic/symbolic.html) (depending on your licensing requirements, of course).
EDIT: I know you're working in C land, but I also have to put in a good word for [SymPy](http://code.google.com/p/sympy/) (a computer algebra system in Python). You can learn a lot from its algorithms (if you can read a bit of python). Also, it's under the new BSD license, while most of the free math packages are GPL. |
What source control system are you using?
Almost all of them have some form of $ Id $ tag that gets expanded when the file is checked in.
I usually use some form of hackery to display this as the version number.
The other alternative is use to use the date as the build number: 080803-1448 |
Not efficient at all, but you can use a regular expression to test for prime numbers.
^1?$|^(11+?)\1+$/ |
Absolutely, especially dealing with lots of these permutations/combinations I can definitely see that the first pass would be an issue.
Interesting implementation in python, though I wrote a nice one in C and Ocaml based on "Algorithm 515" (see below). He wrote his in Fortran as it was common back then for all the "Algorithm XX" papers, well, that assembly or c. I had to re-write it and make some small improvements to work with arrays not ranges of numbers. This one does random access, I'm still working on getting some nice implementations of the ones mentioned in Knuth 4th volume fascicle 2. I'll an explanation of how this works to the reader. Though if someone is curious, I wouldn't object to writing something up.
/** [combination c n p x]
* get the [x]th lexicographically ordered set of [p] elements in [n]
* output is in [c], and should be sizeof(int)*[p] */
void combination(int* c,int n,int p, int x){
int i,r,k = 0;
for(i=0;i<p-1;i++){
c[i] = (i != 0) ? c[i-1] : 0;
do {
c[i]++;
r = choose(n-c[i],p-(i+1));
k = k + r;
} while(k < x);
k = k - r;
}
c[p-1] = c[p-2] + x - k;
}
~"Algorithm 515: Generation of a Vector from the Lexicographical Index"; Buckles, B. P., and Lybanon, M. ACM Transactions on Mathematical Software, Vol. 3, No. 2, June 1977. |
I would be wary of automatically upcasing all whitespace-preceded-words in scenarios where I would run the risk of attracting the fury of nitpickers.
I would at least consider implementing a dictionary for exception cases like articles and conjunctions. Behold:
> "Beauty and the Beast"
And when it comes to proper nouns, the thing gets much uglier. |
A functional language (ideally) allows you to write a mathematical function, i.e. a function that takes *n* arguments and returns a value. If the program is executed, this function is evaluated.
A procedural language, on the other hand, performs a series of *sequential* steps, where the functional program would be nested. There's a way of transforming sequential logic into functional logic called [continuation passing style](http://en.wikipedia.org/wiki/Continuation_passing_style).
As a consequence, a purely functional program always yields *the same value* for an input, and the order of evaluation is not well-defined; which means that uncertain values like user input or random values are hard to model in purely functional languages. |
I wouldn't bother looking for ASP.NET stuff specifically (probably won't find any anyways). Finding a good CSS theme easily can be used in ASP.NET.
Here's some sites that I love for CSS goodness:
<http://www.freecsstemplates.org/>
<http://www.oswd.org/>
<http://www.openwebdesign.org/>
<http://www.styleshout.com/>
<http://www.freelayouts.com/>
|
I have used [Open source Web Design][1] in the past. They have quite a view css themes, don't know about ASP.Net
[1]: http://www.oswd.org/ |
We are heavily using [EasyMock][1] and EasyMock Class Extension at work and are pretty happy with it. It basically gives you everything you need. Take a look at the documentation, there's a very nice example which shows you all the features of EasyMock.
[1]: http://easymock.org |
While I obviously cannot speak to the specifics of your application, in most instances you should not tie your caching implementation to some perceived expectation for how the GC will work. As Stu mentions, calling GC.Collect() will force a collection (with overloads for a specific generation) but more often than not doing so will result in worse performance than just letting the GC manage itself.
If you do find (after doing some real performance testing) that you need to interact with the GC make sure you take into account the different types of GC's that the framework currently has (see [here][1] for more information).
[1]: http://blogs.msdn.com/maoni/archive/2004/09/25/234273.aspx |
I would use [Stax][1] to parse XML, it's fast and easy to use. I've been using it on my last project to parse XML files up to 24MB. There's a nice introduction on [java.net][2], which tells you everything you need to know to get started.
[1]: http://jcp.org/en/jsr/detail?id=173
[2]: http://today.java.net/pub/a/today/2006/07/20/introduction-to-stax.html |
I've been using the [Data Transfer Objects][1] pattern (originally from the Java world, I believe), with a SqDataReader to populate collections of DTOs from the data layer for use in other layers of the application.
The DTOs themselves are very lightweight and simple classes composed of properties with gets/sets. They can be easily serialized/deserialized, and used for databinding, making them pretty well suited to most of my development needs.
[1]: http://en.wikipedia.org/wiki/Data_Transfer_Object |
This is what I use to read from a Magtek card reader:
//Open file on the device
deviceHandle =
CreateFile (deviceDetail->DevicePath,
GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
Try those options and see if you can at least read from the device.
I understand your pain here... I found the USB HID documentation to be basically wrong in several places. |
Assuming you're joining on columns with no duplicates, which is by far the most common case:
- An inner join of A and B gives the result of A intersect B, i.e. the inner part of a venn diagram intersection.
- An outer join of A and B gives the results of A union B, i.e. the outer parts of a venn diagram union.
**Examples**
Suppose you have two Tables, with a single column each, and data as follows:
A B
- -
1 3
2 4
3 5
4 6
Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.
**inner join**
An inner join using either of the equivalent queries gives the intersection of the two tables, i.e. the two rows they have in common.
select * from a INNER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b;
a | b
--+--
3 | 3
4 | 4
**left outer join**
A left outer join will give all rows in A, plus any common rows in B. (I guess the name means, "the left part of a full outer join"?)
select * from a LEFT OUTER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b(+);
a | b
--+-----
1 | null
2 | null
3 | 3
4 | 4
**full outer join**
A full outer join will give you the union of A and B, i.e. All the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.
select * from a FULL OUTER JOIN b on a.a = b.b;
a | b
-----+-----
1 | null
2 | null
3 | 3
4 | 4
null | 6
null | 5
|
Assuming you're joining on columns with no duplicates, which is by far the most common case:
- An inner join of A and B gives the result of A intersect B, i.e. the inner part of a venn diagram intersection.
- An outer join of A and B gives the results of A union B, i.e. the outer parts of a venn diagram union.
**Examples**
Suppose you have two Tables, with a single column each, and data as follows:
A B
- -
1 3
2 4
3 5
4 6
Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.
**inner join**
An inner join using either of the equivalent queries gives the intersection of the two tables, i.e. the two rows they have in common.
select * from a INNER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b;
a | b
--+--
3 | 3
4 | 4
**left outer join**
A left outer join will give all rows in A, plus any common rows in B. (I guess the name means, "the left part of a full outer join"?)
select * from a LEFT OUTER JOIN b on a.a = b.b;
select a.*,b.* from a,b where a.a = b.b(+);
a | b
--+-----
1 | null
2 | null
3 | 3
4 | 4
**full outer join**
A full outer join will give you the union of A and B, i.e. All the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.
select * from a FULL OUTER JOIN b on a.a = b.b;
a | b
-----+-----
1 | null
2 | null
3 | 3
4 | 4
null | 6
null | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.