whenever 定时执行一个model 里面的方法

     做微信要取access_token但是access_token是有请求限制次数的,所以不能用一次取一次,access_token的有效期为2小时所以可以定时来取回access_token.

     下面是ruby里面一个定时方法。

 

whenever 安装:

gem 'whenever', :require => false #在Gamfile里面添加

 然后就是进入程序的根目录底下运行:

 wheneverize

 

这样whenever会给你初始化创建config/schedual.rb文件;
然后在该文件里面添加一下内容:

set :output, "#{path}/log/whenever.log" #设置日志输出文件
job_type :rake_no_env, "cd :path && rake :task :output" #自定义任务

every 1.day,:at=>'10:45am' do
  rake_no_env "check_daylog"    #每天早上:10:45运行 底下命令
end

 

以下是一个简单的自适应容器视频播放的示例代码: HTML: ```html <div id="video-container"> <video id="video" controls> <source src="video.mp4" type="video/mp4"> <source src="video.webm" type="video/webm"> Your browser does not support the video tag. </video> </div> ``` CSS: ```css #video-container { position: relative; padding-bottom: 56.25%; /* 16:9 aspect ratio */ height: 0; } #video { position: absolute; width: 100%; height: 100%; } ``` JavaScript: ```javascript window.onload = function() { var video = document.getElementById("video"); var container = document.getElementById("video-container"); var aspectRatio = video.videoWidth / video.videoHeight; function resizeVideo() { var containerWidth = container.offsetWidth; var containerHeight = container.offsetHeight; var containerAspectRatio = containerWidth / containerHeight; if (containerAspectRatio > aspectRatio) { // The container is wider than the video, so set the video width to 100% video.style.width = "100%"; video.style.height = "auto"; } else { // The container is taller than the video, so set the video height to 100% video.style.width = "auto"; video.style.height = "100%"; } } // Call resizeVideo() whenever the window is resized window.onresize = resizeVideo; // Call resizeVideo() once on page load resizeVideo(); }; ``` 这段代码创建了一个自适应容器,其中视频的宽高比为16:9。在窗口大小变化时,JavaScript代码会根据容器的宽高比和视频的宽高比来调整视频的大小,以确保视频始终填充整个容器。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值