truncate

Truncate Slow Query Log in MySQL

懵懂的女人 提交于 2019-12-04 10:32:20
问题 What's the safest way to truncate the MySQL slow query log (under Linux primarily, but Windows would be handy to know) while MySQL is running? By safe I mean: Mustn't cause any permissions problems Mustn't jump back to its original size next time its appended to 回答1: To truncate a file regardless if it is open by a running application do: > /var/logs/your.log at your shell prompt. 回答2: From here: You can move the open file, then tell mysqld to flush logs, which will open a new log. shell> cd

How to find out width of truncated UILabel text

北战南征 提交于 2019-12-04 09:31:10
问题 I have UILabel , which contains dynamic text. Sometimes text is too long to be shown and thus automagically truncated . How do I find out width of the visible part of truncated text? sizeThatFits returns length of untruncated text , so at the moment I can only detect when truncation will be done. Need to know how much is visible, including those three dots. Any tips? Clarification : when text is truncated, it's usually shorter than UILabel width. 回答1: Robot K is correct. If I was you I'd do

How to replace ellipses with fade / fading edge in textview in Android sdk?

好久不见. 提交于 2019-12-04 09:15:01
I have a list, each row in the list has text. Some of the text extends beyond the edge of the screen. I have no problem making it truncate the text and show ellipses. I have no problem to 'fade the edge of the text' however, the fade occurs at the edge of every text, not just the ones the are too large for the textview. I have searched and searched and can't find a way to, essentially, do exactly what the ellipses do but, instead of ellipses, fade the edge of the text only if it is going off the edge of the screen. Can anyone please help? FYI, right now, my text view contains: android

postgres truncate is slow

筅森魡賤 提交于 2019-12-04 00:31:13
问题 In postgres 9.2 (CentOS), TRUNCATE TABLE command occasionally took a really long time to run. One time, it took more than 1.5 hours to truncate a table with 100K records, even longer in other cases. This problem also happened when I used pgAdmin to truncate table. What is the possible cause? and how to improve the truncation performance? There is 16GB of memory on the server and shared_buffers = 1536MB 回答1: TRUNCATE has to flush shared_buffers for the table being truncated, and it has to

Why does formatting a DateTime as a string truncate and not round the milliseconds?

荒凉一梦 提交于 2019-12-03 23:55:12
问题 When a Double is formatted as a string rounding is used. E.g. Console.WriteLine(12345.6.ToString("F0")); outputs 12346 However, when a DateTime is formatted as a string truncation is used. E.g. var ci = CultureInfo.InvariantCulture; var dateTime = DateTime.Parse("2011-09-14T15:18:42.999", ci); Console.WriteLine(dateTime.ToString("o", ci)); Console.WriteLine(dateTime.ToString("s", ci)); Console.WriteLine(dateTime.ToString("yyyy-MM-hhThh:mm:ss.f", ci)); outputs 2011-09-14T15:18:42.9990000 2011

How do I truncate a list in C#?

孤街浪徒 提交于 2019-12-03 23:10:39
I know in python you can do something like myList[1:20] but is there anything similar in C#? var itemsOneThroughTwenty = myList.Take(20); var itemsFiveThroughTwenty = myList.Skip(5).Take(15); Dean Harding You can use List<T>.GetRange() : var subList = myList.GetRange(0, 20); From MSDN: Creates a shallow copy of a range of elements in the source List<T> . public List<T> GetRange(int index, int count) This might be helpful for efficiency, if you really want to truncate the list, not make a copy. While the python example makes a copy, the original question really was about truncating the list.

Is it possible to delete bytes from the beginning of a file?

北慕城南 提交于 2019-12-03 12:44:58
问题 I know that I can efficiently truncate a file and remove bytes from the end of the file. Is there a corresponding efficient way to truncate files by deleting content from the beginning of the file to a point in the middle of the file? 回答1: As I read the question you are asking to remove content from a file starting from the beginning of the file. In other words you wish to delete content at the start of the file and shift the remaining content down. This is not possible. You can only truncate

What is the best way to empty a self-referential MySQL table?

有些话、适合烂在心里 提交于 2019-12-03 11:25:05
问题 I have a self-referential MySQL table with a recursive parent_id: CREATE TABLE `recursive` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default NULL, `name` varchar(100) NOT NULL, PRIMARY KEY (`id`), KEY `data_categorysource_parent_id` (`parent_id`), CONSTRAINT `parent_id_refs_id_627b4293` FOREIGN KEY (`parent_id`) REFERENCES `data_categorysource` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 During testing, I want to empty it but TRUNCATE fails: TRUNCATE `recursive` /* SQL Error

How to generate a compiler warning/error when object sliced

南笙酒味 提交于 2019-12-03 08:51:12
问题 I want to know if it is possible to let compiler issue a warning/error for code as following: Note: 1. Yea, it is bad programming style and we should avoid such cases - but we are dealing with legacy code and hope compiler can help identify such cases for us.) 2. I prefer a compiler option (VC++) to disable or enable object slicing, if there is any. class Base{}; class Derived: public Base{}; void Func(Base) { } //void Func(Derived) //{ // //} //main Func(Derived()); Here if I comment out the

Truncate Slow Query Log in MySQL

半世苍凉 提交于 2019-12-03 05:29:45
What's the safest way to truncate the MySQL slow query log (under Linux primarily, but Windows would be handy to know) while MySQL is running? By safe I mean: Mustn't cause any permissions problems Mustn't jump back to its original size next time its appended to vartec To truncate a file regardless if it is open by a running application do: > /var/logs/your.log at your shell prompt. From here : You can move the open file, then tell mysqld to flush logs, which will open a new log. shell> cd mysql-data-directory shell> mv mysql.log mysql.old shell> mv mysql-slow.log mysql-slow.old shell>