Posts Tagged ‘functionality’

markup text parser like stackoverflow’s formatter in Objective-C

Sunday, August 22nd, 2010

Hi,

I’m in the process of creating a markup editor in Objective C. I require the following functionality:

  • Recognise the demarcation of a block eg **block**
  • Delete the start and end “tags” eg “The next text is **bold**” becomes “The next text is bold”
  • Determine the start and end positions of the marked-up text in the new context: “The next text is bold”

Edit:
As I may expand the syntax in the future (it will be very limited at the moment), it is important that parsing be top-down such that the start and end positions of the text always correspond with the resulting text. For this reason regex may not be the best solution.

What is the best way to do this?

is it simple to develope a face Recognition web service which uses mat lab?

Sunday, August 22nd, 2010

how complicated is it to develop a web service which works with matlab’s functionality? As my project has a limited time frame, i need to know if there will be any blocking issues.

or is it better to work with openCV?

Hide to the rest of the world some methods used only by internal classes

Sunday, August 22nd, 2010

I have one C++ object that models a real-world object in a remote system. Whenever something happens in the real-world object, the model changes to reflect it. In the same way, the model lets you interact with the real object and make it to perform several actions. It has some methods used by the internal API as well as other public methods. I don’t want to expose those API methods. I’m thinking of using the proxy pattern to hide those methods. Do you think this is a good idea? Is there some design pattern to achieve this?

As an example: let’s say there’s a robotic arm in some remote location that can be controlled by the software but can also be manually moved by some technician. It has some sensors that allow it to know which kind of object it is holding. In my proyect it’s something completely different but I use this just as an example. So I’d have one RoboticArm class which contains a RoboticHeldObject abstract class. RoboticArm let’s you know which RoboticHeldObject it is holding, appart from letting you move the arm. However, you can’t decide to pickup and release an object. This is decided by a technician operating the robot. So it would be something like:

---------------------------------------------
RoboticArm
---------------------------------------------
+ heldObject()             RoboticHeldObject*
+ moveUp()
+ moveDown()
+ setObjectReleased()
+ setObjectHeld(RoboticHeldObject*)
---------------------------------------------
- heldObject               RoboticHeldObject*
- service                  RobotService

Since the implementation is quite complex, I use an external class, RobotService which actually performs the hard work. However, it’s not an Anemic Domain Model since it’s RoboticArm who actually uses RobotService (thus has functionality) and the rest of the world doesn’t know anything about RobotService.

The question here is: setObjectRelased() and setObjectHeld() are API methods here used by RobotService only. They are called only by RobotService whenever a technician releases the object being hold by the arm or places a new object. Thus, they are called when some network event is handled by RobotService (remember the arm is in a remote location, so events are received through a network). For example:

RobotService::handleObjectReleaseEvent(event)
{
 RoboticArm *arm = correspondingRoboticArm(event);
 arm->setObjectReleased();
}

My approach to hide those methods is to rename RoboticArm to RealRoboticArm and create a RoboticArm proxy class:

---------------------------------------------
RoboticArm        (the proxy)
---------------------------------------------
+ heldObject()             RoboticHeldObject*
+ moveUp()
+ moveDown()
---------------------------------------------
- realArm                  RoboticArm*

---------------------------------------------
RealRoboticArm    (the real object)
---------------------------------------------
+ heldObject()             RoboticHeldObject*
+ moveUp()
+ moveDown()
+ setObjectReleased()
+ setObjectHeld(RoboticHeldObject*)
---------------------------------------------
- heldObject               RoboticHeldObject*
- service                  RobotService

Since RoboticArm is a proxy, RoboticArm::heldObject() would call realArm->heldObject(), RoboticArm::moveUp() realArm->moveUp() and so on.

The RobotService would have a pointer to the RealRoboticArm instance, so it could call the API methods such as setObjectReleased(). However, other parts of the application would only be able to use the methods in RoboticArm, since they don’t have a pointer to RealRoboticArm. Thus setObjectReleased() and setObjectHeld() would be effectively hidden from the audience.

I am not 100% sure if this is the proxy pattern or the adapter pattern.

Do you think this is a proper way to model such system? Is there a better pattern?

iPhone OS: Tap status bar to scroll to top doesn’t work after remove/add back

Sunday, August 22nd, 2010

Using this method to hide the status bar:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];

When setting “hidden” back to NO, the tap-to-scroll-to-top (in UIWebView, UITableView, whatever) doesn’t work any more, and requires a restart of the app to get the functionality back.

Is this a bug (I filed a rdar anyhow) or have I missed a step? Should I perhaps expect this behavior since the statusBar “loses touch” somehow with the respective view?

Windows port/implementation for GNU Pth (Gnu Portable Threads)

Sunday, August 22nd, 2010

I have inherited a pure C project that uses GNU Pth ( http://www.gnu.org/software/pth/ ) and I was hoping that there was a Windows port/implementation so I wouldn’t have to stick a whole bunch (more) conditionals into my code.

I know I am being hopeful, but is there anything that provides the exact same function signatures and functionality?

If not, is there any good pure C cross-platform multi-threading library (even if it is different than Pth)?

Edit:

I just found http://en.wikipedia.org/wiki/Netscape_Portable_Runtime#Threads and it sounds like that might be the way to go. Opinions on NSPR?

Overriding public method in dynamically loaded class with AS3 and getDefinitionByName()

Sunday, August 22nd, 2010

I have two SWFs: main.swf and external.swf. main.swf needs to access some methods in external.swf, so it loads external.swf into itself and uses getDefinitionByName(“package.Class”) to access the class and one of its methods:

var ExternalClass = getDefinitionByName("package.Class") as Class;
var ClassInstance = new ExternalClass();
var NeededFunction:Function = ClassInstance["NeededFunction"] as Function;
var response:String = NeededFunction(param);

Now, I need to extend the functionality of NeededFunction (which is a public method)… I know it’s possible to override public methods, but how would I go about this with a dynamically loaded class?

I was thinking I could do something like this, but it doesn’t work:

var ClassInstance["NeededFunction"] = function(param1:uint):String {
    var newString = "Your number is: "+param1.toString();  //New functionality
    return newString;
}

Is it possible to host an ASP.NET MVC2 website from a windows service?

Sunday, August 22nd, 2010

I have a .NET 4 application that runs as a windows service. It runs periodic tasks and provides WCF restful webservices. It already hosts a silverlight web page (via WCF) that allows a user to configure the service.

Now I have a requirement to provide information on HTML/java script pages (e.g. for browsers and platforms that don’t support Silverlight). I can serve simple HTML and javascript pages through WCF but that becomes laborious very quickly. I’d like to use MVC2.

Is it possible to provide MVC2 web pages from within a windows service? Or at least use some of the functionality provided by MVC like routing and the view engine?

Or is it more trouble than it’s worth and should I head down the path of a separate app hosted on IIS?

WPF: Check mouse movement and cursor position within mouseleftbuttondown handler

Saturday, August 21st, 2010

Hi,

I’m working on restoring the aero snap functionality in my wpf c# app which was lost when setting the resize to none. I have a rectangle at the top of my window of which I add code to its mouseleftbuttondown event.

I want to check whether the mouse has moved when the rectangle is being clicked so I can then de-maximize the window using code.

The second part of my question is how can I track whether the cursor is at the top, left or right side of the screen so I can run code for the window to maximize or to align left or right of the screen like aero snap.

Thanks,

karcuri13 on “Adding Webcam video to blog”

Saturday, August 21st, 2010

Every article I found on adding a video from a webcam to a wordpress.com blog is from 2008. Is it even possible using the base wordpress.com functionality or is some sort of plug-in needed?

Howto unescape a Java string literal in Java

Saturday, August 21st, 2010

I’m processing some Java source code using Java. I’m extracting the string literals and feed them to a function taking a String. The problem is that I need to pass the unescaped version of the String to the function (this means converting n to a newline and \ to a single and so on).

Is there a function inside the Java API that does this? If not, can I obtain such functionality from some library? Obviously the Java compiler has to do this conversion.