小编Seg*_*ult的帖子

在eclipse中的<head> </ head>中缩进标签

<head>...</head>当我按下Ctrl + Shift + F时,我需要Eclipse(Kepler)缩进html标签

目前,这个:

<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
function func() {
console.log("Hello world");
}
</script>
</head>
<body>
<p onclick="func()">Some text</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我按下组合键时变成这个.

<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
    function func() {
        console.log("Hello world");
    }
</script>
</head>
<body>
  <p onclick="func()">Some text</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我需要<head>...</head>缩进内部的所有内容以及其中的所有标记<html>...</html>.

理想情况下这样:

function func() {
  console.log("Hello world");
}
Run Code Online (Sandbox Code Playgroud)
<html>

<head>
  <title>Insert title here</title>
  <script type="text/javascript">
    /* function */
  </script>
</head>

<body>
  <p onclick="func()">Some text</p> …
Run Code Online (Sandbox Code Playgroud)

html eclipse indentation auto-indent

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

为什么Lua REPL要求你在前面添加一个等号以获得一个值?

我需要帮助关闭此功能,如果可能的话,从交互模式或我会发疯.如果你想要这个值,REPL会在每个表达式之前坚持等号.我发现这非常刺激和不直观.更糟糕的是,如果你错误地忘记了等号,它会带你进入这个辅助提示,只有输入一个会导致错误的表达式才能退出.

*** str="This is some string"
*** str
>>
>>
>> =
>>
>> =str
stdin:6: unexpected symbol near '='
*** =str
This is some string
*** #str
stdin:1: unexpected symbol near '#'
*** =#str
19
***
*** 545+8
stdin:1: unexpected symbol near '545'
*** =545+8
553
*** 
Run Code Online (Sandbox Code Playgroud)

我需要一个使用REPL的教训:
有没有办法摆脱等号,这样它的行为就像其他REPL一样?
如果不做我做的事情,你如何退出辅助提示?

lua read-eval-print-loop

10
推荐指数
2
解决办法
3086
查看次数

为什么在函数的任何表达式中使用...会导致ara的值在Lua中为nil?

function tell(num,...)
    print("value of implicit table:",arg)
    --print("value of implicit table:",...)
    select(1,arg)
    --select(1,...)
end
tell(12,43,12,55)
Run Code Online (Sandbox Code Playgroud)

为什么是它使用...在表达式引起的值arg
进行nil,例如用print("value of implicit table:",...)select(1,...)

lua arguments function variadic-functions

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

为什么在lisp中数十亿这么慢?

(defun billion-test () 
  (setq i 0) 
  (loop while (< i 100) do 
    (setq i (+ i 1)))) 
(billion-test) 
(print "done")
Run Code Online (Sandbox Code Playgroud)

我有上面的Lisp代码,简单地循环到十亿.问题是它真的很
慢.比我写过的任何琐碎程序都要慢.这些是
我使用的解释器运行的时间(gcl和clisp).

                       Compiled  Uncompiled
GNU Common Lisp(gcl)    270-300s  900-960s
Clisp                   280-300s  960-1647s
Run Code Online (Sandbox Code Playgroud)

我使用这个Python代码来计算时间Clisp和使用系统时间进行近似
,gcl因为您无法从命令提示符运行它.

import sys
import time
import os

start=time.time()
os.system(" ".join(sys.argv[1:]))
stop=time.time()

print "\n%.4f seconds\n"%(stop-start)
Run Code Online (Sandbox Code Playgroud)

以下是与其他语言的while循环的比较:

Kawa scheme     220.3350s
Petite chez     112.827s
C#              1.9130s
Ruby            31.045s
Python          116.8600s        113.7090s(optimized)
C               2.8240s          0.0150s(optimized)
lua             84.6970s
Run Code Online (Sandbox Code Playgroud)

我的假设是,loop while <condition> doLisp …

lisp windows common-lisp while-loop

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

处理Lua中的CR行结尾

我正在尝试CR使用file:read似乎由于某种原因起作用的方法读取带行结尾的文件.文件内容如下所示:

ABCDEFGH
12345
##
6789
Run Code Online (Sandbox Code Playgroud)

我希望它与所有类型的行结尾一致.每次我尝试读取文件时,它都会返回文件中的最后一行与前一行中任何尾随字符的连接,这些字符的位置大于最后一行中最后一个字符的位置.这就是我的意思:

> file=io.open("test.lua", "rb")
> function re_read(openFile)
     openFile:seek("set");
     return openFile:read("*a");
  end
> =re_read(file) -- With CR
67895FGH

> =re_read(file) -- With CRLF
ABCDEFGH
12345
##
6789

> =re_read(file) -- with LF
ABCDEFGH
12345
##
6789

>
Run Code Online (Sandbox Code Playgroud)

如您所见,返回的字符串5是前一行中的最后一个字符串加上FGH第一行的加号.将跳过任何比最后一行短的行.

我的目标是使用该file:line()方法逐行读取文件.我希望如果file:read找到"修复",那么它可以应用于file:lines().

lua file line-endings

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

PostgreSQL中的PGDATA是什么

PostgreSQL的新手,在Oracle中经验丰富。试图了解什么是PGDATA。

阅读它,它似乎包含创建初始数据库集群所需的内容。

我安装了,并且正在从Oracle转换一些数据。安装默认情况下将PGDATA放入的路径在一个很小的文件系统中。因此,我希望将其移动到更大的文件系统中。

所以我的问题是:

  1. 这类似于Oracle数据字典吗?
  2. 我是否需要将所有应用程序数据放入该路径中,还是最好的做法是不这样做?
  3. 我知道我可以使用默认值并在更大的文件系统中创建一个新的数据库,但是应该吗?

谢谢

database postgresql

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

如何从南非以外的非洲国家/地区支付 Chrome 网上应用店开发者注册费?

我想用我的借记卡支付 5 美元的费用,但邮政编码只允许一个非洲国家(SA)。有没有解决的办法?我来自肯尼亚。

允许的国家/地区列表

google-chrome-extension chrome-web-store

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

让IPython使用我原来的启动脚本

我为python设置了一个startup.py脚本,它导入了常用的模块,如re,os和sys.然而,Ipython似乎没有在启动时运行它,因为尝试使用其中一个模块会引发错误.

startupscript ipython

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

lua中string.format函数的布尔插值字符是什么

我正在寻找一个布尔插值字符string.format(如标题所示).
我想要一些可以这样工作的东西:

print(string.format("nil == false: %b",(nil==false))
Run Code Online (Sandbox Code Playgroud)

%b只是一个占位符,你会得到一个错误.我正在寻找'b'.我不能这样做:

print("nil == false: " .. (nil==false))
Run Code Online (Sandbox Code Playgroud)

因为布尔值不能与字符串连接.我可以:

val=(nil==false)
if val==false then truth="false" else truth="true" end
print("nil==false: ".. truth)
Run Code Online (Sandbox Code Playgroud)

但是工作太多了.

string lua boolean

3
推荐指数
2
解决办法
5785
查看次数

如何在Lisp中的变量中存储函数并使用它

我想print在变量中存储一个函数,这样我就可以输入一些简短的函数p,例如:
In Scheme:

(define print display)
(print "Hello world\n")
;; alternate way
(define print 'display)
((eval print) "Hello world\n")
Run Code Online (Sandbox Code Playgroud)

同样的方法似乎不起作用Common Lisp:

(defvar p 'print)
;;(print (type-of p))
(p "Hello world") ;; Attempt 1
((eval p) "Hello world") ;; >> Attempt 2
((eval (environment) p) "Hello world") ;; Attempt 3
Run Code Online (Sandbox Code Playgroud)

Attempt 1上面得到这个错误:

*** - EVAL: undefined function P
Run Code Online (Sandbox Code Playgroud)

而这与Attempt 23Clisp:

*** - EVAL: (EVAL (ENVIRONMENT) P) …
Run Code Online (Sandbox Code Playgroud)

scheme eval common-lisp first-class-functions lisp-2

2
推荐指数
3
解决办法
2634
查看次数

有没有时候`is`运算符可以在Python中用两个相似的字符串返回false?

我有一些代码,我是编辑,使其一目了然更容易理解,我想我应该改变所有的char=="|"char is "|".我知道看起来我太过分了,但看起来确实好看了.无论如何,我pycheck最后一次决定,我得到了这个警告:

Warnings...

test.py:7: Using is |, may not always work
Processing module test (test.py)...
Run Code Online (Sandbox Code Playgroud)

对于我的生活,我无法想象除非你开始冒险进行多字节字符编码,CJK字符等,如果我没有错,那么它"|" is "|"将会返回False.还有其他一些我错过的情况吗?

python string comparison

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

为什么Lua会像它那样进行比较?

如果标题没有多大意义,请原谅我.我不得不选择Is Lua的比较方式有用吗?Lua的比较.

我今天想做这样的事情:

 if currChar == nextChar == "-" then
    ... 
 end
Run Code Online (Sandbox Code Playgroud)

但它false每次都会回来:

> currChar="-"
> nextChar="-"
> =currChar == nextChar == "-"
false
>
-- All true in Python
print(5 == 5)                    -- true
print(5 == 5 == 5)               -- false
print((5 == 5) == (5 == 5))      -- true
print(5 == (4 + 1) == (6 - 1))   -- false
Run Code Online (Sandbox Code Playgroud)

我在一段时间内摆弄了这些值,并发现由于某种原因,Lua从左到右成对地比较值:

> = 52 > 3 > 2
stdin:1: attempt to compare …
Run Code Online (Sandbox Code Playgroud)

comparison lua

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

在Clojure中以功能方式重写此修剪功能

我有这个功能(这个程序的摘录),我想以更吸引人/功能/惯用的方式重写.
它应该从s表达式中删除任何不必要的空格.

(defn trim 
  " Trim whitespace from code:
        (trim (trim \" d ' (    print   (   +   1   1 )  )\")
    ==> d '(print (+ 1 1))
    The replaced string is passed repeatedly to every call.
    Functional version
"
  [string] 
  (clojure.string/replace
   (clojure.string/replace
    (clojure.string/replace
     (clojure.string/replace
      (clojure.string/replace
       (clojure.string/replace
        (clojure.string/replace
         (clojure.string/replace
          (clojure.string/replace
           (clojure.string/replace
            string #"([^\\(\[{@~`'])(\(|\[|\{)" "$1 $2")
           #"(\)|\]|})(\[|\(|\{)" "$1 $2")
          #"[ \t]*(\)|\]|\})" "$1")
         #"[ \t]{2,}" " ")
        #"(\)|\]|\})[ \t]*(?=(\)|\]|\}))" "$1")
       #"(\(|\[|\{)[ \t]*(?=(\(|\[|\{))" "$1")
      #"^[ \t]*" "")
     #"(\\\{|\\\(|\\\[) " "$1  ") …
Run Code Online (Sandbox Code Playgroud)

string reduce clojure

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