Can someone give me an example of Decorator pattern in C++ ?
I have come across the Java version of it. But C++ i have found it difficult to understand the examples that are given.
Hey Guys,
i'm not very firm with preg_replace - in other Words i do not really understand - so i hope you can help me.
I have a string in a Text like this one: [demo category=1] and want to replace with the Content of Category (id=1) e.g. "This is the Content of my first Category"
This is my startpoint Pattern - that's all i have:
'/[demo\s*.*?]/i';
Hope you can help?
Thanks,
Sascha
This is probably a simple problem, but unfortunately I wasn't able to get the results I wanted...
Say, I have the following line:
"Wouldn't It Be Nice" (B. Wilson/Asher/Love)
I would have to look for this pattern:
" (<any string>)
In order to retrieve:
B. Wilson/Asher/Love
I tried something like "" (([^))]*)) but it doesn't seem to work. Also, I'd like to use Match.Submatches(0) so that might complicate things a bit because it relies on brackets...
.NET's ProviderBase was established in the 2.0 release of the .NET Framework. Have there been any new features since then that supercede or improve on this pattern that should be used as an alternative?
Fairly straightforward question:
I know that Codeigniter is a MVC framework - however what design pattern is Codeigniter using?
From first look it seems like Facade, but I could be wrong.
How do I recursively add files by a pattern (or glob) located in different directories?
For example, I'd like to add A/B/C/foo.java and D/E/F/bar.java (and several other java files) with one command:
git add '*.java'
Unfortunately, that doesn't work as expected.
A periodic computer generated message (simplified):
Hello user123,
- (604)7080900
- 152
- minutes
Regards
Using python, how can I extract "(604)7080900", "152", "minutes" (i.e. any text following a leading "- " pattern) between the two empty lines (empty line is the \n\n after "Hello user123" and the \n\n before "Regards"). Even better if the result string list are stored in an array. Thanks!
For a while I have been struggling to integrate scala with java methods that might return null. I came up with the following utility which helps a lot:
// produce an Option, nulls become None
object Maybe {
def apply[T](t:T) = if (t==null) None else Some(t)
}
Maybe(javaClass.getResultCouldBeNull()).map( result => doSomeWork(result) )
I have a few questions about this solution:
Is there a better or more standard pattern to use?
Am I duplicating something that already exists?
Does this functionality have hidden gotchas?
I can't figure out a way to define a generic pattern rule for the following kind of production with make:
require xyzzy-en_US.ext2 from xyzzy.ext0 via xyzzy.ext1.
This works:
all: xyzzy-en_US.ext2
# to be compiled from xyzzy.ext0
%.ext1 : %.ext0
# produce xyzzy.ext1
%-en_US.ext2 : %.ext1
# produce xyzzy-en_US.ext2
But how to generalize the locale part of the second rule? Or do I need to generate rules for all different locales?
Neither of these work:
%-??_??.ext2 : %.ext1
# ...
%.ext2 : $(@,%-??_??.ext2,%.ext1)
# ...
I have a class which has a list of child items. Is there a design pattern I can copy that I can apply to these classes so that I can access the parent instance from the child, and it enforces rules such as not being able to add the child to multiple parents, etc?
If I have a HTTP based RESTful service and I want to POST a search resource and use the PRG pattern for returning the URL to the search-result resource, I have to persist the search-result resource on the server.
Is this a good idea?
If I do persist the search-result resource how long is it persisted for?
Can I control this by a HTTP header of some kind?
Cheers
AWC
What would you suggest as a good and practical but simple pattern for a soloution with:
HTML + JSP (as a view/presentation)
SERVLETS (controller, request, session-handling)
EJB (persistence, businesslogic)
MySQL DB
And is it necessary to use an own layer of DAO for persistence? I use JPA to persist objects to my DB.
Should I withdraw business logic from my EJB? Sources online all tell me different things and confuses me...
Hi,
someone can tell me why this is incorrect as a singleton pattern:
class preSingleton(object):
def __call__(self):
return self
singleton = preSingleton()
a = singleton()
b = singleton()
print a==b
a.var_in_a = 100
b.var_in_b = 'hello'
print a.var_in_b
print b.var_in_a
Edit: The above code prints:
True
hello
100
thank you very much
I have this text:
Lorem ipsum dolor sit
{something.something({print.print(param1,param2)},param2)},
consectetur adipiscing elit.
Where i need a pattern that can replace everything but: something.something
The text something.something can contain [a-zA-Z.]
(I am using preg_replace)
Here is a site where you can test the code: http://www.spaweditor.com/scripts/regex/index.php
In my bash script I have an external (received from user) string, which I should use in sed pattern.
REPLACE="<funny characters here>"
sed "s/KEYWORD/$REPLACE/g"
How can I escape the $REPLACE string so it would be safely accepted by sed as a literal replacement?
NOTE: The KEYWORD is a dumb substring with no matches etc. It is not supplied by user.
Imagine a:
public class Global : IDisposable
{
private static readonly List<IDisposable> Disposables = new List<IDisposable>();
public void ApplicationStart()
{
var heavyLifter = new HeavyLifter();
Disposables.Add(heavyLifter);
}
public void Dispose()
{
Disposables.ForEach(d => d.Dispose());
}
}
I am somewhat inexperienced with IDisposable. Is this a viable pattern?
I'd like to "grab" a few hundred urls from a few hundred html pages.
Pattern:
<h2><a href="http://www.the.url.might.be.long/urls.asp?urlid=1" target="_blank">The Website</a></h2>
Hi,
I have design problem regarding async calls to method.
I'd like to know best/good pattern to call async method, which calls another async method, which calls another async method :)
In other words, I have WCF service reference created with async methods and I want to call them from another async method which is called by other async method.
All this for non blocking GUI.
Thanks!
i have something that requires a matrix of values, similar to pokemon:
i have a class object for each of the types, is there a pattern or a good way to implement this, as a middle layer or in the classes?
Recently lot of interviewers are asking
"What are the integration patterns are you familiar with?".
I know design patterns,what is integration pattern then?
How to create regex pattern which is concatenate with variable, something like this:
var test ="52";
var re = new RegExp("/\b"+test+"\b/");
alert('51,52,53'.match(re));
Thanks
In python if a string contains the following,
print valid_str
The output of this is
Record is positive in tone:
It emphasizes "what a child can do and his or her achievements, as opposed to what he or she cannot do," explains the It is useful for progress and achievements during office conferences
How to search for the pattern It is useful in the above string and if not found return something.
Thanks..
I have a Java-application that loads data from a legacy file format into an SQLite-Database using JDBC. If the database file specified does not exist, it is supposed to create a new one. Currently the schema for the database is hardcoded in the application. I would much rather have it in a separate file as an SQL-Script, but apparently there is now easy way to execute an SQL-Script though JDBC. Is there any other way or a pattern to achieve something like this?