I need to create a file with a list of commands (in particular key mappings) that I may sometimes need, like a .vimrc that I can execute inside Vim when I need them.
Hi guys, the question is: suppose I have an input function like sin(2-cos(3*A/B)^2.5)+0.756*(C*D+3-B) specified with a BNF, I will parse input using recursive descent algorithm, and then how can I use or change Dijkstra’s algorithm to handle this given function? After parsing this input function, I need to execute it with variable inputs, where Dijkstra’s algorithm should do the work. Thanks in advance.
EDIT: May be I should ask also: What is the best practice or data structure to represent given function?
I am using in my code at the moment a ReentrantReadWriteLock to synchronize access over a tree-like structure. This structure is large, and read by many threads at once with occasional modifications to small parts of it - so it seems to fit the read-write idiom well. I understand that with this particular class, one cannot elevate a read lock to a write lock, so as per the Javadocs one must release the read lock before obtaining the write lock. I've used this pattern successfully in non-reentrant contexts before.
What I'm finding however is that I cannot reliably acquire the write lock without blocking forever. Since the read lock is reentrant and I am actually using it as such, the simple code
lock.getReadLock().unlock();
lock.getWriteLock().lock()
can block if I have acquired the readlock reentrantly. Each call to unlock just reduces the hold count, and the lock is only actually released when the hold count hits zero.
EDIT to clarify this, as I don't think I explained it too well initially - I am aware that there is no built-in lock escalation in this class, and that I have to simply release the read lock and obtain the write lock. My problem is/was that regardless of what other threads are doing, calling getReadLock().unlock() may not actually release this thread's hold on the lock if it acquired it reentrantly, in which case the call to getWriteLock().lock() will block forever as this thread still has a hold on the read lock and thus blocks itself.
For example, this code snippet will never reach the println statement, even when run singlethreaded with no other threads accessing the lock:
final ReadWriteLock lock = new ReentrantReadWriteLock();
lock.getReadLock().lock();
// In real code we would go call other methods that end up calling back and
// thus locking again
lock.getReadLock().lock();
// Now we do some stuff and realise we need to write so try to escalate the
// lock as per the Javadocs and the above description
lock.getReadLock().unlock(); // Does not actually release the lock
lock.getWriteLock().lock(); // Blocks as some thread (this one!) holds read lock
System.out.println("Will never get here");
So I ask, is there a nice idiom to handle this situation? Specifically, when a thread that holds a read lock (possibly reentrantly) discovers that it needs to do some writing, and thus wants to "suspend" its own read lock in order to pick up the write lock (blocking as required on other threads to release their holds on the read lock), and then "pick up" its hold on the read lock in the same state afterwards?
Since this ReadWriteLock implementation was specifically designed to be reentrant, surely there is some sensible way to elevate a read lock to a write lock when the locks may be acquired reentrantly? This is the critical part that means the naive approach does not work.
Hi,
I will get a BS in Computer Science in May/2010.
I want to do a master but a have to choose between Computer Networking or Management Information System.
My plans would be to work in the area of networking.
Any suggestion?
Hi I am having two date as string , that is assigned to two labels,
one label holds current date string, that is may 29, 2010
similarly the other date will be selected by user in this same format, i need to check the user date is present, past , or future. by comparing with current date string.
please provide some sample code.
Thanks in advance.
I want to make the effect as demonstrate on this site http://dropshadow.webvex.limebits.com/ with arguments - left:0 top:0 blur:1 opacity:1 examples:engraved font:sans serif
I tried #333333 -1px -1px but seems not enough to make an inner shadow on such big font, it may be much more complex than i thought?
And worse is i'm using Cufon to replace the font but Cufon doesn't support blur of text-shadow
I am using IntelliJ IDEA 9.
In the IDEA window On the bottom right corner I see the current memory usage, typically "224M of 254M" How do I give more memory to Idea so it may read like "224M of 512M" ?
Thank you.
Refer to this post for discussions on previous versions.
Asking the question again since Visual Studio 2010 has been officially released. Does anyone have any visibility this early on as to which is better? What about any other products that may be out there? This one will probably be on my dime, so I'd like the wisdom of those with experience before pulling the trigger on a decision.
Hi,
I'm migrating to MVC 2 and I have a method:
private MvcHtmlString WriteCategoryLink(CategoryViewData category)
{
var spanBuilder = new TagBuilder("span") {InnerHtml = category.Name};
return htmlHelper.ActionLink(spanBuilder.ToString(TagRenderMode.Normal), MVC.Category.Index());
}
Problem is, that it encodes link text, but i don't want to, may be someone has a solution?
When would you NOT want to use functional programming? What is it not so good at?
I am more looking for disadvantages of the paradigm as a whole, not things like "not widely used", or "no good debugger available". Those answers may be correct as of now, but they deal with FP being a new concept (an unavoidable issue) and not any inherent qualities.
Related:
pitfalls of object oriented programming
advantages of functional programming
I have been trying to understand how this problem is solved for over a month now. I really need to come up with a general approach that works -- I'm basically the only resource who can do it. I have a theory, but I'm just not sure it's the easiest (or correct) approach and I haven't been able to find any information to support my ideas.
Here's the scenario:
1) You have a complex web application that offers secure content on a subscription basis.
2) Users are required to log in to your application with user name and password.
3) You sell to large corporations, which already have a corporate authentication technology (for example, Active Directory).
4) You would like to integrate with the corporate authentication mechanism to allow their users to log onto your Web App without having to enter their user name and password.
Now, any solution you come up with will have to provide a mechanism for:
adding new users
removing users
changing user information
allowing users to log in
Ideally, all these would happen "automagically" when the corporate customer made the corresponding changes to their own authentication.
Now, I have a theory that the way to do this (at least for Active Directory) would be for me to write a client-side app that integrates with the customer's Active Directory to track the targeted changes, and then communicate those changes to my Web App. I think that if this communication were done via Web Services offered by my web app, then it would maintain an unhackable level of security, which would obviously be a requirement for these corporate customers.
I've found some information about a Microsoft product called Active Directory Federation Service (ADFS) which may or may not be the right approach for me. It seems to be a bit bulky and have some requirements that might not work for all customers.
For other existing ID scenarios (like Athens and Shibboleth), I don't think a client application is necessary. It's probably just a matter of tying into the existing ID services.
I would appreciate any advice anyone has on anything I've mentioned here. In particular, if you can tell me if my theory is correct about providing a client-side app that communicates with server-side Web Services, or if I'm totally going in the wrong direction. Also, if you could point me at any web sites or articles that explain how to do this, I'd really appreciate it. My research has not turned up much so far.
Finally, if you could let me know of any Web applications that currently offer this service (particularly as tied to a corporate Active Directory), I would be very grateful. I am wondering if other B2B Web app's like salesforce.com, or hoovers.com offer a similar service for their corporate customers.
I hate being in the dark and would greatly appreciate any light you can shed ...
Jeremy
I'm currently reading the book Professional Enterprise .NET and I've noticed this warning in some of the example programs:
'NUnit.Framework.Assert.IsInstanceOfType(System.Type, object)' is obsolete
Now I may have already answered my own question but, to fix this warning is it simply a case of replacing Assert.IsInstanceOfType() with Assert.IsInstanceOf()? For example this:
Assert.IsInstanceOfType(typeof(ClassName), variableName);
would become:
Assert.IsInstanceOf(typeof(ClassName), variableName);
Here is my code... basically it finds any page-NUMBER- within a variable and then replaces it with a page url from an array
$content_text = preg_replace("/page-(\d+)-/sie", '$pageurl[$1]', $content_text);
It works a treat until the NUMBER it finds isn't in the array and it returns an error...
Is there another efficient way I could do this instead?
I liked my code above because it was simple but I may have to use more complex code...
I have a Asp.net MVC web application, containing mostly text. I want to put a feature into it so that admin can easily edit text/html using the web. May be some double clicking on a page and converting it into editable and save able. How can i do it? any sample code?
I need this to be done for Asp.net MVC.
thanks
I’m trying to find Microsoft CAT.NET for VS2010 and it looks like there was a beta of their 2.0 version but every link to it in Microsoft Connect is now dead. This is the most recent reference I could find: http://blogs.msdn.com/securitytools/archive/2010/02/05/how-to-use-cat-net-2-0-beta.aspx
Some references suggest it may have been rolled into FxCop. Does anyone know the status of the project?
I have been using HighCharts in my PHP website by migrating it from older charts and I am very impressed by the number of graph options and functions with this library.
However I am not able provide hyperlinks to the values of the x-axis(or y-axis) in order to navigate to another URI.
Code of Categories in this case
xAxis: {
categories: [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
]
},
Can anyone point me to an example or documentation on Highcharts if available.
Thanks
We (will) have the following architecture:
Base.war will be a self-contained spring-hibernate application
All applications will run under Glassfish, and may be clustered
E1.war will sit on top of Base.war, extending it's functionality
There could be further extensions (E2.war, E3.war, …) sitting on top of Base.war
Either wars could start a transaction, and transactions could span between wars
Without shutting down Base.war, or any other Ex.war, it should be possible to upgrade an Ey.war
Is there a solution for this with spring-hibernate-glassfish environment?
Has anyone seen any image deskew algorithms in c#? I have found:
http://www.codeproject.com/KB/graphics/Deskew_an_Image.aspx
but unfortunately, it doesn't do very much for images without text. I am specifically trying to auto deskew an image of a book with solid edges, but minimal text.
Has anyone seen anything that may be able to do this?
Hello everybody,
I'm having trouble with overloading operator() with a const version:
#include <iostream>
#include <vector>
using namespace std;
class Matrix {
public:
Matrix(int m, int n) {
vector<double> tmp(m, 0.0);
data.resize(n, tmp);
}
~Matrix() { }
const double & operator()(int ii, int jj) const {
cout << " - const-version was called - ";
return data[ii][jj];
}
double & operator()(int ii, int jj) {
cout << " - NONconst-version was called - ";
if (ii!=1) {
throw "Error: you may only alter the first row of the matrix.";
}
return data[ii][jj];
}
protected:
vector< vector<double> > data;
};
int main() {
try {
Matrix A(10,10);
A(1,1) = 8.8;
cout << "A(1,1)=" << A(1,1) << endl;
cout << "A(2,2)=" << A(2,2) << endl;
double tmp = A(3,3);
} catch (const char* c) { cout << c << endl; }
}
This gives me the following output:
NONconst-version was called - - NONconst-version was called - A(1,1)=8.8
NONconst-version was called - Error: you may only alter the first row of the matrix.
How can I achieve that C++ call the const-version of operator()? I am using GCC 4.4.0.
Thanks for your help!
Sebastian
When using Eclipse PDT with XDebug to debug a PHP web application, is there any way to open up a console window that will allow me to type in and see the value of arbitrary expressions in the current scope?
This would seem like an obvious element of the debugging environment, and I may be missing something, but the only thing resembling a console says "no consoles to display at this time"
How can I get the state of a modifier key using VB.NET on the Compact Framework, in this case Windows Mobile 6.1. I want to be able to determine if the following keys are pressed or locked:
Shift
CTRL
ALT
and for the Psion Teklogix machines
Orange
Blue
Although I may be able to work this out, if I can determine the others.
I want to create my own on-screen indicator panel and want to poll the keys, not using events.
Thanks Colin
I have three records in a table
example:
*Usernames* *email* *city*
Nick [email protected] London
Vikky [email protected] Paris
Lisa [email protected] Sydney
Now I want to get specific record keeping email ID as a key ,
SQL query may be like this
select * from table1 where email = "[email protected]"
What is the equivalent GQL query for the above ??
There's placeholder on the page that is loaded asynchronously using jQuery load method. Page URL might have anchor and I want to scroll to the anchor after content is loaded. What is the best way to do that?
Problem is similar to this: http://forum.jquery.com/topic/goto-anchor-after-load
But I don't like the solution. May be someone has and better ideas on this?
I'm trying to display frequencies within barplot ... well, I want them somewhere in the graph: under the bars, within bars, above bars or in the legend area. And I recall (I may be wrong) that it can be done in ggplot2. This is probably an easy one... at least it seems easy. Here's the code:
p <- ggplot(mtcars)
p + aes(factor(cyl)) + geom_bar()
Is there any chance that I can get frequencies embedded in the graph?
Now that I am playing with NHibernate I am getting a lot more YSODs as I am learning it however I seem to get this error sometimesafter a YSOD:
This webpage is not available
The webpage at http://localhost:49497/ might be temporarily down or it may have moved permanently to a new web address.
Error 139 (net::ERR_TEMPORARILY_THROTTLED): Unknown error.
Is there any way to disable this because I have to wait a few minutes every time and that is a pretty big killer is productivity?