我制作了一个简单的bash脚本,该脚本使用pcmanfm从我的壁纸目录中更改了一张随机图片的壁纸。就像这样:
#!/bin/bash
pcmanfm -w "$(find /home/likewise-open/MAPS/lucas.cardeal/Pictures/Wallpapers -type f | shuf -n1)"
Run Code Online (Sandbox Code Playgroud)
我会自动想要它,所以您将脚本放在crontab上。但是,当crontab调用它时,它没有任何作用。我的脚本怎么了?我该如何解决?
谢谢
我有一个php,如果它存在于mysql数据库中,它将检查某些值.如果该值不存在,则只需添加该值并刷新页面一次以再次加载页面,现在它在数据库中有一个值,将继续添加其他值.如何在调用页面时只刷新一次页面?
<?php
$sname = "W3 schools C# tutorials";//$_POST["sitename"];
$stype = "C#";//$_POST["sitetype"];
$saddy = "www.w3schools.com";//$_POST["siteaddress"];
$scomm = "W3 schools C# tutorials";//$_POST["sitecomment"];
$conn = mysql_connect("localhost","root","password");
if(!$conn){
die("Could not connect: ".mysql_error());
} else {
mysql_select_db("bookmarks",$conn);
$rs = mysql_query("select TypeId from bookmarktypes where TypeName = '$stype'");
$row = mysql_fetch_array($rs);
if($row > 0 ){
//Data found, continue to add...
} else {
//No data... insert a valid one
$rs = mysql_query("insert into bookmarktypes (TypeName) values ('$stype')");
if (!$rs){
die('Error: ' . mysql_error());
} else { …Run Code Online (Sandbox Code Playgroud) 我正在尝试让Unquote库在.NET 4中使用xUnit,而且我没有任何运气可以让测试运行.所以,我把它分解为最简单的再现步骤.有人知道我可能会缺少什么吗?
我直接从Unquote主页获得了实际测试,但内容并不重要,因为它没有运行.
module Tests
open Xunit
open Swensen.Unquote
[<Fact>]
let ``demo Unquote xUnit support`` () =
test <@ ([3; 2; 1; 0] |> List.map ((+) 1)) = [1 + 3..1 + 0] @>
Run Code Online (Sandbox Code Playgroud)
然后我编译程序集并将其加载到xUnit.net GUI测试运行器(64位,CLR 4)中,并在运行测试时收到以下错误:
Tests.demo Unquote xUnit support : System.MissingMethodException : Method not found:
'Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Quotations.FSharpExpr> Swensen.Unquote.Extensions.Expr.ReduceFully(Microsoft.FSharp.Quotations.FSharpExpr)'.
Stack Trace:
at Tests.demo Unquote xUnit support()
Run Code Online (Sandbox Code Playgroud) 初学者在这里.为什么这是一个无限循环?
for (p = 0; p < 5; p += 0.5)
{
printf("p=%2.2f\n",p);
}
Run Code Online (Sandbox Code Playgroud) 显然我在下面的例子中忽略了一些非常简单的事情,我试图在实例化新的父记录时创建嵌套的关联记录.
我希望有一双新鲜的眼睛,我的帮助可以找到几天来一直在吃的东西.提前致谢!我错过了什么/弄乱了什么?这似乎是微不足道的.
ActiveRecord :: NestedAttributes显然不高兴.
class ContentGroup < ActiveRecord::Base
attr_protected
has_many :contents, :dependent=>:destroy
accepts_nested_attributes_for :contents
end
Run Code Online (Sandbox Code Playgroud)
class Content < ActiveRecord::Base
attr_protected
has_one :sort_item, :as=>:sortable
belongs_to :content_group, :dependent=>:destroy
accepts_nested_attributes_for :sort_item
end
Run Code Online (Sandbox Code Playgroud)
class SortItem < ActiveRecord::Base
attr_accessible :position, :sortable_id, :sortable_type
belongs_to :sortable, :polymorphic=>true
end
Run Code Online (Sandbox Code Playgroud)
> p = {"sort_item_attributes"=>{"position"=>"1"}}
> b = Content.new(p)
=> Content id: nil, content_group_id: nil
Run Code Online (Sandbox Code Playgroud)
> p = {"contents_attributes"=>{"sort_item_attributes"=>{"position"=>"1"}}}
> cg = ContentGroup.new(p)
ActiveRecord::UnknownAttributeError: unknown attribute: position
from /.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/attribute_assignment.rb:88:in `block in assign_attributes'
from /.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/attribute_assignment.rb:78:in `each'
from /.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/attribute_assignment.rb:78:in …Run Code Online (Sandbox Code Playgroud) 我有初始化以下向量的问题:
int main()
{
...
int size = classData.size();
vector<vector<string>> arrayClass[size][3]; // <-- problem
for(int i = 0 ; i < classData.size(); i++)
{
for(int j = 0 ; j < 3; j++)
{
arrayClass[i][j] = classData[j+i];
}
}
}
Run Code Online (Sandbox Code Playgroud)
它说size必须是恒定的价值.有什么想法吗?
为了优化响应延迟,必须在将响应发送回客户端之后执行工作.但是,在发送响应之后,我似乎能够获得运行代码的唯一方法是使用setTimeout.有没有更好的办法?也许某个地方在发送响应后插入代码,或者某处异步运行代码?
这是一些代码.
koa = require 'koa'
router = require 'koa-router'
app = koa()
# routing
app.use router app
app
.get '/mypath', (next) ->
# ...
console.log 'Sending response'
yield next
# send response???
console.log 'Do some more work that the response shouldn\'t wait for'
Run Code Online (Sandbox Code Playgroud) 我正在将基于全局变量的实时Ember应用程序转换为使用ember-cli的基于es6的应用程序.在我的应用程序中,我需要经常了解当前的路线.在全局版本中,我正在这样做.
全球模式
var MyApp = Ember.Application.create({
currentRoute : ''
});
MyApp.Route = Ember.Route.extend({
actions : {
didTransition : function () {
MyApp.set('currentRoute', this);
}
}
});
Run Code Online (Sandbox Code Playgroud)
然后,我可以MyApp.get('currentRoute')在我的会话或离线控制器中确定在发生某些事件时如何/在何处转换.
使用ember-cli时,我导入应用程序以便能够从必要的控制器中引用它.
import MyApp from "../app";
Run Code Online (Sandbox Code Playgroud)
但事实证明MyApp.currentRoute,MyApp.get和MyApp.set都是不确定的.
我的一部分认为这是ember-cli中的一个错误,即应用程序实例不再绑定getter和setter.我的一部分意识到将应用程序实例存储在一起并不是一个很好的做法.
我可以解决这个问题,通过转换的所有实例MyApp.get,并MyApp.set以Ember.get(MyApp, ...)和Ember.set(MyApp, ...)分别,但我想我会先问这里,因为这似乎要么是与Ember,CLI或其他什么东西的问题,其中有达到什么更好的推荐方式我需要.
对于ES6生成器,为什么这篇博文的作者说:
来自:http://davidwalsh.name/es6-generators
"第一个下一个(..)调用,我们不发送任何内容.为什么?因为没有收益表达式来接收我们传入的内容."
不是第一次it.next()打电话(yield (x + 1))?
function *foo(x) {
var y = 2 * (yield (x + 1));
var z = yield (y / 3);
return (x + y + z);
}
var it = foo( 5 );
// note: not sending anything into `next()` here
console.log( it.next() ); // { value:6, done:false }
console.log( it.next( 12 ) ); // { value:8, done:false }
console.log( it.next( 13 ) ); // …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一系列按钮,我的网站用户可以点击这些按钮,以便在不同的CSS3文件之间进行切换,这将改变某些特效.为了实现这个目标,我需要一些方法来访问
href="example1.css"
Run Code Online (Sandbox Code Playgroud)
在我的HTML中标记,并将其更改为
href="example2.css"
Run Code Online (Sandbox Code Playgroud)
使用JavaScript或HTML.
ecmascript-6 ×3
javascript ×3
activerecord ×1
arrays ×1
associations ×1
bash ×1
c ×1
c++ ×1
crontab ×1
css3 ×1
ember-cli ×1
ember.js ×1
f# ×1
f#-unquote ×1
for-loop ×1
generator ×1
html ×1
koa ×1
loops ×1
optimization ×1
pcmanfm ×1
php ×1
refresh ×1
stdvector ×1
string ×1
unit-testing ×1