我真的对使用VIM感到沮丧.我只是想对vimrc文件做一些小的自定义.我做了一些小的改动,但他们并没有做我所希望的.所以,我回去并删除了我添加的行,恢复到原始文件.现在,我甚至无法进入VIM!当我从终端输入"vim filename.xxx"时,我就回到命令提示符.没有错误消息,没有文件打开,没有.好像我只是按下回车键.
我尝试卸载并重新安装VIM,但结果相同.有谁知道我能做些什么才能让VIM回到原来的状态?我正在使用Ubuntu 11.
仍然无法让这个工作.我的问题是关于如何使解密线工作.这是我写的:
class IVCounter(object):
@staticmethod
def incrIV(self):
temp = hex(int(self, 16)+1)[2:34]
return array.array('B', temp.decode("hex")).tostring()
def decryptCTR(key, ciphertext):
iv = ciphertext[:32] #extracts the first 32 characters of the ciphertext
#convert the key into a 16 byte string
key = array.array('B', key.decode("hex")).tostring()
print AES.new(key, AES.MODE_CTR, counter=IVCounter.incrIV(iv)).decrypt(ciphertext)
return
Run Code Online (Sandbox Code Playgroud)
我的错误信息是:
ValueError:'counter'参数必须是可调用对象
我只是无法弄清楚pycrypto是如何让我将第三个参数组织成新的.
有人可以帮忙吗?谢谢!
在实施以下建议后编辑新代码.还是卡住了!
class IVCounter(object):
def __init__(self, start=1L):
print start #outputs the number 1 (not my IV as hoped)
self.value = long(start)
def __call__(self):
print self.value #outputs 1 - need this to …Run Code Online (Sandbox Code Playgroud) 试图写一个计时器进行倒计时(如火箭发射:3-2-1-Go).我所拥有的似乎只执行一次.我需要它重复(几乎递归地)执行,直到值达到0.
正如您将看到的,我有各种println语句来跟踪这一进展.这是我的输出:
在Coundown构造函数中
在ActionListener中
倒计时
3
错在于我错过了以下输出:
2
1
走
这告诉我这个计时器实际上并没有倒计时.它似乎在等待一秒然后终止.
如何在定时器达到零之前调用它?谢谢!
public class StopWatch {
JFrameMath myTest;
int seconds;
/* Constructor */
public StopWatch(JFrameMath thisTest, int sec) {
myTest = thisTest;
seconds = sec;
myTest.hideTestButtons(true);
Countdown display = new Countdown(myTest);
}
}
class Countdown extends JFrame implements ActionListener {
private Timer myTimer = new Timer(250, this);
JFrameMath myTest;
public Countdown(JFrameMath thisTest) {
System.out.println("in Coundown constructor");
myTimer.setInitialDelay(1150);
myTest = thisTest;
myTimer.start();
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("in ActionListener"); …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个简短的shell脚本来打开一个新的终端窗口并启动一个程序.这是我有的:
osascript <<END
tell application "Terminal"
make new window
activate
set contents of window to "./hello" & return
end tell
END
Run Code Online (Sandbox Code Playgroud)
执行错误:终端出错:AppleEvent处理程序失败.(-10000)
谁能告诉我怎么做?在一个完美的世界中,我也喜欢这个脚本在Linux上运行,所以如果有一个可移植的方法,那就更好了.
谢谢!
我正在尝试启动一个活动,同时正确维护一个后台堆栈以允许用户使用后退按钮.为此,我正在按照谷歌的指示行事,但我无处可去.当我单击我的按钮时,没有任何反应(除了日志输出).我需要做些什么才能使此次发布成为下一个活动?
mBtnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "click");
Intent intent = new Intent(ProfileSelectActivity.this, PermissionsRequestActivity.class);
PendingIntent pendingIntent =
TaskStackBuilder.create(ProfileSelectActivity.this)
// add all of DetailsActivity's parents to the stack,
// followed by DetailsActivity itself
.addNextIntentWithParentStack(intent)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(ProfileSelectActivity.this);
builder.setContentIntent(pendingIntent);
}
});
Run Code Online (Sandbox Code Playgroud)
在我看来,最后有一条缺失的线.除了其他事情,我已经尝试过了startActivities();,startActivity();但是我的所有尝试都没有成功.
谢谢你的帮助.
编辑
试图从njzk2实施下面的建议,但我仍然感到困惑.为了添加startActivities()到TaskStackBuilder行的末尾,我必须删除对PendingIntent的任何赋值.这可能还可以.但是,在下一个活动开始后,如果我点击后退按钮,我只会看到一个白色屏幕.
TaskStackBuilder.create(ProfileSelectActivity.this)
.addNextIntentWithParentStack(intent)
.startActivities();
Run Code Online (Sandbox Code Playgroud)
我还注意到,onResume通过后退按钮返回时,我的父活动中的方法没有被调用,所以这可能只是恢复状态的问题???
我在userform上有一个文本框,我试图将用户输入限制为仅允许整数值.我能够做到这一点,但行为有点奇怪.首先,这是我的代码:
Private Sub txtAnswer_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii >= 48) And (KeyAscii <= 57) Then
Me.txtAnswer.SetFocus
Else
KeyAscii = 0
Me.txtAnswer.SetFocus
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
问题是,在用户输入值后,焦点似乎远离文本框.此外,如果用户输入整数值,则从文本框中删除该值(即输入被"吃掉").SetFocus行是我尝试使控件行为正确,但它们似乎没有任何效果.
我想要做的就是确保用户不在文本框中输入类似"r"(或任何其他非整数值)的内容.任何整数值> = 0都是完全可以接受的(包括多个数字值,如10或1000000).
谁能明白为什么我的方法不起作用?我已经尝试了几种不同的方法并且搜索了很多,但我找不到有用的东西.
谢谢
正在为我正在进行密码学的自学课程工作(我没有得到这门课程的学分).我需要在大型文件上计算哈希值,其中哈希是逐块完成的.我现在难以理解的是如何将文件分解为这些块?我正在使用python,我很新.
f = open('myfile', 'rb')
BLOCK_SIZE = 1024
m = Crypto.Hash.SHA256.new()
thisHash = ""
blocks = os.path.getsize('myfile') / BLOCK_SIZE #ignore partial last block for now
for i in Range(blocks):
b = f.read(BLOCK_SIZE)
thisHash = m.update(b.encode())
f.seek(block_size, os.SEEK_CUR)
Run Code Online (Sandbox Code Playgroud)
我接近这个吗?代码似乎一直运行直到m.update(b.encode())行执行.我不知道我是否会离开基地或做些什么来完成这项工作.任何建议表示赞赏.谢谢!
(注意:你可能会注意到,这段代码目前并没有真正产生任何东西 - 我只是设置了一些脚手架)
我正在尝试使用上次修改某些文件的日期和时间filemtime.不幸的是,这对我的所有文件都失败了.我尝试过使用完整的完整路径(例如www.mysite.com/images/file.png).我尝试过只使用扩展名(例如/images/file.png),还只使用文件名本身(file.png).什么都行不通.如何传递路径引用以便它可以找到我的文件?谢谢!
<br />n<b>Warning</b>: filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for www.mysite.com/images/hills.png in <b>D:\Hosting\11347607\html\mobile\updateImages.php</b> on line <b>20</b><br
Run Code Online (Sandbox Code Playgroud)
这是php脚本:
<?php
include '../scripts/connection.php';
//get information on this location from the database
$sql = "SELECT * FROM types";
$result = mysql_query($sql);
$array = array();
while ($row = mysql_fetch_array($result)) {
$path = $row['path'] . $row['picture_url'];
$last_mod = filemtime($path);
$this_file = array(
'filename' => $row['picture_url'],
'last_mod' => $last_mod
);
$array[$row['type']] = $this_file;
}
echo json_encode(array('result'=>'success', 'message'=>$array));
?>
Run Code Online (Sandbox Code Playgroud) Python 新手,无法让它工作。我需要生成一个 openSSL 进程。这是我所拥有的:
from subprocess import call
cmd = "openssl aes-128-cbc -d -in ciphertext -base64 -pass pass:test123"
decrypted = call(cmd)
print (decrypted)
Run Code Online (Sandbox Code Playgroud)
这甚至无法编译。我明白了TypeError: 'function' object is not subscriptable
谁能告诉我该怎么做?谢谢。
顺便说一句,当我只需在终端中输入 cmd 字符串时,它就可以正常工作。
编辑:我将行更改decrypted = call[cmd]为decrypted = call(cmd). 当我这样做时,我收到以下一系列错误:
Traceback (most recent call last):
..., line 14, in <module>
plaintext = call(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/subprocess.py", line 523, in call
with Popen(*popenargs, **kwargs) as p:
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/subprocess.py", line 817, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/subprocess.py", line 1441, …Run Code Online (Sandbox Code Playgroud) 尝试在 Android Studio 中安装并运行 GitHub Copilot 插件。我收到以下错误:
java.lang.NoSuchMethodError: 'com.intellij.ui.dsl.builder.Row com.intellij.ui.dsl.builder.Panel.row$default(com.intellij.ui.dsl.builder.Panel, javax.swing.JLabel, kotlin.jvm.functions.Function1, int, java.lang.Object)'
at com.github.copilot.github.DeviceLoginForm.descriptionPanel(DeviceLoginForm.kt:60)
at com.github.copilot.github.DeviceLoginForm.access$descriptionPanel(DeviceLoginForm.kt:18)
at com.github.copilot.github.DeviceLoginForm$deviceLoginPanel$container$1.invoke(DeviceLoginForm.kt:29)
at com.github.copilot.github.DeviceLoginForm$deviceLoginPanel$container$1.invoke(DeviceLoginForm.kt:27)
at com.intellij.ui.dsl.builder.BuilderKt.panel(builder.kt:19)
at com.github.copilot.ui.component.Panel.panelBuilder(Panel.kt:9)
at com.github.copilot.github.DeviceLoginForm.deviceLoginPanel(DeviceLoginForm.kt:27)
at com.github.copilot.github.DeviceLoginForm.<init>(DeviceLoginForm.kt:22)
at com.github.copilot.github.DeviceLoginDialog.createCenterPanel(DeviceLoginDialog.java:65)
at com.intellij.openapi.ui.DialogWrapper.init(DialogWrapper.java:1296)
at com.github.copilot.github.DeviceLoginDialog.showDeviceLogin(DeviceLoginDialog.java:30)
at com.github.copilot.lang.agent.AgentGitHubService.loginInteractive(AgentGitHubService.java:108)
at com.github.copilot.github.GitHubService.lambda$showLoginNotification$0(GitHubService.java:62)
at com.intellij.notification.NotificationAction.lambda$createSimpleExpiring$2(NotificationAction.java:62)
at com.intellij.notification.NotificationAction$Simple.actionPerformed(NotificationAction.java:96)
at com.intellij.notification.NotificationAction.actionPerformed(NotificationAction.java:33)
at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:315)
at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:294)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:337)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:294)
at com.intellij.openapi.fileEditor.impl.IdeUiServiceImpl.performActionDumbAwareWithCallbacks(IdeUiServiceImpl.java:109)
at com.intellij.notification.Notification.fire(Notification.java:288)
at com.intellij.notification.impl.NotificationsManagerImpl.lambda$createAction$11(NotificationsManagerImpl.java:841)
at com.intellij.ui.components.labels.LinkLabel.doClick(LinkLabel.java:174)
at com.intellij.ui.components.labels.LinkLabel.doClick(LinkLabel.java:388)
at com.intellij.ui.components.labels.LinkLabel$MyMouseHandler.mouseReleased(LinkLabel.java:361)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown …Run Code Online (Sandbox Code Playgroud)