truncate

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...

What's the best way to update data in a table while it's in use without locking the table?

I have a table in a SQL Server 2005 Database that is used a lot. It has our product on hand availability information. We get updates every hour from our warehouse and for the past few years we've been running a routine that truncates the table and updates the information. This only takes a few seconds and has not been a problem, until no...

Truncating Ruby Time objects efficiently

Hi, I am trying to come up with an efficient method for truncating Ruby Time objects according to a given resolution. class Time def truncate resolution t = to_a case resolution when :min t[0] = 0 when :hour t[0] = t[1] = 0 when :day t[0] = t[1] = 0 t[2] = 1 when :month t[0] ...

How to truncate a datetime in SQL Server

What's the best way to truncate a datetime value (as to remove hours minutes and seconds) in SQL Server 2008? For example: declare @SomeDate datetime = '2009-05-28 16:30:22' select trunc_date(@SomeDate) ----------------------- 2009-05-28 00:00:00.000 Thanks ...

Truncate last part of an NSString

This should be a simple one, but my brains are a bit hazy today: I have an NSString * myOldString = @"This is a string (and this part is between brackets)" Now, I want to truncate the string in such a way, that basically everything between the brackets, including the brackets, is truncated. More precisely: I don't care what is happen...

Is there a way to TRUNCATE most tables in a MySQL schema?

I'm looking for a query (or series of) to TRUNCATE all tables in my schema (which has a few hundred tables) EXCEPT for a 4 specific ones. How might I go about doing that? Thanks! ...

How can I display short URLs without file extention?

Hi, I've looked around but wasn't able to find what I was looking for. I'm looking for a way to automatically create short URLs displayed in the browser, not using a URL shortener. Basically I would like to re-create something like this: idzr.org/1ptb I upload screenshots to my server with "GrabUp" on a regular basis but it creates r...

python truncate after a hundreds?

How can truncate an input like 315.15321531321 I want to truncate all the values after the hundredths position so it becomes 315.15 how do i do that? ...

What is a unix command for deleting the first N characters of a line?

For example, I might want to: tail -f logfile | grep org.springframework | <command to remove first N characters> I was thinking that 'tr' might have the ability to do this but I'm not sure. Thanks in advance stackoverflow geniuses! -- LES ...

Truncate words function in javascript (studying dojo's code)

A 'truncate words' would take a string of words and return only the first, let's say, 10 words. In dojo (javascript library) they have such a function, whose code is this: truncatewords: function(value, arg){ // summary: Truncates a string after a certain number of words // arg: Integer // Number of words to tru...

Truncating a file while it's being used (Linux)

I have a process that's writing a lot of data to stdout, which I'm redirecting to a log file. I'd like to limit the size of the file by occasionally copying the current file to a new name and truncating it. My usual techniques of truncating a file, like cp /dev/null file don't work, presumably because the process is using it. Is th...

Access Query Memo field truncation due to "distinct"

I am having problems running a query without either truncating the note field in NotesTbl or returning repeated entries. UID is not unique for AccessTbl. When I leave out "distinct" notes will return multiple times because I am joining with AccessTbl on a non-distinct condition. When I use distict, the note field is trunctated because...

Truncating Query String & Returning Clean URL C# ASP.net

I would like to take the original URL, truncate the query string parameters, and return a cleaned up version of the URL. I would like it to occur across the whole application, so performing through the global.asax would be ideal. Also, I think a 301 redirect would be in order as well. ie. in: www.website.com/default.aspx?utm_source=twi...

C# Process.Start parameters truncated

Hi, I've got truncated parameters when passing very long file paths. I need to start a program and pass it everything via command params - sometimes it just truncates the command. It does it globally - so it's not only a problem for each parameter but for whole. edit: The problem is probably the limit on the command line length as monk...

How do I create a new Joda DateTime truncated to the last hour?

I am pulling timestamps from a file that I want to create a new DateTime for, but I want to create the DateTime at the floor of the hour (or any Joda Period will do). How Can I do this? ...

Using hibernate/hql to truncate a table?

What is the recommended way to truncate a table using hibernate/hql? I've tried this: Query query = session.createQuery("truncate table MyTable"); query.executeUpdate(); But it didn't work (truncate doesn't seem do be documented anywhere in hql...) ...

Rails: Smart text truncation

I wonder if there's a plugin to enable a sort of smart truncation. I need to truncate my text with a precision of a word or of a sentence. For example: Post.my_message.smart_truncate( "Once upon a time in a world far far away. And they found that many people were sleeping better.", :sentences => 1) # => Once upon a time in a w...

Truncate a string straight javascript

I'd like to truncate a dynamically loaded string using straight javascript. It's a url, so there are no spaces, and I obviously don't care about word boundaries, just characters. Here's what I got: var pathname = document.referrer; //wont work if accessing file:// paths document.getElementById("foo").innerHTML = "<a href='" + pathna...

How to insert a space in a sentence if it runs across the screen?

Hi, I have a user control in my asp.net web project. It displays the title of a blog post. If the title is too long, it will stretch the wrapped table and ruin the page layout. Is there a way I can chop the text after 40 characters IF the text doesn't contain a space in it? How would I check for the existance of a space anywhere, an...

mysql Truncate table vs delete

We are about to deploy some code that truncates tables in our mysql 4 database. We are doing this to get around some replication 'weirdness' that we are seeing (and is widely known) with temp tables. My knee-jerk reaction when I saw this in a code review was "no", but I'm having trouble backing it up. So, the question is: am I just ov...