swap

Swap alt keys functionality

我只是一个虾纸丫 提交于 2019-12-07 12:16:50
问题 I need to swap Alt keys functionality in Windows 7. A big company needs that for old people that were writing on typewriters, which had diacritic characters key on the left side, but Win7 which they are working on now has right Alt for this purpose. Two days of research brought me to a driver solution. I need source code for original Windows 7 drivers (two .sys files seem to be the keyboard drivers), and possibily to modify them in Windows DDK. Or I need to make an additional driver that

How to change span color on div hover

雨燕双飞 提交于 2019-12-07 11:48:17
问题 I am trying to change color of span on div's hover How to make the red hamburger button (which is span) to change the color to black on div's hover PS: Right now it does it on span's hover JSFiddle: https://jsfiddle.net/bjjbqct8/ .mobile-nav-toggle { height: 50px; width: 35px; margin-right: 31px; background: #ddd; display: flex; align-items: center; cursor: pointer; } .mobile-nav-toggle span, .mobile-nav-toggle span::before, .mobile-nav-toggle span::after { border-radius: 2px; content: "";

Variable swap with and without auxiliary variable - which is faster?

∥☆過路亽.° 提交于 2019-12-07 07:44:31
问题 I guess you all heard of the 'swap problem'; SO is full of questions about it. The version of the swap without use of a third variable is often considered to be faster since, well, you have one variable less. I wanted to know what was going on behind the curtains and wrote the following two programs: int main () { int a = 9; int b = 5; int swap; swap = a; a = b; b = swap; return 0; } and the version without third variable: int main () { int a = 9; int b = 5; a ^= b; b ^= a; a ^= b; return 0;

Swap two elements in jQuery

血红的双手。 提交于 2019-12-07 05:56:39
问题 I'm trying to swap two elements using up and down arrows. A JSFiddle solution would be great! My HTML: <div class="item"> <div class="content">Some text</div> <div class="move"> <div class="move-down">down</div> </div> </div> <div class="item"> <div class="content">Some other text</div> <div class="move"> <div class="move-up">up</div> <div class="move-down">down</div> </div> </div> <div class="item"> <div class="content">Some text</div> <div class="move"> <div class="move-up">up</div> <div

Swap two objects in JavaScript

折月煮酒 提交于 2019-12-07 02:30:41
问题 I have the following code: MyObject.prototype.doIt = function() { var a = this.obj1; var b = this.obj2; } How can i swap the values of this.obj1 and this.obj2 so obj1 becomes obj2 and obj2 becomes obj1. !Note: Have in mind that i am not working with primitive types. 回答1: You can swap any number of objects or literals, even of different types, using a simple identity function like this: var swap = function (x){return x}; b = swap(a, a=b); c = swap(a, a=b, b=c); This works in JavaScript because

How to swap filenames in Unix?

一曲冷凌霜 提交于 2019-12-07 02:26:04
问题 Any way to do this quickly without using a temp variable? Is there a built in function? Edit: Thanks for the answers guys. Looks like I need to clarify my question but for the most part you guys assumed correctly: There are two files and the filenames names are reversed. File A has name B-name.file File B has name A-name.file I'd like for File A to be named A-name.file and File B to be named B-name.file. I agree, the situation doesn't happen often but it just happened to me and I wanted a

std: container c++ move to front

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 20:33:22
问题 I'm looking for a std container like a std::list that can efficiently move an element to the front: a-b-c-d-e move "b" to front: a-c-d-e-b There is no such function in the std containers. Therefor, I think I must combine a remove and push_front function but has anyone can find a better idea? Thank in advance. 回答1: If you don't have to maintain the order of the other elements, then the simplest solution is doubtlessly just to swap the element you want with the first element in the container.

Swap two elements from list with specified indices

女生的网名这么多〃 提交于 2019-12-06 15:44:05
I need to swap two elements in list with specified indices using predicate: swap(List, index1, index2). I tried this way: change_value([X|List], 0, Y, [Y|List2]) :- copy_rest([X|List], List2). change_value([], P, Y, []). change_value([X|List], Pos, Y, [X|List2]) :- X \== Y, Pos > 0, NewPos is Pos - 1, change_value(List, NewPos, Y, List2). copy_rest([], []). copy_rest([X|List], [X|List2]) :- copy_rest(List, List2). Is there any better solution? Thank you very much! No need to write recursive code! Simply use the builtin predicates length/2 , same_length/2 , and append/3 like so: list_i_j

Javascript check if list is sorted after one swap

感情迁移 提交于 2019-12-06 15:39:15
I want to check if a list can be sorted by performing at most one swap operation, and I want to return true if it does. Otherwise, I want to return false . For example, the input A = [1,2,3,4,5] should result in true because it is already sorted. A = [1,2,5,4,3] should result in true because with one swap, involving 5 and 3, the list is sorted. A = [1,2,5,3,4] should result in false because it requires more than one swap to sort. My code is below. It returns true if A is already sorted, but it returns undefined if it is not sorted but can be sorted with one swap. Can someone help me find the

MySQL如何避免使用swap(1)

僤鯓⒐⒋嵵緔 提交于 2019-12-06 15:02:29
Linux有很多很好的内存、IO调度机制,但是并不会适用于所有场景。对于DBA来说Linux比较让人头疼的一个地方是,它不会因为MySQL很重要就避免将分配给MySQL的地址空间映射到swap上。对于频繁进行读写操作的系统而言,数据看似在内存而实际上在磁盘是非常糟糕的,响应时间的增长很可能直接拖垮整个系统。这篇blog主要讲讲我们作为DBA,怎样尽量避免MySQL惨遭swap的毒手。 首先我们要了解点基础的东西,比如说为什么会产生swap。假设我们的物理内存是16G,swap是4G。如果MySQL本身已经占用了12G物理内存,而同时其他程序或者系统模块又需要6G内存,这时候操作系统就可能把MySQL所拥有的一部分地址空间映射到swap上去。 cp一个大文件,或用mysqldump导出一个很大的数据库的时候,文件系统往往会向Linux申请大量的内存作为cache,一不小心就会导致L使用swap。这个情景比较常见,以下是最简单的三个调整方法: 1、/proc/sys/vm/swappiness的内容改成0(临时),/etc/sysctl.conf上添加vm.swappiness=0(永久) 这个参数决定了Linux是倾向于使用swap,还是倾向于释放文件系统cache。在内存紧张的情况下,数值越低越倾向于释放文件系统cache。 当然,这个参数只能减少使用swap的概率