entities

Use JavaScript regex to replace numerical HTML entities with their actual characters

僤鯓⒐⒋嵵緔 提交于 2019-11-29 03:47:14
问题 I'm trying to use JavaScript & regex to replace numerical HTML entities with their actual Unicode characters, e.g. foo's bar → foo's bar This is what I got so far: "foo's bar".replace(/&#([^\s]*);/g, "$1"); // "foo39s bar" All that's left to do is to replace the number with String.fromCharCode($1) , but I can't seem to get it to work. How can I do this? 回答1: "foo's bar".replace(/&#(\d+);/g, function(match, match2) {return String.fromCharCode(+match2);}) 回答2: "foo's bar".replace(/&#([^\s]*);/g

Sf2 : using a service inside an entity

烂漫一生 提交于 2019-11-28 15:36:10
i know this has been asked over and over again, i read the topics, but it's always focused on specific cases and i generally try to understand why its not best practise to use a service inside an entity. Given a very simple service : Class Age { private $date1; private $date2; private $format; const ym = "%y years and %m month" const ... // some DateTime()->diff() methods, checking, formating the entry formats, returning different period formats for eg. } and a simple entity : Class People { private $firstname; private $lastname; private $birthday; } From a controller, i want to do : $som1 =

What is the difference between “LINQ to Entities”, “LINQ to SQL” and “LINQ to Dataset”

风格不统一 提交于 2019-11-28 15:15:42
I've been working for quite a while now with LINQ. However, it remains a bit of a mystery what the real differences are between the mentioned flavours of LINQ. The successful answer will contain a short differentiation between them. What is the main goal of each flavor, what is the benefit, and is there a performance impact... P.S. I know that there are a lot of information sources out there, but I'm looking for a kind of a "cheat sheet" which instructs a newbie where to head for a specific goal. all of them are LINQ - Language Integrated Query - so they all share a lot of commonality. All

Why do we need entity objects? [closed]

元气小坏坏 提交于 2019-11-28 14:56:55
I really need to see some honest, thoughtful debate on the merits of the currently accepted enterprise application design paradigm. I am not convinced that entity objects should exist. By entity objects I mean the typical things we tend to build for our applications, like "Person", "Account", "Order", etc. My current design philosophy is this: All database access must be accomplished via stored procedures. Whenever you need data, call a stored procedure and iterate over a SqlDataReader or the rows in a DataTable (Note: I have also built enterprise applications with Java EE, java folks please

html entities in a javascript alert?

删除回忆录丶 提交于 2019-11-28 12:24:17
I have a string coming from a XML (which I can't edit) and I'd like to print it trough an alert in javascript. Example of my string: This is à string And I need to print in an alert: This is à string is there a js html decode? var encoded = "This is à string"; var decoded = $("<div/>").html(encoded).text(); alert(decoded); Imperative you could put the string in a dom element and read it out again, even without jquery: https://stackoverflow.com/a/3700369/1986499 Edit by recent demand to include some code from another SO answer: var div = document.createElement('div'); div.innerHTML = encoded;

How to make Nokogiri transparently return un/encoded Html entities untouched?

谁说胖子不能爱 提交于 2019-11-28 11:32:06
How can I use Nokogiri with having html entities (like German umlauts) untouched? I.e.: # this is fine node = Nokogiri::HTML.fragment('<p>ö</p>') node.to_s # => '<p>ö</p>' # this is not node = Nokogiri::HTML.fragment('<p>ö</p>') node.to_s # => '<p>ö</p>' # this is what I need node = Nokogiri::HTML.fragment('<p>ö</p>') node.to_s # => '<p>ö</p>' I've tried to mess with both PARSE_OPTIONS and :save_with options but could not come up with a way to have Nokogiri just transparently behave like above. Any pointers? svenfuchs Ok, my question has been answered by Aaron via twitter / gist : require

Is there a way to keep entities intact while parsing html with DomDocument?

百般思念 提交于 2019-11-28 10:20:24
I have this function to ensure every img tag has absolute URL: function absoluteSrc($html, $encoding = 'utf-8') { $dom = new DOMDocument(); // Workaround to use proper encoding $prehtml = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset={$encoding}\"></head><body>"; $posthtml = "</body></html>"; if($dom->loadHTML( $prehtml . trim($html) . $posthtml)){ foreach($dom->getElementsByTagName('img') as $img){ if($img instanceof DOMElement){ $src = $img->getAttribute('src'); if( strpos($src, 'http://') !== 0 ){ $img->setAttribute('src', 'http://my.server/' . $src); } } }

Spacy annotation tool entities indices

本秂侑毒 提交于 2019-11-28 02:14:48
How can I read my annotated data in Spacy? 1) My annotated data's form: "annotation": [ [ 79, 99, "Nom complet" ], 2) Annotated data's form in the script: "annotation": [ { "label": [ "Companies worked at" ], "points": [ { "start": 1749, "end": 1754, "text": "Oracle" } ] }, 3) How can I change this code that can read my annotated data? for line in lines: data = json.loads(line) text = data['text'] entities = [] for annotation in data['annotation']: #only a single point in text annotation. point = annotation['points'][0] labels = annotation['label'] # handle both list of labels or a single

Programmatically loading Entity classes with JPA 2.0?

戏子无情 提交于 2019-11-27 19:09:09
问题 With Hibernate you can load your Entity classes as: sessionFactory = new AnnotationConfiguration() .addPackage("test.animals") .addAnnotatedClass(Flight.class) .addAnnotatedClass(Sky.class) .addAnnotatedClass(Person.class) .addAnnotatedClass(Dog.class); Is there a way to do the same thing - programmatically loading your Entity classes - in a JPA 2.0 compliant way? The reason for this question is because I'd like to dynamically load my Entity classes, thus not necessarily programmatically. 回答1

What is
?

人走茶凉 提交于 2019-11-27 17:10:08
问题 In html made by fckeditor i find the following character: &#13; What is this character? 回答1: Looks like the ASCII code for Carriage Return, encoded as an XML character reference. 回答2: When you code in windows, and use "DOS/Windows" line endings, the your lines will end like this "\r\n". In some xhtml editors, that "\r" is illegal so te editor converts it to "&#13". 来源: https://stackoverflow.com/questions/1459170/what-is-13