Is this considered good programming practise in C++:
try {
// some code
}
catch(someException) {
// do something
}
catch (...)
{
// left empty <-- Good Practise???
}
"8,5,,1,4,7,,,,7,,1,9,3,6,,,8,6,3,9,,2,5,4,,,,,3,2,,,7,4,1,1,,4,,6,9,,5,,,,5,,,1,,6,3,,,6,5,,,,7,4,,1,7,6,,,,8,,5,,,7,1,,3,9,"
I'm doing a programming challenge where i need to parse this sequence into my sudoku script.
Need to get the above sequence into 8,5,0,1,4,7,0,0,0,7,0,1,9,3,6,0,0,8.........
I tried re but without success, help is appreciated, thanks.
Hello,
I know it's not really a programming question but I don't know where to ask it.
Should i use a captcha in my sign up form ?
Facebook, twitter, foursquare, gowalla etc... don't use one (or not a visible one). Is there an invisible catpcha on theses sites ?
Thank you
I need to read a Excel 2007 xlsx file in a java application. Does anyone know of a good api to accomplish this task?
Thanks in advance for any advice given.
-MrPortico
I am working remotely on a Windows Server via Remote Desktop Connection and some process has hung the server. I looked up how to bring up the Task Manager remote (equivalent of locally doing CTRL+ALT+DEL) and I found CTRL+ALT+END and it doesn't seem to work.
I tried logging off and logging back on and the system is still up (tried earlier seeing the properties of My Comptuer, FYI).
Does anyone know how I can escape this 'hindrance' and star fresh?!?
I'm trying to find out what a binormal is in the context of graphics programming but coming up short, I saw on a site that the binormal was being calculated as the corss between the normal and tangent (i.e. cross(normal, tangent)), is this the correct way to calculate a binormal?
I'm looking for an ExecutorService implementation that can be provided with a timeout. Tasks that are submitted to the ExecutorService are interrupted if they take longer than the timeout to run. Implementing such a beast isn't such a difficult task, but I'm wondering if anybody knows of an existing implementation.
I've got a very large and mature C++ code base that I'm trying to use SWIG on to generate a C# interface for. I cannot change the actual C++ code itself but we can use whatever SWIG offers in the way of extending/updating it. I'm facing an issue where a function C++ is written as such:
A* SomeClass::next(A*)
The caller might do something like:
A* acurr = 0;
while( (acurr = sc->next(acurr)) != 0 ){
if( acurr isoftype B ){
B* b = (B*)a;
...do some stuff with b..
}
elseif( acurr isoftype C )
...
}
Essentially, iterating through a container elements that depending on their true type, do something different. The SWIG generated C# layer for the "next" function unfortunately does the following:
return new A();
So the calling code in C# land cannot determine if the returned object is actually a derived class or not, it actually appears to always be the base class (which does make sense). I've come across several solutions:
Use the %extend SWIG keyword to add a method on an object and ultimately call dynamic_cast. The downside to this approach, as I see it, is that this requires you to know the inheritance hierarchy. In my case it is rather huge and I see this is as a maintenance issue.
Use the %factory keyword to supply the method and the derived types and have SWIG automatically generate the dynamic_cast code. This appears to be a better solution that the first, however upon a deeper look it still requires you to hunt down all the methods and all the possible derived types it could return. Again, a huge maintenance issue. I wish I had a doc link for this but I can't find one. I found out about this functionality by looking through the example code that comes with SWIG.
Create a C# method to create an instance of the derived object and transfer the cPtr to the new instance. While I consider this clumsy, it does work. See an example below.
public static object castTo(object fromObj, Type toType)
{
object retval = null;
BaseClass fromObj2 = fromObj as BaseClass;
HandleRef hr = BaseClass.getCPtr(fromObj2);
IntPtr cPtr = hr.Handle;
object toObj = Activator.CreateInstance(toType, cPtr, false);
// make sure it actually is what we think it is
if (fromObj.GetType().IsInstanceOfType(toObj))
{
return toObj;
}
return retval;
}
Are these really the options? And if I'm not willing to dig through all the existing functions and class derivations, then I'm left with #3? Any help would be appreciated.
I'd like to set some autorun task to Eclipse, or simply set the command with path, how to run my Apache while starting Eclipse.
My point is, that I don't want webserver (Apache) to be running after OS start, because it's useless load for my laptop. I usually want webserver use when I start Eclipse, so I think there could be an option, when can I do that to save my OS load and my time.
How can I set this?
Im using c#.net windows form application. I have a xml file. I have loaded the node names of that xml file into a treeview. Now my task is , when I select a particular node from the treview, I should be able to display its attributes in a combo box. Please help.
A friend of mine, who studies game development at an university, is currently learning programming in OpenCL. What would be a simple project that teaches the most important aspects of OpenCL and can be finished within about 50 - 100 hours?
I wrote a sparse vector class (see #1, #2.)
I would like to provide two kinds of iterators:
The first set, the regular iterators, can point any element, whether set or unset. If they are read from, they return either the set value or value_type(), if they are written to, they create the element and return the lvalue reference. Thus, they are:
Random Access Traversal Iterator and Readable and Writable Iterator
The second set, the sparse iterators, iterate over only the set elements. Since they don't need to lazily create elements that are written to, they are:
Random Access Traversal Iterator and Readable and Writable and Lvalue Iterator
I also need const versions of both, which are not writable.
I can fill in the blanks, but not sure how to use boost::iterator_adaptor to start out.
Here's what I have so far:
template<typename T>
class sparse_vector {
public:
typedef size_t size_type;
typedef T value_type;
private:
typedef T& true_reference;
typedef const T* const_pointer;
typedef sparse_vector<T> self_type;
struct ElementType {
ElementType(size_type i, T const& t): index(i), value(t) {}
ElementType(size_type i, T&& t): index(i), value(t) {}
ElementType(size_type i): index(i) {}
ElementType(ElementType const&) = default;
size_type index;
value_type value;
};
typedef vector<ElementType> array_type;
public:
typedef T* pointer;
typedef T& reference;
typedef const T& const_reference;
private:
size_type size_;
mutable typename array_type::size_type sorted_filled_;
mutable array_type data_;
// lots of code for various algorithms...
public:
class sparse_iterator
: public boost::iterator_adaptor<
sparse_iterator // Derived
, array_type::iterator // Base (the internal array) (this paramater does not compile! -- says expected a type, got 'std::vector::iterator'???)
, boost::use_default // Value
, boost::random_access_traversal_tag? // CategoryOrTraversal
>
class iterator_proxy {
???
};
class iterator
: public boost::iterator_facade<
iterator // Derived
, ????? // Base
, ????? // Value
, boost::?????? // CategoryOrTraversal
> {
};
};
I've been teaching myself object oriented programming and I'm thinking about a situation where I have an object "Transaction", that has quite a few properties to it like account, amount, date, currency, type, etc.
I never plan to mutate these data points, and calculation logic will live in other classes. My question is, is it poor Python design to instantiate thousands of objects just to hold data? I find the data far easier to work with embedded in a class rather than trying to cram it into some combination of data structures.
Whatever it be, caffeine, tobacco, whatever, list your programming performance enhancing drug of choice.
Do you feel like you NEED it to be most effective at your work?
Vote up someone if they answered the same as you.
Hi there
I'm programming against a Webservice that requires the amount of ticks (for the current time) (A single tick represents one hundred nanoseconds or one ten-millionth of a second) since 1.1.0001 (midnight).
what is the easiest way to get the amount of ticks from an NSDate Object?
thanks for your help
Hello,
I'm new to PHP programming and I wanted to know that is it possible to handle PHP events as we do in ASP.NET
I mean I've got a img and I want to perform some task on click event of this img.
I know how to do it in ASP.NET but please help me in context of PHP
Thanks,
GURU
I am passing in command line arguments to my Lisp program and they are formatted like this when they hit my main function:
("1 1 1" "dot" "2 2 2")
I have a dot function and would like to call it directly from the argument, but first I must strip the " characters.
I tried variations of this function:
(defun remove-quotes (s)
(setf (aref s 0) '""))
to no avail, Lisp complains that "" is not a member of base-char.
Thanks!
This isn't a question about code, but it's programming related. We have a web app that's ready for beta testing. Has anyone noticed any difference between open beta vs. closed beta in terms of the quality or quantity of feedback the testers give or any other factors?
That is detect when the user makes web part changes and selects to exit editing the page.
I want to be able to capture a page event, then create a SharePoint task to instruct a user to translate that page to another language (note that MOSS and variations is not an option because the client wants to use the free version of SharePoint). So the customer wants essentially the same WSS site in multiple languages.
Hello (this is a long post sorry),
I am writing a application in ASP.NET MVC 2 and I have reached a point where I am receiving this error when I connect remotely to my Server.
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
I thought I had worked around this problem locally, as I was getting this error in debug when site was redirected to a baseUrl if a subdomain was invalid using this code:
protected override void Initialize(RequestContext requestContext)
{
string[] host = requestContext.HttpContext.Request.Headers["Host"].Split(':');
_siteProvider.Initialise(host, LiveMeet.Properties.Settings.Default["baseUrl"].ToString());
base.Initialize(requestContext);
}
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (Site == null)
{
string[] host = filterContext.HttpContext.Request.Headers["Host"].Split(':');
string newUrl;
if (host.Length == 2)
newUrl = "http://sample.local:" + host[1];
else
newUrl = "http://sample.local";
Response.Redirect(newUrl, true);
}
ViewData["Site"] = Site;
base.OnActionExecuting(filterContext);
}
public Site Site
{
get
{
return _siteProvider.GetCurrentSite();
}
}
The Site object is returned from a Provider named siteProvider, this does two checks, once against a database containing a list of all available subdomains, then if that fails to find a valid subdomain, or valid domain name, searches a memory cache of reserved domains, if that doesn't hit then returns a baseUrl where all invalid domains are redirected.
locally this worked when I added the true to Response.Redirect, assuming a halting of the current execution and restarting the execution on the browser redirect.
What I have found in the stack trace is that the error is thrown on the second attempt to access the database.
#region ISiteProvider Members
public void Initialise(string[] host, string basehost)
{
if (host[0].Contains(basehost))
host = host[0].Split('.');
Site getSite = GetSites().WithDomain(host[0]);
if (getSite == null)
{
sites.TryGetValue(host[0], out getSite);
}
_site = getSite;
}
public Site GetCurrentSite()
{
return _site;
}
public IQueryable<Site> GetSites()
{
return from p in _repository.groupDomains
select new Site
{
Host = p.domainName,
GroupGuid = (Guid)p.groupGuid,
IsSubDomain = p.isSubdomain
};
}
#endregion
The Linq query ^^^ is hit first, with a filter of WithDomain, the error isn't thrown till the WithDomain filter is attempted.
In summary: The error is hit after the page is redirected, so the first iteration is executing as expected (so permissions on the database are correct, user profiles etc) shortly after the redirect when it filters the database query for the possible domain/subdomain of current redirected page, it errors out.
I need to programatically encrypt a directory of files, like in a .zip or whatever. Preferably password protected obviously.
How can I accomplish this, and WHAT IS the BEST encryption way to do it, if applicable?
Programming language doesn't matter. I am dictioned in all syntax.
I've created a Zend_Application using the zf tool that's bundled with Zend Framework (1.96, if that matters)
What at the rules for formatting action names and how those action names get translated into into URL paths, and where in the Framework codebase does this happen?
I ask because I tried to create an action like
public function createFooAction()
{
}
and it wouldn't load with a URL like
http://example.com/controller/createFoo
BUT, the following did work
public function createfooAction()
{
}
http://example.com/controller/createfoo
I also know non-alphanumeric characters get treated differently, and I'd like to know the base rules I'm dealing with.
hello
i never worked with web programming and
i've been asked lately to write a web-based software to manage assets and tasks. to be used by more than 900 persons
what are the recommended modules , frameworks , libraries for this task.
and it will be highly appreciated if you guyz recommend some books and articles that might help me. thanks in advance
Hi.In my WinApp I am using DataGridView in tab control.When I am adding to table in another tab ,it does not update datagridview. After closing and re-opening app it shows new value.I connected my table with wizard to datagridview. And in my Button action after adding new value to data base I used
this.BindingContext[this.dataGridView1.DataSource].EndCurrentEdit();
this.dataGridView1.Refresh();
this.dataGridView1.Parent.Refresh();
but it is not working.I am using mysql.
Obviously Python is more user friendly, a quick search on google shows many results that say that, as Python is byte-compiled is usually faster. I even found this that claims that you can see an improvement of over 2000% on dictionary-based operations.
What is your experience on this matter? In which kind of task each one is a clear winner?