text

DOM: fetch all text nodes in the document (PHP)

I've have the following (PHP) code that traverses an entire DOM document to get all of the text nodes. It's a bit of a ugly solution, and I'm sure there must be a better way... so, is there? $skip = false; $node = $document; $nodes = array(); while ($node) { if ($node->nodeType == 3) { $nodes[] = $node; } if (!$skip && ...

Change text cursor (caret) colour in Cocoa?

Hello! Does anyone know if it’s possible to change the text cursor (aka caret) colour in Cocoa? I need to create a textfield which would change its caret colour depending on something. Please notice that I’m not talking about the mouse pointer picture, but the blinking vertical line which helps you understand where you are typing :-) ...

Changing lines in a file

I'd like to replace (as an example) the text of lines 5-15 in a file with the text from lines 6-15 from another file. But I'd like to do this over about 2000 files, and would rather not have to do it manually. I could script something in perl, but I'd like to try to do it with any built-ins possible. ...

Compute numerical values from a space separated text file, within a range of lines

I have a file with the following values: for 3 threads: Average time taken for API1 is: 19097.7 nanoseconds. Average time taken for API2 is: 19173.1 nanoseconds. Average time taken for API2 is: 19777.7 nanoseconds. Average time taken for API2 is: 19243.1 nanoseconds. Average time taken for API1 is: 19737.7 nanoseconds. Average time take...

How can I access the actual text that is displayed in a DIV when using CSS style overflow: hidden?

I have the following content DIV on my page, which displays dynamic text: <div id="someContent"> </div> It uses the following CSS to cut off additional text: #someContent { height: 200px; width: 200px; overflow: hidden; } If I load this text into the DIV: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praes...

Why does casting text as varchar without specifying a length truncate the text at 30 characters?

I was searching an MS-SQL Server 2005 database to make sure that a certain text field was always a multiple of 8 in length. When I ran the following query, I got that several rows were of length 30. But when I investigated those records, I found that they were longer than that. select distinct len(cast(textfield as varchar)) from tabl...

SQL query engine for text files on Linux?

We use grep, cut, sort, uniq, and join at the command line all the time to do data analysis. They work great, although there are shortcomings. For example, you have to give column numbers to each tool. We often have wide files (many columns) and a column header that gives column names. In fact, our files look a lot like SQL tables. ...

Creating nice pdfs with ruby

I would like to create pdfs with ruby. One special need is embedding a picture into text (or a textblock), which means I need to be able to let the text flow around the image. E.g. the image should be in the rigth upper corner and the text should start left of the image and continue after the image by using the whole width of the page. H...

Are digits represented in sequence in all text encodings?

This question is language agnostic but is inspired by these c/c++ questions. How to convert a single char into an int Char to int conversion in C Is it safe to assume that the characters for digits (0123456789) appear contigiously in all text encodings? i.e. is it safe to assume that '9'-'8' = 1 '9'-'7' = 2 ... '9'-'0' = 9 in all...

Working with large text snippets in Java source

Are there any good ways to work with blocks of text (Strings) within Java source code? Many other languages have heredoc syntax available to them, but Java does not. This makes it pretty inconvenient to work with things like tag libraries which output a lot of static markup, and unit tests where you need to assert comparisons against blo...

cocos2d: LabelAtlas text alignment?

Is there a way in cocos2d 0.7.1 to specify the text alignment in a LabelAtlas? I'm using a LabelAtlas for a score (displayed in the upper right corner) but when the score goes above 10, the second digit is cut off. I can implement code to detect that and move the LabelAtlas, but is there a way to have cocos2d do it for me? Thanks. ...

In Javascript, can I get the exact coordinates on text cluttered with tags (childNodes everywhere?)

Hi, See the example below: it shows lines of text in a table (there's a good reason for this, but that's not the issue here). Basically, all I need is a function that alert()'s me the perfect coordinates of the text selection when I click on the link. By perfect coordinates, I mean: line number of the start of the selection, line numbe...

How to embed a text link in an image ?

How do I embed text in an image? The embedded text should be hyperlinked to an URL. The use case is like having an image with a link that says 'Click here' which opens a new page. ...

Remove lines from file

Hey Guys, I am doing some text processing on a unix system. I have access to the command line on this machine and it has Python, Perl and the default text processing progams installed, awk etc. I have a text file that looks like below: 2029754527851451717 2029754527851451717 2029754527851451717 2029754527851451717 202975452785145...

What is the best way to draw text on an HTML canvas element?

The canvas element unfortunately doesn't handle text well. There are a bunch of approaches (see e.g. http://canvaspaint.org/blog/2006/12/rendering-text/ ), but they mostly seem like hacks. What can I do that is cross-platform and gives me the most flexibility to make my fonts like how I want? ...

Truncating long strings with CSS: feasible yet?

Is there any good way of truncating text with plain HTML and CSS, so that dynamic content can fit in a fixed-width-and-height layout? I've been truncating server-side by logical width (i.e. a blindly-guessed number of characters), but since a 'w' is wider than an 'i' this tends to be suboptimal, and also requires me to re-guess (and kee...

SMS archive solutions

Hi all, Does anyone know if there are any SMS archive solution out there? The idea is to archive your sms message from your phone to a central location. ...

Algorithm for estimating text width based on contents

This is a long shot, but does anyone know of an algorithm for estimating and categorising text width (for a variable width font) based on its contents? For example, I'd like to know that iiiiiiii is not as wide as abcdefgh, which in turn is not as wide as WWWWWWWW, even though all three strings are eight characters in length. This is a...

How do I handle/edit large amount of text in WPF?

What would be a good approach to display and edit large amount of unformatted text (just like notepade does) using WPF? Loading a big string into a TextBox makes the UI unresponsive. The overall performance is not nearly comparable with TextBox Controls of previous Microsoft UI Frameworks. What options do I have to solve this problem. ...

PDF to Text conversion when uploading to IIS Web App?

I've investigated several C# DLL's and have not found any that work especially well. My requirements are: PDF documents are uploaded via an ASPX page. Text needs to be extracted and stored in the DB with the PDF. Solution cannot have additional cost for replicating the Web App (so if I know it will work, a fixed-fee solution would be...