小编puk*_*puk的帖子

将"jj"映射到<ESC>会导致光标尝试向前跳跃

.vimrc在迁移到Windows后开始调试我的文件(请参阅此处的相关问题).在Ubuntu中,我将jj键组合映射到ESC这样

inoremap jj <Esc>                       
Run Code Online (Sandbox Code Playgroud)

虽然按下jj确实有助于我退出插入模式,但它会尝试向前搜索10或15个字符(我实际上没有计算过).以下是一些可能相关的其他事情,

  • ;进入命令模式,但q;没有给我命令模式历史记录,我必须输入q:
  • 我已将SHIFT+ J(<S-J>)映射到先前的缓冲区命令(bp).它也会左/右移动光标.类似地,SHIFT+ K(<S-K>)映射到bn
  • jk命令行为正常
  • 它似乎只适用于触发ENTERESC按钮的情况

这是我的vimrc文件,以防万一

" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","

" Swap ; and :  Convenient.
nnoremap …
Run Code Online (Sandbox Code Playgroud)

vim windows-7

2
推荐指数
1
解决办法
1035
查看次数

PostgreSQL外键引用继承表

我试图通过继承来简化我的代码。这是我现在拥有的

DROP SCHEMA PUBLIC CASCADE;
CREATE SCHEMA PUBLIC;

CREATE TABLE student(
   id SERIAL PRIMARY KEY,
   age INT
);

CREATE TABLE engineer(
   id SERIAL PRIMARY KEY,
   studentId INT REFERENCES student (id),
   friend INT REFERENCES student (id)
);

CREATE TABLE artist(
   id SERIAL PRIMARY KEY,
   studentId INT REFERENCES student (id),
   friend INT REFERENCES student (id)
);

INSERT INTO student (age) VALUES (20); --Trying to remove this
INSERT INTO student (age) VALUES (21); --Trying to remove this
INSERT INTO engineer (studentId) VALUES (1); …
Run Code Online (Sandbox Code Playgroud)

sql postgresql inheritance

2
推荐指数
1
解决办法
1689
查看次数

如何将输出重定向到文件和STDOUT并在出错时退出

我可以像错误一样退出程序

ls /fake/folder || exit 1
Run Code Online (Sandbox Code Playgroud)

我可以将输出重定向到文件和STDOUT,就像这样

ls /usr/bin | tee foo.txt
Run Code Online (Sandbox Code Playgroud)

但我不能这样做

ls /fake/folder | tee foo.txt || exit 1
Run Code Online (Sandbox Code Playgroud)

因为我得到的输出tee而不是ls

如何将输出重定向到文件和STDOUT 在出错时退出

bash shell stdout pipe

2
推荐指数
1
解决办法
94
查看次数

HTML Canvas剪辑和putImageData

我有一个画布,背景中有一个大图像,前面有一个较小的圆形图像.我通过使用这样的剪辑实现了这种圆形图像效果

ctx.save();

ctx.beginPath();
ctx.arc(x,y,r,0,Math.PI*2, true);   
ctx.closePath();
ctx.clip();

ctx.drawImage(img,x-r,y-r,2*r,2*r);     // draw the image
ctx.restore();
Run Code Online (Sandbox Code Playgroud)

然后我想旋转圆形图像,所以我使用第二个上下文并像这样旋转和重绘

backCanvas=document.createElement('canvas');    
backContext=backCanvas.getContext('2d');
backCanvas.width=w;
backCanvas.height=h;

backContext.translate(w/2,h/2);
backContext.rotate(a);

backContext.drawImage(img,-w/2,-h/2,w,h);

var imgData=backContext.getImageData(0,0,w,h);

ctx.save();

ctx.beginPath();
ctx.arc(x,y,r,0,Math.PI*2, true);   
ctx.closePath();
ctx.clip();
ctx.putImageData(imgData,x,y);

ctx.restore();
Run Code Online (Sandbox Code Playgroud)

但是发生的事情是黑色透明背景从后画布复制而且剪辑无法"剪辑"它.

任何帮助,将不胜感激

html canvas clip

1
推荐指数
1
解决办法
3885
查看次数

AJAX vs PHP提交表单

我最初有一个表单设置(CSS样式已被删除)

<form name="LoginForm" action="login.php" method="post">

<input name="email" id="email" type="text"></input>

<input name="password" id="password" type="password"></input>

<input name="login" id="login" type="submit" value="Login"></input>
</form>
Run Code Online (Sandbox Code Playgroud)

并且它工作正常,login.php将验证用户的信用.但是,该方法需要页面重定向.我正在尝试将代码迁移到AJAX,以便我可以查询登录详细信息并保留在页面内.[编辑]这里是我使用的AJAX对象

function Ajax(){
    this.xmlhttp=null;  //code below will assign correct request object
    if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari
        this.xmlhttp=new XMLHttpRequest();
    }
    else{       // code for IE6, IE5
        this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    this.stateChangeFunction=function(){};  //user must reimplement this

    var that=this;
    this.xmlhttp.onreadystatechange=function(){ //executes the appropriate code when the ready state and status are correct
        if (this.readyState==4 && this.status==200){
            that.stateChangeFunction();     
        }
        else{
            dump("Error"); …
Run Code Online (Sandbox Code Playgroud)

html php forms ajax

1
推荐指数
1
解决办法
3189
查看次数

html画布像素缓冲区

我不知道正确的术语,但在GTK中我认为它被称为像素缓冲区.您可以将全部或部分绘图区域复制到pixbuf,然后将pixbuf转储回屏幕,而不是通过再次渲染整个事物.我正在实施一个菜单栏,菜单栏下降并遮挡下面的所有东西.但是,绘制整个画布需要几秒钟,所以我想知道是否有正确的方法来复制将被下拉菜单遮挡的所有内容,然后当关闭下拉菜单时,将其重绘到屏幕上.我想这可以通过context.getImageData()函数完成,但我已经读过它效率非常低.

html canvas redraw

1
推荐指数
1
解决办法
568
查看次数

Dojo类加载顺序

我试图从纯JavaScript迁移到Dojo,我遇到了一些问题.我当前的问题是import语句的顺序.在纯JavaScript我能有一个文件,A.js这样

function(name){
    this.name=name;
}
Run Code Online (Sandbox Code Playgroud)

和文件B.js一样

function(name,age){
    this.A=A;
    A(name);
    this.age=age;
}
Run Code Online (Sandbox Code Playgroud)

然后我可以在加载这两个文件index.html可以是本身

<html>
    <head>
    <script LANGUAGE="javascript" SRC="A.js"></script>
    <script LANGUAGE="javascript" SRC="B.js"></script>
    </head>
</html>
Run Code Online (Sandbox Code Playgroud)

或者作为

<html>
    <head>
    <script LANGUAGE="javascript" SRC="B.js"></script>
    <script LANGUAGE="javascript" SRC="A.js"></script>
    </head>
</html>
Run Code Online (Sandbox Code Playgroud)

但如果我转换A.jsB.jsdojo这样

dojo.declare("A", null, {
    constructor: function(name){
        this.name=name;
    }
});
Run Code Online (Sandbox Code Playgroud)

等等

dojo.declare("B",[A],
    constructor:function(name,age){
        this.age=age;
    }
});
Run Code Online (Sandbox Code Playgroud)

那我只能加载脚本index.html这样

<html>
    <head>
    <script LANGUAGE="javascript" SRC="A.js"></script>
    <script LANGUAGE="javascript" SRC="B.js"></script>
    </head>
</html>
Run Code Online (Sandbox Code Playgroud)

如果我B.js之前尝试加载A.js,它会抱怨A.js不存在.有没有办法解决?

javascript dojo

1
推荐指数
1
解决办法
1473
查看次数

重新实现javascript删除关键字

很多人都知道,javascript delete关键字使用起来有点棘手(见这里).是否可以重新实施或修改它?我有一个多次引用的对象,我想删除首先删除所有引用.像这样:

var oj = new OrangeJuice();
var juice = oj;
var beverage = oj;
var allRightSunnyD = oj;
delete oj; //I want this to delete the actual object
Run Code Online (Sandbox Code Playgroud)

我不希望垃圾收集器找到所有的引用,让我说我知道引用的位置,我只想重新实现删除也去掉果汁,饮料和allRightSunnyD.我意识到我可以实现一个OrangeJuice.delete()功能,但我想知道是否有办法正确实现.就像javascript onDelete()在删除对象之前调用回调函数一样.

javascript extend

1
推荐指数
1
解决办法
3278
查看次数

C系统无法运行hello world

任何人都可以告诉我为什么这个systemshell hello world命令的简单C 调用不起作用:

MWE:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

main( int argc, char *argv[] )
{
   char *str;

   str = strdup ( "hello" );
   printf ( "echo %s\n", str );
   system ( ( "echo %s\n", str ) );

   return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

回声你好

sh:1:你好:没找到

c shell process

1
推荐指数
1
解决办法
93
查看次数

Vim n用于"部分"单词搜索的键?

如果我在源文件中实现了这样的C++函数:

void ClassName::foo ()
{
   if ( true)
   {
      while ( true )
      {
         fork ();
         1 / 0;
      }
      foo ();
   }
}
Run Code Online (Sandbox Code Playgroud)

然后我把光标放在最后一行的第3行foo ()并按下*,它抱怨"搜索命中BOTTOM,继续在TOP".换一种说法:

/\<foo\>
Run Code Online (Sandbox Code Playgroud)

不匹配

ClassName::foo
Run Code Online (Sandbox Code Playgroud)

无论如何都要覆盖默认搜索功能

vim

1
推荐指数
1
解决办法
477
查看次数

标签 统计

html ×3

canvas ×2

javascript ×2

shell ×2

vim ×2

ajax ×1

bash ×1

c ×1

clip ×1

dojo ×1

extend ×1

forms ×1

inheritance ×1

php ×1

pipe ×1

postgresql ×1

process ×1

redraw ×1

sql ×1

stdout ×1

windows-7 ×1