cursor

Every new line add a numbered list UITextView

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to add a number to the beginning of each row whenever the user enters a newline. I'd like the numbers to go in order (like in an ordered list), but with my current code, if the user does not add a new line at the end but instead adds the line in the middle of the UITextView , it will continue counting from where it left off at the bottom -- meaning that the NSUInteger I made increments and doesn't take into account that the user did not make the new line at the end. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:

Flask--数据库连接池

混江龙づ霸主 提交于 2019-12-03 07:41:41
目录 数据库连接池 pymsql链接数据库 数据库连接池版 数据库连接池 pymsql链接数据库 import pymysql conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='123456', db='s8day127db') cursor = conn.cursor(cursor=pymysql.cursors.DictCursor) # cursor.execute("select id,name from users where name=%s and pwd=%s",['lqz','123',]) cursor.execute("select id,name from users where name=%(user)s and pwd=%(pwd)s",{'user':'lqz','pwd':'123'}) obj = cursor.fetchone() conn.commit() cursor.close() conn.close() print(obj) 数据库连接池版 方式一 为每个线程创建一个连接,线程即使调用了close方法,也不会关闭,只是把连接重新放到连接池,供自己线程再次使用。当线程终止时,连接自动关闭 from DBUtils.PersistentDB

Delphi How to get cursor position on a control?

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to know the position of the cursor on a TCustomControl. 回答1: You can use MouseMove event: procedure TCustomControl . MouseMove ( Sender : TObject ; Shift : TShiftState ; X , Y : Integer ); begin Label1 . Caption := IntToStr ( x ) + ' ' + IntToStr ( y ); end ; 回答2: GetCursorPos can be helpful if you can't handle a mouse event: function GetCursorPosForControl ( AControl : TWinControl ): TPoint ; var P : TPoint ; begin Windows . GetCursorPos ( P ); Windows . ScreenToClient ( AControl . Handle , P ); result := P ; end ; 回答3: If

1031 笔记

拟墨画扇 提交于 2019-12-03 07:32:51
目录 pymysql 1.基本操作 1.新建表 2.增加数据 3.删除数据 4.更改数据 5.查找数据 6.断开连接 2.sql注入 解决方法 3.创建大数据库 索引 定义 作用 实现原理 B+树的性质 B+树的分类 InnoDB存储引擎表示索引组织表,即表中数据按照主键顺序存放。而聚集索引(clustered index)就是按照每张表的主键构造一棵B+树,同时叶子结点存放的即为整张表的行记录数据,也将聚集索引的叶子结点称为数据页。聚集索引的这个特性决定了索引组织表中数据也是索引的一部分。同B+树数据结构一样,每个数据页都通过一个双向链表来进行链接。 如果未定义主键,MySQL取第一个唯一索引(unique)而且只含非空列(NOT NULL)作为主键,InnoDB使用它作为聚簇索引。 如果没有这样的列,InnoDB就自己产生一个这样的ID值,它有六个字节,而且是隐藏的,使其作为聚簇索引。 由于实际的数据页只能按照一棵B+树进行排序,因此每张表只能拥有一个聚集索引。在多少情况下,查询优化器倾向于采用聚集索引。因为聚集索引能够在B+树索引的叶子节点上直接找到数据。此外由于定义了数据的逻辑顺序,聚集索引能够特别快地访问针对范围值得查询。 索引的种类 主键索引 primary key 唯一索引 unique(name) 唯一联合索引 uniqe (name, email) 普通索引

[CF1246F]Cursor Distance

帅比萌擦擦* 提交于 2019-12-03 07:28:58
题目链接 题意 光标只能使用“跳到下一个字符 $\alpha$”和“跳到上一个字符 $\alpha$”这两种命令来移动,求一个字符串中任意两个位置间移动的最短命令长度和。 题解 首先把 操作反序 ,发现一次反操作就是把光标移动回在上一个和下一个本字符之间的任一位置。 假设 $i$ 的反操作可达区间为 $[L_i, R_i]\setminus\{i\}$, 再记 $i$ 经过至多 $k$ 次反操作可达区间为 $[L_i^{(k)}, R_i^{(k)}]$. 那么 $[L_i^{(k+1)}, R_i^{(k+1)}]=\bigcup_{L_i^{(k)} \le x \le R_i^{(k)}}[L_x, R_x]$. 考虑在 $k$ 步之内还有哪些点不能到达 ,于是答案被改写成 $\sum_{i=0}^{n-1}\sum_{k=0}^{n-1}(n-1-L_i^{(k)}+R_i^{(k)})$. 由于 $L^{(k)}$ 和 $R^{(k)}$ 互相影响,直接对着它们优化已经比较困难了。 这里的思路比较巧妙。我们考虑一下 $[L_i^{(k)}, R_i^{(k)}]=[l, r]$ 进行一轮迭代后的区间 $[L_i^{(k+1)}, R_i^{(k+1)}]=[l', r']$。我们发现:如果假设 $p_1, p_2, \ldots, p_t$

Fade out mouse cursor when inactive (with jQuery)

北城以北 提交于 2019-12-03 07:10:21
I have an element with class fade-object that fades out when the mouse is inactive for a certain amount of time (5000 milliseconds in this case), and fades back in when the mouse is moved again. This is the code I'm using: var timer; $(document).mousemove(function() { if (timer) { clearTimeout(timer); timer = 0; } $('.fade-object').fadeIn(); timer = setTimeout(function() { $('.fade-object').fadeOut() }, 5000) }) How do I make it so the mouse cursor fades in and out the same way, in sync with my fade-object div? Kaizen Programmer Set cursor: none in the CSS of the html and prevent the mousemove

How to Render a Transparent Cursor to Bitmap preserving alpha channel?

China☆狼群 提交于 2019-12-03 06:23:36
I use the code below to render a transparent icon: private void button1_Click(object sender, EventArgs e) { // using LoadCursorFromFile from user32.dll var cursor = NativeMethods.LoadCustomCursor(@"d:\Temp\Cursors\Cursors\aero_busy.ani"); // cursor -> bitmap Bitmap bitmap = new Bitmap(48, 48, PixelFormat.Format32bppArgb); Graphics gBitmap = Graphics.FromImage(bitmap); cursor.DrawStretched(gBitmap, new Rectangle(0, 0, 32, 32)); // 1. Draw bitmap on a form canvas Graphics gForm = Graphics.FromHwnd(this.Handle); gForm.DrawImage(bitmap, 50, 50); // 2. Draw cursor directly to a form canvas cursor

NSCursor: Using high-resolution cursors with cursor zoom (or retina)

微笑、不失礼 提交于 2019-12-03 05:55:46
In OSX the user can zoom the mouse cursor using the accessibility system preferences. Since Lion (I think) OSX stores the cursors as PDFs and is able to resize them smoothly. I want the same functionality for my app but using PDFs as the NSImage used for my NSCursor just scales up the rendered bitmap when a cursor zoom level larger than 1.0 is set. How do I: Use vector artwork for my cursors and have them scale correctly like the system cursors do? Detect the current cursor zoom level. Get notified when the cursor zoom level changes? Also, when using a HiDPI mode for my screen and revert the

CopyOnWriteList揭秘

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 05:35:36
List的并发容器-CopyOnWriteList Vector和SynchronizedList ArrayList是用来代替Vector,Vector是线程安全的容器,因为它在方法上都加上了synchronized同步关键字 例如: public synchronized void copyInto(Object[] anArray) { System.arraycopy(elementData, 0, anArray, 0, elementCount); } /** * Trims the capacity of this vector to be the vector's current * size. If the capacity of this vector is larger than its current * size, then the capacity is changed to equal the size by replacing * its internal data array, kept in the field {@code elementData}, * with a smaller one. An application can use this operation to * minimize the storage of a vector.

android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed even after closing cursor

谁说胖子不能爱 提交于 2019-12-03 05:29:55
There are many questions on SO about CursorWindowAllocatoinException: SQLite Android Database Cursor window allocation of 2048 kb failed Could not allocate CursorWindow Out of Memory when allocating cursors Android SQLite CursorWindowAllocationException crash All of them suggest that cursor must be closed after use. But that did not resolve my problem. Here is my code: String query = "select serial from tbl1 union select serial from tbl2 union select serial from tbl3"; SQLiteDatabase db = null; Cursor cur = null; try { SettingsDatabaseHelper dal = new SettingsDatabaseHelper( c); db = dal