Date.getTime()返回自1970年1月1日以来的毫秒数.Unixtime是自1970年1月1日以来的秒数.我通常不用java编写代码,但我正在修复一些错误.我有:
Date now = new Date();
Long longTime = new Long(now.getTime()/1000);
return longTime.intValue();
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法在java中获得unixtime?
UPDATE
根据John M的建议,我最终得到:
Date now = new Date();
Long longTime = new Long(now.getTime()/1000);
return longTime.intValue();
Run Code Online (Sandbox Code Playgroud) 我正在构建一个 django-react 站点,突然我的 docker-compose 不再构建,尽管需求或图像版本发生了任何更改。
\n我的requirements.txt 如下所示:
\nDjango>=3.2.4,<4.0\ndjangorestframework>=3.12.4,<3.14.0\ndjangorestframework-simplejwt>=4.8.0,<5.3.0\npsycopg2>=2.8.6,<2.9\ndrf-spectacular>=0.15.1,<0.30\ndjango-allauth>0.5,<1.0\ndj-rest-auth>=3.0,<4.0\nRun Code Online (Sandbox Code Playgroud)\n错误输出:
\n => [backend internal] load .dockerignore 0.0s \n => => transferring context: 234B 0.0s \n => [backend internal] load build definition from Dockerfile 0.0s \n => => transferring dockerfile: 933B 0.0s \n => [backend internal] load metadata for docker.io/library/python:3.9-alpine3.13 0.5s \n => [backend 1/6] FROM docker.io/library/python:3.9-alpine3.13@sha256:a7cbd1e7784a35a098cedbc8681b790d35ff6030a5e13f043185e2465003a040 0.0s \n => [backend internal] load build context 0.0s \n => => transferring context: 2.53kB 0.0s \n => CACHED [backend 2/6] WORKDIR …Run Code Online (Sandbox Code Playgroud) 我正在为项目使用twitter bootstrap - 特别是它的tab功能(http://twitter.github.com/bootstrap/javascript.html#tabs)
现在我有了这个tablist,当我按下它时,它会切换到每个标签的内容.但是,此内容已预先加载到页面中(所有选项卡的内容的html代码已经存在,您只需按下选项卡即可更改可见性).
但是,我只想在按下某个选项卡时动态加载内容,因此在加载整个页面时,将获得最新数据而不是数据.
我打算为此使用jQuery.但是,如何在按下选项卡时调用某个jquery函数?
我试图在单击选项卡时显示警告(如果可行,jQuery函数也会),但即使这样也不起作用:
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="http://twitter.github.com/bootstrap/1.4.0/bootstrap-tabs.js"></script>
<script type="text/javascript">
$(function() {
$('.tabs').bind('click', function (e) {
e.target(window.alert("hello"))
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
而我的HTML:
<ul class="tabs" data-tabs="tabs">
<li class="active"><a href="#tab1">tab 1</a></li>
<li><a href="#tab2">tab 2</li>
</ul>
<div id="my-tab-content" class="tab-content">
<div class="tab-pane" id="tab1">
<h1>Tab1</h1>
<p>orange orange orange orange orange</p>
</div>
<div class="tab-pane" id="tab2">
<h1>Tab2</h1>
<p>blue blue blue blue blue</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
有关如何使这项工作的任何想法?
请参阅twitter bootstrap选项卡的工作原理:(http://twitter.github.com/bootstrap/javascript.html#tabs)及其使用的js文件:http: //twitter.github.com/bootstrap/1.4. 0 /自举-tabs.js
我最近从Ruby的Net:HTTP类切换到rest-client 1.6.7.
我发现形成请求要容易得多,但与Net:HTTP请求不同,当rest-client获得200以外的任何东西时,请求就会消失.我已经尝试在RestClient.get之后直接放置一个断点,它永远不会被击中 - 所以我做错了.
def get_member_using_card
resource = "#{@settings_app_uri}api/v1/card/#{self.member_card_num}?token=#{@settings.api_key}"
response = RestClient.get resource
if response.code == 200
card = JSON.parse(response.body)
self.customer_id = card['card']['customer_id']
else
return 0
end
end
Run Code Online (Sandbox Code Playgroud)
这导致了这个堆栈跟踪:
RestClient::ResourceNotFound - 404 Resource Not Found:
/Users/tim/.rvm/gems/ruby-1.9.2-p290/gems/rest-client-1.6.7/lib/restclient/abstr
act_response.rb:48:in `return!'
/Users/tim/.rvm/gems/ruby-1.9.2-p290/gems/rest-client-1.6.7/lib/restclient/reque
st.rb:230:in `process_result'
/Users/tim/.rvm/gems/ruby-1.9.2-p290/gems/rest-client-1.6.7/lib/restclient/reque
st.rb:178:in `block in transmit'
/Users/tim/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:627:in `start'
/Users/tim/.rvm/gems/ruby-1.9.2-p290/gems/rest-client-1.6.7/lib/restclient/reque
st.rb:172:in `transmit'
/Users/tim/.rvm/gems/ruby-1.9.2-p290/gems/rest-client-1.6.7/lib/restclient/reque
st.rb:64:in `execute'
/Users/tim/.rvm/gems/ruby-1.9.2-p290/gems/rest-client-1.6.7/lib/restclient/reque
st.rb:33:in `execute'
/Users/tim/.rvm/gems/ruby-1.9.2-p290/gems/rest-client-1.6.7/lib/restclient.rb:68
:in `get'
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何正确评估响应代码并防止这种异常发生......?
我有一部分&[u8],我想将它附加到Vec<u8>最小的复制.以下是我认识的两种方法:
let s = [0u8, 1u8, 2u8];
let mut v = Vec::new();
v.extend(s.iter().map(|&i| i));
v.extend(s.to_vec().into_iter()); // allocates an extra copy of the slice
Run Code Online (Sandbox Code Playgroud)
在Rust稳定中有更好的方法吗?(rustc 1.0.0-beta.2)
我在项目中使用该Microsoft.Bcl.Async 包,该项目由另一个不使用异步功能的项目引用.
现在,当我编译解决方案(或仅第二个项目)时,我收到此错误警告:
无法解析主要引用"XYZ.dll",因为它对框架程序集"System.Runtime,Version = 1.5.11.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"具有间接依赖性,无法在当前目标中解析框架." .NETFramework,版本= V4.0" .要解决此问题,请删除引用"XYZ.dll"或将应用程序重新定位到包含"System.Runtime,Version = 1.5.11.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"的框架版本.
我在这两个项目中使用这个app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:bcl="urn:schemas-microsoft-com:bcl">
<dependentAssembly bcl:name="System.Runtime">
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.16.0" newVersion="2.5.16.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.16.0" newVersion="2.5.16.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
我不想引用异步包dll.
我不能使用.Net 4.5目标.它必须是.Net 4.
所有项目的目标框架:.NET Framework 4
我对WPF比较陌生,有些东西对我来说很陌生.首先,与Windows窗体不同,WPF控件层次结构不支持IDisposable.在Windows窗体中,如果用户控件使用任何托管资源,则通过覆盖每个控件实现的Dispose方法来清理资源非常容易.
在WPF中,故事并不那么简单.我搜索了几个小时,遇到了两个基本主题:
第一个主题是微软明确指出WPF没有实现IDisposable,因为WPF控件没有非托管资源.虽然这可能是真的,但他们似乎完全错过了WPF类层次结构的用户扩展可能确实使用托管资源(直接或通过模型间接)的事实.通过不实现IDisposable,Microsoft已经有效地删除了唯一保证机制,通过该机制可以清除自定义WPF控件或窗口使用的非托管资源.
其次,我发现了一些对Dispatcher.ShutdownStarted的引用.我曾尝试使用ShutdownStarted事件,但似乎没有为每个控件触发.我有一堆WPF UserControl,我已经为ShutdownStarted实现了一个处理程序,它永远不会被调用.我不确定它是否只适用于Windows,或者WPF App类.但是它没有正确触发,每次应用程序关闭时我都会泄漏打开的PerformanceCounter对象.
清理非托管资源是否有比Dispatcher.ShutdownStarted事件更好的替代方案?是否有一些技巧来实现IDisposable,以便调用Dispose?如果可能的话,我更愿意避免使用终结器.
/etc/file.txt如果文件存在,这个木偶清单将删除该文件:
file { "/etc/file.txt":
ensure => absent,
}
Run Code Online (Sandbox Code Playgroud)
如何告诉木偶删除所有文件/etc/*.txt?
根据参考资料,似乎puppet file不允许使用通配符.
http://docs.puppetlabs.com/references/latest/type.html#file
ps:我知道我可以从puppet执行一个脚本,但我更喜欢另一种更优雅的方式.
ruby ×2
wpf ×2
.net-4.0 ×1
async-await ×1
asynchronous ×1
c# ×1
call ×1
cython ×1
dispose ×1
docker ×1
finalizer ×1
java ×1
javascript ×1
jquery ×1
puppet ×1
pyyaml ×1
rest-client ×1
rust ×1
system ×1
vector ×1