在Oracle VirtualBox,Windows 7主机中退出缩放模式的快捷方式是什么?
我想生产JWT并用HMAC_SHA256签名.对于那个任务,我必须使用jose4j.我试图基于秘密生成密钥:
SecretKeySpec key = new SecretKeySpec(("secret").getBytes("UTF-8"), AlgorithmIdentifiers.HMAC_SHA512);
Run Code Online (Sandbox Code Playgroud)
但是它会生成40位密钥,而使用HMAC_SHA256签名需要512位密钥.
我有一个抽象类,它基本上用作“迭代器接口”。也就是说,它是一个抽象迭代器,稍后会由一些具体的类实现。为了使抽象类成为迭代器,我需要重载T operator++(int),其中T运算符重载的类在哪里。
class AbstractClass {
virtual AbstractClass operator++(int) = 0; // compile time error
virtual AbstractClass& operator++() = 0; // but this is fine
}
Run Code Online (Sandbox Code Playgroud)
但是,我不能写,AbstractClass operator++(int)因为只允许将抽象类的指针和引用作为返回值。
有没有办法要求子类operator++(int)在普通 C++11 中重载?
我有一组耗时的操作,这些操作特定于我的应用程序的每个用户,它都被封装在一个方法(例如write_collections方法)中.在这个方法中,程序与Facebook和MongoDB进行通信.我想在每个用户的线程中运行此方法.
在get '/'Sinatra路由中调用此线程,但仅需要线程(数据库中的状态)的结果get '/calculate'.我的想法是运行线程get '/'并加入它get '/calculate'以确保在计算用户启动结果之前,所有用户的数据都已在数据库中正确写入.
为了显示:
get "/" do
@user = @graph.get_object("me")
data_thread = Thread.new do
write_collections(@user)
end
session[:data_thread] = data_thread.object_id
erb :index
end
get "/calculate" do
begin
# Is this safe enough?
if ObjectSpace._id2ref(session[:data_thread]).alive?
data_thread = ObjectSpace._id2ref(session[:data_thread])
data_thread.join
end
rescue RangeError => range_err
# session[:data_thread] is not id value
# direct access to /calculate without session
rescue TypeError => type_err
# session[:data_thread] is nil
end
# do …Run Code Online (Sandbox Code Playgroud) 我添加了一个imageViewin GraphicalLayout但它在我的真实设备上看起来与AVD不同.
我发现我需要添加contentDescription一个布局.xml,但是当我添加时:contentDescription="@string/desc"
有一个错误:
"找不到与给定名称匹配的资源(在'contentDescription'中,值为'@ string/desc')"
这个字符串"desc"是什么?它应该是什么样的?
我正在阅读Haskell课程的介绍,他们正在引入着名的河内塔问题作为头等课程的作业.我被诱惑并写了一个解决方案:
type Peg = String
type Move = (Peg, Peg)
hanoi :: Int -> Peg -> Peg -> Peg -> [Move]
hanoi n b a e
| n == 1 = [(b, e)]
| n > 1 = hanoi (n - 1) b e a ++ hanoi 1 b a e ++ hanoi (n - 1) a b e
| otherwise = []
Run Code Online (Sandbox Code Playgroud)
我已经玩了一点,看到它显然使用Tail Call Optimization,因为它在恒定的内存中工作.
Clojure是我大部分时间都在工作的语言,因此我遇到了编写Clojure解决方案的挑战.天真的被丢弃,因为我想写它来使用TCO:
(defn hanoi-non-optimized
[n b a e]
(cond
(= n 1) [[b …Run Code Online (Sandbox Code Playgroud) 看一下这个例子:
(into [] (select-keys {:a 1 :b 2 :c 3} [:c :b])) => [[:c 3] [:b 2]]
是否保证返回的结果将保留在第二个参数中声明的顺序select-key?
我的想法是不断ping 一个地址,提取一些信息,并将其写入文件。
这是我尝试过的:
$ ping google.com | awk -F' ' '{ time = split($8, arr, "time="); print arr[2] }' > file.log
Run Code Online (Sandbox Code Playgroud)
然后等待几秒钟并执行以下操作:
$ file file.log
file.log: empty
Run Code Online (Sandbox Code Playgroud)
然而,这按预期工作(打印time=ping 输出中的每一行):
$ ping google.com | awk -F' ' '{ time = split($8, arr, "time="); print arr[2] }'
Run Code Online (Sandbox Code Playgroud)
这也有效:
$ echo "64 bytes from some.net (x.x.x.x): icmp_seq=7 ttl=115 time=16.7 ms" | awk -F' ' '{ time = split($8, arr, "time="); print arr[2] }' > file.log
$ cat file.log
16.7 …Run Code Online (Sandbox Code Playgroud) 是否有Clojure函数在持久映射中交换两个键的值?我的意思是这样的:
(defn swap-keys [map k1 k2]
(let [f (get map k1) s (get map k2)]
(assoc map k1 s k2 f)))
(swap-keys {:a 1 :b 2 :c 3 :d 4} :a :c)
;; => {:a 3, :b 2, :c 1, :d 4}
Run Code Online (Sandbox Code Playgroud)