我写了一个简单的脚本来检查Dropbox文件的状态并将其移动到另一个文件夹,如果文件已经完全同步并下载(状态=='最新').
我现在唯一的问题是,如果文件或目录中有空格,那么我的脚本将无法正常运行.
我曾经#{...}传递过文件名,但似乎它拆分了在空格中给它的任何东西.
这是我的脚本:
# runs in Ruby 1.8.x (ftools)
class DropboxHelper
require 'ftools'
def self.move
directory = "Foo"
destination = "Bar"
while true
Dir.glob(directory+"/**/*") do |item|
next if item == '.' or item == '..'
fileStatus = `~/bin/dropbox.py filestatus #{item}`
puts "processing " + item
puts "filestatus: " + fileStatus
if (fileStatus.include? "up to date")
puts item.split('/',2)[1] + " is up to date, starting to move file now."
`cp -r #{item + " " + destination + …Run Code Online (Sandbox Code Playgroud) 我有很长的一句话,看起来像这样:
foo,foo bar,bar@foo,foo# bar,bar$ foo#
Run Code Online (Sandbox Code Playgroud)
现在我想把它变成:
"foo","foo bar","bar@foo","foo# bar","bar$ foo#"
Run Code Online (Sandbox Code Playgroud)
因此,分隔符是逗号.这样做的最佳方式是什么vi(m)?
编辑:有人会关注详细的暗示吗?
我已经从flat csv中读过Create nested JSON,但在我的情况下它并没有帮助.
我有一个很大的电子表格,使用包含11行和74列的Google Docs创建(某些列未被占用).
我在Google云端硬盘上创建了一个示例.导出时,CSV它看起来像这样:
id,name,email,phone,picture01,picture02,picture03,status
1,Alice,alice@gmail.com,2131232,"image01_01
[this is an image]",image01_02,image01_03,single
2,Bob,bob@gmail.com,2854839,image02_01,"image02_02
[description to image 2]",,married
3,Frank,frank@gmail.com,987987,image03_01,image03_02,,single
4,Shawn,shawn@gmail.com,,image04_01,,,single
Run Code Online (Sandbox Code Playgroud)
现在我想有一个JSON结构,看起来像这样:
{
"persons": [
{
"type": "config.profile",
"id": "1",
"email": "alice@gmail.com",
"pictureId": "p01",
"statusId": "s01"
},
{
"type": "config.pictures",
"id": "p01",
"album": [
{
"image": "image01_01",
"description": "this is an image"
},
{
"image": "image_01_02",
"description": ""
},
{
"image": "image_01_03",
"description": ""
}
]
},
{
"type": "config.status",
"id": …Run Code Online (Sandbox Code Playgroud) 在尝试使用clang编译它时,我得到以下Objective-C代码的错误.
Obj-C代码:
// first program example
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool {
NSLog (@"Programming is fun!");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
main.m:6:5: error: unexpected '@' in program
@autoreleasepool {
^
main.m:7:38: error: extraneous ')' before ';'
NSLog (@"Programming is fun!");
^
main.m:7:16: warning: expression result unused [-Wunused-value]
NSLog (@"Programming is fun!");
^~~~~~~~~~~~~~~~~~~~~~
main.m:9:5: error: expected identifier or '('
return 0;
^
main.m:10:1: error: expected external declaration
}
^
1 warning and 4 errors …Run Code Online (Sandbox Code Playgroud) 我有给定的文字:
# Blub
Hello this is a blub text.
# Bla
This is the bla text.
# Abba
Another text.
Run Code Online (Sandbox Code Playgroud)
有可能用#?对线条进行排序?这样生成的文本是:
# Abba
Another text.
# Bla
This the bla text.
# Blub
Hello this is a blub text.
Run Code Online (Sandbox Code Playgroud)
最好使用vim或emacs.
这应该是使用re库的一个非常简单的任务.不过,我似乎无法到我的字符串的分隔符分裂]和[.
我已经读过在Python中拆分带有多个分隔符的字符串,Python:带有多个分隔符的拆分字符串,以及Python:如何在方括号内获取多个元素.
我的字符串:
data = "This is a string spanning over multiple lines.
At somepoint there will be square brackets.
[like this]
And then maybe some more text.
[And another text in square brackets]"
Run Code Online (Sandbox Code Playgroud)
它应该返回:
['This is a string spanning over multiple lines.\nAt somepoint there will be square brackets.','like this', 'And then maybe some more text.', 'And another text in square brackets']
Run Code Online (Sandbox Code Playgroud)
一个简短的例子:
data2 = 'A new …Run Code Online (Sandbox Code Playgroud) 我知道你可以通过点击并拖动右下角来应用函数/公式,但我有一定的问题.
我的功能看起来像这样
=IF(COUNT(H3:N3)>0;SUMPRODUCT(H2:N2;H3:N3)/SUM(H2:N2);"")
Run Code Online (Sandbox Code Playgroud)
除了COUNT和SUMPRODUCT的第二个参数之外,我希望所有其他行都完全相同.
所以接下来的行应该是这样的:
=IF(COUNT(H4:N4)>0;SUMPRODUCT(H2:N2;H4:N4)/SUM(H2:N2);"")
=IF(COUNT(H5:N5)>0;SUMPRODUCT(H2:N2;H5:N5)/SUM(H2:N2);"")
=IF(COUNT(H6:N6)>0;SUMPRODUCT(H2:N2;H6:N6)/SUM(H2:N2);"")
...
Run Code Online (Sandbox Code Playgroud)
所以我的除数保持不变,数字也乘以(H2:N2).
当我向右转弯时,我总是得到这个:
=IF(COUNT(H4:N4);SUMPRODUCT(H3:U3;H4:U4)/SUM(H3:U3);"")
Run Code Online (Sandbox Code Playgroud)
有没有办法在不改变每一行的每个公式的情况下做到这一点?
我希望有一个类似于这个的jQuery /任何滑块,但功能更多.
我将在我的HTML代码,图像,文本和可能的一些div中使用元素,默认情况下应该隐藏这些元素,但是当滑块达到特定值时,图像/文本/应该连续显示.
因此,在值0处,例如,仅显示一个图像,然后在值1处弹出另一个图像,依此类推.
是否有任何预制的jQuery插件,或者我将如何进行此操作?
<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile Tutorial on Codeforest.net</title>
<link rel="stylesheet"
href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css">
<style>
#slider {
margin: 10px;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<script>
var img1 = $('<img\>').attr('src', 'http://lorempixel.com/400/200/');
var img2 = $('<img\>').attr('src', 'http://lorempixel.com/300/200/');
var foto = $('#foto');
foto.html(img1);
$("#slider").slider({
slide: function(event, ui) {
if (ui.value > 50) {
$('#foto').html(img2);
} else {
$('#foto').html(img1);
}
}
});
</script>
</head>
<body>
<div id="slider"></div>
<div id="foto"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)