我有一个由WDBackup(西部数字外部高清备份工具)创建的备份目录,其中包含备份的每一天的目录以及备份内容的增量内容.
层次结构如下所示:
20100101
My Documents
Letter1.doc
My Music
Best Songs Every
First Songs.mp3
My song.mp3 # modified 20100101
20100102
My Documents
Important Docs
Taxes.doc
My Music
My Song.mp3 # modified 20100102
...etc...
Run Code Online (Sandbox Code Playgroud)
仅备份已更改的内容,并且所做的第一个备份包含选择用于备份的所有文件.
我现在要做的是逐步复制,同时保持文件夹结构,从最旧到最新,每个这些日期文件夹到一个'合并'文件夹,以便它覆盖旧内容并保留新内容.
例如,如果只使用这两个示例文件夹,最终合并的文件夹将如下所示:
Merged
My Documents
Important Docs
Taxes.doc
Letter1.doc
My Music
Best Songs Every
First Songs.mp3
My Song.mp3 # modified 20100102
Run Code Online (Sandbox Code Playgroud)
希望有道理.
谢谢,
玩笑
OnClickListener除了以下方法之外,是否有其他方法来设置按钮,例如通过XML?
final Button button = (Button) findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Handle click event.
}
});
Run Code Online (Sandbox Code Playgroud) 简单的问题,我有点惊讶,Rails已经没有更好的处理.
我试图params用这个except!()方法从许多Rails API控制器中清除掉一些多余的属性,如下所示:
params.except!( :format, :api_key, :controller, :action, :updated_at, :created_at )
Run Code Online (Sandbox Code Playgroud)
因为这些属性在许多API端点上是相同的,所以我想将它们存储Constant在API中BaseController,如下所示:
PARAMS_TO_SCRUB = [ :format, :api_key, :controller, :action, :updated_at, :created_at ]
params.except!( PARAMS_TO_SCRUB ) # => Doesn't work.
Run Code Online (Sandbox Code Playgroud)
但该except!()方法只接受一个键的splat,因此没有任何属性被过滤:
# File activesupport/lib/active_support/core_ext/hash/except.rb, line 11
def except!(*keys)
keys.each { |key| delete(key) }
self
end
Run Code Online (Sandbox Code Playgroud)
我现在设置的工作是创建一个方法,用相应的BaseController方式擦除params键,如下所示:
def scrub_params
params.except!( :format, :api_key, :controller, :action, :updated_at, :created_at )
end
Run Code Online (Sandbox Code Playgroud)
有没有办法存储像这样的符号列表?
我试图通过使用一个BaseComponentType类来重构我的代码,并在我的ElectricalComponentType类(和类似的子类)中继承它,如下所示:
public abstract class BaseComponentType {
public static BaseComponentType findByUid ( Class klass, String uid ) {
return new Select().from( klass ).where( "uid = ?", uid ).executeSingle();
}
}
Run Code Online (Sandbox Code Playgroud)
public class ElectricalComponentType extends BaseComponentType {
public static ElectricalComponentType findByUid( String uid ) {
return (ElectricalComponentType) findByUid( ElectricalComponentType.class, uid );
}
}
Run Code Online (Sandbox Code Playgroud)
我需要做的就是调用,ElectricalComponentType.findByUid( 'a1234' )但如果我不必findByUid在ElectricalComponentType类中定义,而是可以从中继承此功能,那将会很棒BaseComponentType.
你会发现有两件事情在路上:
我需要父方法中的ElectricalComponentType类findByUid.
我需要返回ElectricalComponentType对象(或任何子类对象)而不是BaseComponentType …
我正在从我的 Android 应用程序创建一个可打印标签(这是一个检查应用程序,允许您在蓝牙打印机上打印标签,以便留在现场以识别您发现的任何问题)。
我用来drawText在 上绘制文本Canvas并使用 来设置我的绘画(样式等)TextPaint。
如果您查看继承自的 上可用的标志Paint,TextPaint您将看到许多与潜在质量相关的标志,例如抖动和抗锯齿。
在查看其他教程后,他们似乎使用 和 之一或Paint.ANTI_ALIAS_FLAG两者Paint.LINEAR_TEXT_FLAG。
没有太多讨论这些选项实际上如何影响输出质量,特别是文本输出质量。一般来说,我知道抗锯齿和抖动的作用,但 Android 文档中没有关于用于文本等的官方建议。
有这方面的好资源吗?
无法在任何地方找到这个,也许我正在寻找错误的动词.
我正在尝试在输入数字时让文本框需要某种格式.为简单起见,我们使用电话号码示例.当我输入框时,我想要一些指导方针来帮助用户输入正确的电话号码格式:
(4__) ___-____
(403) 3__-____
(403) 329-98__
(403) 329-9824
Run Code Online (Sandbox Code Playgroud)
这将防止用户忘记区号等.我已经在其他地方看到过这种情况,但不确定从哪里开始.
我确定这是javascript,但它适用于rails应用程序上的ruby,所以如果你知道一个插件或什么的.
谢谢!
玩笑
javascript formatting textbox ruby-on-rails string-formatting
我有一个刷新按钮,我希望根据情况可见.
单击" 刷新"按钮时,我可以使其不可见而不会出现问题,但是,一旦该AsyncTask过程完成,我就无法再将其显示出来.我无法将MenuItem值传回给AsyncTask.
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getSupportMenuInflater().inflate(R.menu.refresh_action_provider, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_refresh:
item.setVisible(false); //hide refresh button
setSupportProgressBarIndeterminateVisibility(true);
Toast.makeText(getApplicationContext(), "REFRESH CLiCKED", Toast.LENGTH_SHORT).show();
new DownloadNewsTask().execute();
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud) to_s我不想覆盖我的模型,而是将其别名为现有的方法full_name.
双方alias并alias_method似乎并不如预期的工作.
aliasclass Person < ActiveRecord::Base
# ... other model code.
alias to_s full_name
def full_name
"#{first_name} #{last_name}"
end
end
# In Terminal
> Person.last.to_s #=> "#<Person:0x007fa5f8a81b50>"
Run Code Online (Sandbox Code Playgroud)
alias_methodclass Person < ActiveRecord::Base
# ... other model code.
alias_method :to_s, :full_name
def full_name
"#{first_name} #{last_name}"
end
end
# In Terminal
> Person.last.to_s #=> "#<Person:0x007fa5f8a81b50>"
Run Code Online (Sandbox Code Playgroud) 我将一些文本附加到notes我的某个ActiveRecord::Base模型上的字段中,但是当我保存它时,它不会更新:
valve.notes
#=> "Level: Top"
valve.notes << "\nDirection: North"
valve.notes
#=> "Level: Top\nDirection: North"
valve.save
#=> true
valve.reload.notes
#=> "Level: Top"
Run Code Online (Sandbox Code Playgroud) 我正在使用 SQLite 并提供id要检索的值列表。但是,这些id值的顺序很重要,我想以相同的顺序检索记录。
例如,
SELECT
*
FROM
todos
WHERE
todos.id in ( 1, 3, 2, 4 )
Run Code Online (Sandbox Code Playgroud)
这将返回:
1
2
3
4
Run Code Online (Sandbox Code Playgroud)
但我希望它以与提供的id值相同的顺序返回,如下所示:
1
3
2
4
Run Code Online (Sandbox Code Playgroud)
我已经看到了 MySQL 和 PostgreSQL 的答案,但没有看到 SQLite 的答案。
我想开始一个被叫的ProgressDialog时候onPreExecute(),但它不起作用.
Homeactivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//switch condtion...
case R.id.buttontime :
new FlightListTask().execute("");
break:
}
public class FlightListTask extends AsyncTask<String,ArrayList<HashMap<String, String>>, ArrayList<HashMap<String, String>>> {
protected String onPreExecute(String temp) {
progresdialoglistview=ProgressDialog.show(HomeActivity.this, "", "Loading");
Log.e("onPreExecutive","called"+progresdialoglistview);
return temp;
}
@Override
protected ArrayList<HashMap<String, String>> doInBackground( String... params ) {
return flightlist;
}
protected void onPostExecute(ArrayList<HashMap<String, String>> flightList) {
// listview code....
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用jCanvas构建一个HTML5应用程序,我需要删除一个图层,这是画布上的黑色圆圈,你可以在这里看到代码.
var cvLingualWidth = 945;
var cvLingualHeight = 100;
var cvLingual = document.getElementById("cvLingual");
function drawGrid() {
var contextLingual = cvLingual.getContext("2d");
for (var y = 0.5; y < cvLingualHeight; y += 6) {
contextLingual.moveTo(0, y);
contextLingual.lineTo(cvLingualWidth, y);
}
contextLingual.strokeStyle = "#DDD";
contextLingual.stroke();
}
function drawCircle() {
$("#cvLingual").drawArc({
layer: true,
name: "circleLayer_18",
strokeStyle: "#000",
strokeWidth: 2,
x: 42,
y: 70,
radius: 8
});
}
function clearCircle() {
var circleLayer = $("#cvLingual").getLayer("circleLayer_18");
// TODO
}
$(function () {
drawGrid();
drawCircle();
$("#clear").click(function(){ …Run Code Online (Sandbox Code Playgroud) android ×4
ruby ×3
canvas ×2
activerecord ×1
alias ×1
alias-method ×1
attributes ×1
button ×1
command-line ×1
constants ×1
copy ×1
dirty-data ×1
formatting ×1
html5 ×1
inheritance ×1
java ×1
javascript ×1
jcanvas ×1
menuitem ×1
merge ×1
paint ×1
recursion ×1
sql-order-by ×1
sqlite ×1
symbols ×1
text ×1
textbox ×1
unix ×1
where-in ×1