我在运行Nginx的应用程序中包含prerender时遇到问题,我已经定义了一个简单的规则,用于将所有http请求重写为https,但是预渲染在运行GoDaddy证书的https上有一些问题,它会缓存页面但内容为空.我已经在http上测试了它并且工作正常,我现在正在尝试的是,如果我http_user_agent是Prerender,我想保持http网址完好无损,否则将网址重写为https.
欢迎任何帮助/意见/建议.
我有一个Bootstrap Carousel,其中有许多来自Facebook的社交嵌入,包含视频.我不会详细介绍Bootstrap Carousel,因为问题已经在这个简单的jsfiddle中可见,并且是由于Facebook嵌入.
如果您加载此页面:https://jsfiddle.net/1L95vqn4/,并查看"网络标签"上的Chrome开发工具并过滤"XHR"(禁用缓存),您将看到34个请求并加载在您甚至"播放"所有通过Facebook iframe通过ajax加载的视频之前5.8Mb.
我想懒得加载那些fb ajax请求的权重,也就是说,当用户按"播放视频"时只加载那些调用.
我很惊讶我在网上找不到任何相关内容.其他社交网络(例如twitter嵌入)在用户按下播放之前不会加载视频.即使在播放视频之前,Facebook嵌入案例中的大量数据也会被加载(5Mb,15mb,30mb ......).
请注意,仅仅是为了获取有关我实际更复杂问题的信息:在我的网站上,我实际上并没有使用这个iframe而是嵌入了样式(但是不可能在jsfiddle上放置ajax请求或者对我来说太复杂).而我的实际问题是,当您加载旋转木马时,每张幻灯片上有20个facebook嵌入视频,那么当您打开旋转木马时,它会增加巨大的性能.
$.ajax({
url: 'https://www.facebook.com/plugins/post/oembed.json/?url=https://www.facebook.com/cocacola/posts/1526674334016658',
dataType: 'jsonp',
cache: false,
success: function (data) {
try {
var embed_html = (data.html);
$('div#item1').html(embed_html);
} catch (err) {
console.log(err);
}
}
});
Run Code Online (Sandbox Code Playgroud)
有没有办法阻止FB加载所有这些ajax xhr和mp4通过延迟加载或任何其他方式影响性能?
我是 react、js 和deck.gl 方面的新手,想从deck.gl运行基本的入门示例:
我把这段代码放在哪里,我使用哪个扩展名,我是否需要其他文件app.js来运行这个:
import DeckGL from 'deck.gl/react';
import {ArcLayer} from 'deck.gl';
const flights = new ArcLayer({
id: 'flights',
data: [] // Some flight points
});
<DeckGL width={1920} height={1080} layers={[flights]} />
Run Code Online (Sandbox Code Playgroud)
对于这个模糊的问题,我真的很抱歉,但我真的很想采取必要的步骤来让这个例子在 Mac 上运行。我需要安装反应应用程序吗?这是如何运作的?
我在使用 'if(S_IFDIR(stbuf.st_mode))' 行时遇到一些问题。这是测试要递归到的目录的正确方法吗?目前该函数似乎可以正确执行 1 或 2 个循环,然后失败并出现分段错误。
我已经尝试过以下方法,并且可能更多作为条件。
S_ISDIR(st_mode)
((st_mode & ST_IFMT) == S_IFDIR)
S_IFDIR(stbuf.st_mode)
Run Code Online (Sandbox Code Playgroud)
我已经包含了整个函数,因为我担心问题可能出在其他地方。
void getFolderContents(char *source, int temp){
struct stat stbuf;
int isDir;
dirPnt = opendir(source);
if(dirPnt != NULL){
while(entry = readdir(dirPnt)){
char *c = entry->d_name;
if(strcmp(entry->d_name, cwd) == 0 || strcmp(entry->d_name, parent) == 0){
}
else{
stat(entry->d_name, &stbuf);
printf("%i %i ", S_IFMT, stbuf.st_mode);
if(S_IFDIR(stbuf.st_mode)){ //Test DIR or file
printf("DIR: %s\n", entry->d_name);
getFolderContents(entry->d_name, 0);
}
printf("FILE: %s\n", entry->d_name);
}
}
closedir(dirPnt);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试按照正式的入门指南启动和运行Protractor .
命令
webdriver-manager start
Run Code Online (Sandbox Code Playgroud)
似乎运行顺利:
webdriver-manager start
seleniumProcess.pid: 22169
Apr 23, 2014 10:27:46 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.driver to /usr/local/lib/node_modules/protractor/selenium/chromedriver
10:27:46.959 INFO - Java: Apple Inc. 20.65-b04-462
10:27:46.960 INFO - OS: Mac OS X 10.8.5 x86_64
10:27:46.968 INFO - v2.41.0, with Core v2.41.0. Built from revision 3192d8a
10:27:47.021 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: …Run Code Online (Sandbox Code Playgroud) selenium integration-testing selenium-chromedriver angularjs protractor
我正在使用gulp-nodemon
config目录只包含一个文件server.js.
$.nodemon({
script: 'config/server.js',
watch: ['config/**/*.js']
})
.on('restart', function () {
setTimeout(function () {
$.livereload.changed();
}, 1000);
});
Run Code Online (Sandbox Code Playgroud)
输出:
[gulp] [nodemon] v1.2.1
[gulp] [nodemon] to restart at any time, enter `rs`
[gulp] [nodemon] watching: config/**/*.js
[gulp] [nodemon] starting `node config/server.js`
[gulp] [nodemon] watching 34,325 files - this might cause high cpu usage. To reduce use "--watch".
Run Code Online (Sandbox Code Playgroud)
如果我包含一个忽略选项它修复.
ignore: [
'node_modules/**',
'bower_components/**'
]
Run Code Online (Sandbox Code Playgroud)
为什么即使我告诉它只观看配置目录,nodemon也会监视所有内容?
它也从输出中看出它只监视config目录 [nodemon] watching: config/**/*.js
我在我的项目中使用角度过滤器按页面对输出对象进行排序问题是当我使用这样的语法时:
<ul class="catalog-list"
ng-repeat="(key, value) in list | groupBy: 'styl' | toArray | orderBy:'page'">
{{key}}
<li ng-repeat="dziecko in value | filter:search | bookmark:search"
ng-class="{active:isActiveTab(dziecko)}"
ng-click="openItem(dziecko)">
{{dziecko.rodzina}}
<b>{{dziecko.page}}</b>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
Angular将'styl'属性['nowoczesny','klasyczny'..]转换为数字.排序工作正常,但我想获取名称而不是数字.
为什么第二个数组bowerFiles不会过滤到javascript文件.
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
gulp.task('default', function () {
var unfiltered = mainBowerFiles();
console.log('unfiltered files:', unfiltered); // 11 FILES
//var jsRegEx = /js$/i; // tried this way too...
var jsRegEx = new RegExp('js$', 'i');
var bowerFiles = mainBowerFiles(jsRegEx);
console.log('bower files:', bowerFiles); // 11 FILES
});
Run Code Online (Sandbox Code Playgroud)
我试图模仿什么亭子,主文件是做在这里,和它的作品.
有没有办法根据NODE_ENV设置来指定gulp任务?
例如在我的package.json文件中,我有类似的东西:
"scripts": {
"start": "gulp"
}
Run Code Online (Sandbox Code Playgroud)
我有多个gulp任务
gulp.task('development', function () {
// run dev related tasks like watch
});
gulp.task('production', function () {
// run prod related tasks
});
Run Code Online (Sandbox Code Playgroud)
如果我设置NODE_ENV=production npm start,我可以指定只运行gulp production吗?或者有更好的方法吗?
我正在使用React-Navigation,我使用React-Navigation来使用自定义抽屉的功能contentComponent.
const DrawerNavigation = DrawerNavigator({
DrawerStack: { screen: DrawerStack }
}, {
contentComponent: DrawerComponent,
drawerWidth: 300
})
Run Code Online (Sandbox Code Playgroud)
这里DrawerComponent是我的自定义导航抽屉,我使用自定义导航项目,如用户名,个人资料图片,电子邮件地址和其他菜单.
现在每当用户更新他们的个人资料我想刷新我的DrawerComponent时,我都无法找到任何方法来做到这一点.任何人都可以建议我实现这个的好方法吗?