我注意到如果我们期望一些回调函数运行,我可以使用Closure或Callable作为类型提示.例如:
function callFunc1(Closure $closure) {
$closure();
}
function callFunc2(Callable $callback) {
$callback();
}
$function = function() {
echo 'Hello, World!';
};
callFunc1($function); // Hello, World!
callFunc2($function); // Hello, World!
Run Code Online (Sandbox Code Playgroud)
题:
这有什么区别?换句话说,何时使用Closure以及何时使用CallableOR它们的用途相同?
我们是一些在同一个项目上工作的开发人员,我们在项目中使用git.如果我们中的两个或多个碰巧在同一个文件上工作,我们会收到难以处理的git冲突,有时一个开发人员在发生这些冲突时会发生更改.
他们如何在团队中使用git?为了避免git冲突,应该采取什么样的正确流程?
提前致谢.
我经常做同样的任务,即将更改提交到远程分支.有时懒惰,我需要放置一组git命令来自动执行这些步骤:
cd D:\wamp\www\projectName
git checkout dev
git add .
git commit -am "made changes"
git push
pause
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
cd D:\wamp\www\projectName
call git checkout dev
call git add .
call git commit -am "made changes"
call git push
pause
Run Code Online (Sandbox Code Playgroud)
和
cd D:\wamp\www\projectName
git.exe checkout dev
git.exe add .
git.exe commit -am "made changes"
git.exe push
pause
Run Code Online (Sandbox Code Playgroud)
最终push命令的一切都是令人兴奋的.这是输出:
D:\wamp\www\givingcircle>git checkout dev
Already on 'dev'
Your branch is ahead of 'origin/dev' by 1 commit.
D:\wamp\www\givingcircle>git add .
D:\wamp\www\givingcircle>git commit -am "made …Run Code Online (Sandbox Code Playgroud) 当我在我的应用程序中切换活动时,我无法理解为什么我的自定义动画不会覆盖系统动画.
styles.xml
<style name="AppBaseTheme" parent="android:Theme.Holo.Light"></style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:buttonStyle">@style/buttonStyle</item>
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
<item name="android:editTextStyle">@style/editTextStyle</item>
<item name="android:windowAnimationStyle">@style/ActivityAnimationStyle</item>
</style>
<!-- activities animation style start -->
<style name="ActivityAnimationStyle" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/fadein</item>
<item name="android:activityOpenExitAnimation">@anim/fadeout</item>
<item name="android:activityCloseEnterAnimation">@anim/fadein</item>
<item name="android:activityCloseExitAnimation">@anim/fadeout</item>
</style>
<!-- activities animation style end -->
Run Code Online (Sandbox Code Playgroud)
fadein.xml:
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromAlpha="0.0"
android:interpolator="@android:anim/anticipate_interpolator"
android:toAlpha="1.0" />
Run Code Online (Sandbox Code Playgroud)
fadeout.xml
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromAlpha="1.0"
android:interpolator="@android:anim/anticipate_interpolator"
android:toAlpha="0.0" />
Run Code Online (Sandbox Code Playgroud)
表现:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)
有了这些,我希望看到渐弱的动画,但这根本不会发生.
仅供参考,我发现如果我使用android:windowEnterAnimation和android:windowExitAnimation替代和增加值android:duration,以类似2000的动画文件,那么我也看得很慢衰落动画,但我想有四个案件都和更快的褪色动画.
我使用的是Kitkat 4.4.2.谢谢你的帮助
是否有任何与 JavaScript 配合良好的平面文件数据库系统,例如 JSON 格式或类似格式的数据库系统。我听说过mongodb、couchdb等,但似乎它的整个设置必须安装在计算机上。
当然,我不能使用sqlite,因为我认为我无法通过 javascript 操作它,而且我不想为我的小应用程序使用任何服务器端语言。
我也在谷歌上搜索过。基本上我只是在寻找平面文件数据库系统,我可以将其放入javascript应用程序的文件夹(即便携式数据库和应用程序)中,并且能够在任何地方使用它,例如在其他计算机上,而无需安装任何依赖项?那里存在这样的便携式平面文件数据库吗?
我正在做的是以编程方式从网页中选择所有文本,然后将其复制。全选功能适用,execCommand但复制功能无效。
这是我的代码:
$.ajax({
url: $('#url').val(),
type: 'GET',
success: function(res) {
$('#result').html(res.responseText);
$('#result').fadeIn('fast');
$('#result').focus();
$('#result').select();
document.execCommand('selectall');
// copy does not work ?
document.execCommand('copy');
}
});
Run Code Online (Sandbox Code Playgroud)
我也尝试使用Flash解决方案,例如ZeroClipboard,但是似乎必须显式地按下其Flash对象/按钮才能复制文本,而我想这样做zeroclip.setText('whatever'); 而无需用户按下按钮。
谁能告诉我如何以编程方式复制文本?
在处理本地项目时,您无法恢复到1天前或1个月前的文件状态.因此,如果我们也可以将SVN用于本地项目,那就太棒了.
有谁知道如何在本地设置svn以保持项目的文件版本化?
通过本地,我的意思是我应该能够安装file://或http://localhost/projectName使用wamp 版本的文件.
仅供参考,我使用的是Windows 7.
我正在构建我的自定义库以合并所有屏幕css样式表,但我不知道如何screen仅为媒体类型获取样式表.例如:
<!-- This should be fetched -->
<link href="http://www.domain.com/style.css" rel="stylesheet" type="text/css" />
<!-- This should be fetched -->
<link href="http://www.domain.com/ie.css" rel="stylesheet" type="text/css" />
<style type="text/css" media="all">
<!-- This should be fetched -->
@import url("http://static.php.net/www.php.net/styles/phpnet.css");
</style>
<style type="text/css" media="screen">
<!-- This should be fetched -->
@import url("http://static.php.net/www.php.net/styles/site.css");
</style>
<style type="text/css" media="print">
<!-- This should NOT be fetched since it is media type print -->
@import url("http://static.php.net/www.php.net/styles/print.css");
</style>
Run Code Online (Sandbox Code Playgroud)
鉴于上面的字符串,我只想提取href和url值.我不知道该怎么做.虽然我尝试过:
preg_match_all("/(url\([\'\"]?)([^\"\'\)]+)([\"\']?\))/", $html, $matches);
print_r($matches);
Run Code Online (Sandbox Code Playgroud)
但它不会归还它.
使用php dom,xpath或regex实现的任何解决方案?
我使用以下方法生成两个连接文件:
concat: {
header: {
src: [
// these will go in header
'assets/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js',
'assets/js/jquery-ui/jquery-ui.js',
'assets/js/select2/select2.min.js',
'assets/js/icheck/jquery.icheck.js',
'assets/uploadify/js/jquery.fileupload.js'
],
dest: 'assets/js/admin_header_common.js'
},
footer: {
src: [
'assets/js/vendor/bootstrap.min.js',
'assets/js/bootstrap-lightbox.min.js',
'assets/js/jqBootstrapValidation.js',
'assets/js/tinymce/tinymce.min.js',
'assets/js/common.js'
],
dest: 'assets/js/admin_footer_common.js'
}
},
Run Code Online (Sandbox Code Playgroud)
现在我想压缩这两个生成的连接文件,所以我这样做:
// minify js
uglify: {
build: {
header: {
src: 'assets/js/admin_header_common.js',
dest: 'assets/js/admin_header_common.min.js'
},
top: {
src: 'assets/js/admin_footer_common.js',
dest: 'assets/js/admin_footer_common.min.js'
}
}
},
Run Code Online (Sandbox Code Playgroud)
但问题是生成的文件没有被压缩.以上uglify声明是好还是我遗失了什么?我只需要压缩两个文件并生成两个单独的目标文件.
非常感谢您的帮助