How to use Prerenderio with Meteor? - meteor

I would like to use prerenderio with Meteor instead of phantomjs on the server with modulus.
However given the examples they provide, I'm not sure how to integrate it. They only provide a node express middleware which doesn't translate 100%.

For SEO purposes? I mean, what else could it be? ;)
Firstly, remove the spiderable package if you haven't already.
Second, drop this at your server-side code (for example server/prerenderio.js):
// Use Prerender with your token
var prerenderio = Npm.require('prerender-node').set('prerenderToken', 'YOUR_TOKEN');
// Feed it to middleware! (app.use)
WebApp.connectHandlers.use(prerenderio);
If you're wondering about Npm.require (or Meteor.require), See this answer (by me, sorry for shameless plug) for the gist: https://stackoverflow.com/a/16481897/951773
Source: I've used prerenderio successfully for a couple of our clients.
![Good luck!][1]
EDIT:
Since there has been major differences now between express request and response objects to meteor's connect objects, it went to really complicated now. But this has been addressed now and hopefully the PR I put in works:
https://github.com/dfischer/meteor-prerenderio/issues/1
TL;DR Thanks to this question now we have a prerender.io meteor module.

Related

HERE-API using eval and New Function

Is there any way to use the Here API without eval and new Function statements?
(since this kind of statements can be blocked on some environments)
I believe this question is specific to the HERE JavaScript API. For example, from mapsjs-core.js line 154 which is otherwise minimized and obfuscated:
function(){eval("var self = arguments[0];"+b)}
I'm not going to argue whether or not eval('...') and new Function('...') are evil/bad practices as the implication from the question is that their usage is blocked anyway in some environments.
As that is the current implementation for the JavaScript API, an alternative is to use the HERE REST API directly for whichever services you need. You will need to handle Ajax requests without the convenience of the JavaScript SDK, but for some libraries and frameworks it may be necessary to have that level of control anyway. We've recently published some blog posts demonstrating this with React, Angular, and Vue that may be helpful examples.

How to create multiple USE statements in sniff

I'm working on a sniff for PHP_CodeSniffer 3.x. For example, the class declaration class NoInlineFullyQualifiedClassNameUnitTestInc extends \PSR2R\Base\AbstractBase should be split into a uses and class AbstractBase. The sniff detects similar issues for method signatures.
I believe the problem is that I'm generating and inserting multiple use statements at the same line (i.e., same token), but doing so in separate fixer->beginChangeset() ... fixer->endChangeset() sequences. The fixer treats multiple sets of changes to the same token as a conflict, and things get messy (and wrong).
The GitHub issue is here: https://github.com/php-fig-rectified/psr2r-sniffer/issues/9
Has anyone figured out how to do this writing custom sniffs for the latest 3.x CodeSniffer?
You can also use SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff
It turns this
Into this
How to use it?
The best is to use it with EasyCodingStandard like this:
# easy-coding-standard.neon
checkers:
- SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff
Install it:
composer require --dev symplify\easy-coding-standard
Run it:
vendor/bin/ecs check src
Fix it:
vendor/bin/ecs check src --fix
Enjoy and let me know how it works for you.
If any troubles come up, just create an issue here. I'm happy to improve this tool as much as possible.
The problem is multiple Sniffer (fixer) changesets editing the same token. I was able to get the Sniff to work by collecting a list of USE statements and inserting them at the end of the Sniff's processing.
I identified the end of processing by searching backwards from the last token to find the first token of the list of registered tokens.
Edit: Here is the sniff: https://github.com/php-fig-rectified/psr2r-sniffer/blob/master/PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php

How to create a closure from String in Dart?

How to use dart-mirror API to create a anonymous closure dynamically?
Like as the interpreter, compile the code during run-time.
var funcstr='bool (String s){ return (s==null); }';
var func=parseStr(funcstr);
// func(s)-> s==null;
var r=func('false');
// r=false;
so, how to do with "parseStr"?
my project:
http://github.com/stevehsu77/surebet
At the moment there is no way to do this. Dart has no eval and no code generation at runtime.
But it is something Gilad Bracha (the language spec lead of Dart) wants to have (https://groups.google.com/a/dartlang.org/forum/#!topic/misc/6O4g7eEHgOU) at least for the development environment.
Also
We’d like to support more powerful reflective features in the future. These would include mirror builders, designed to allow programs to extend and modify themselves, and a mirror-based debugging API as well.
https://www.dartlang.org/articles/reflection-with-mirrors/
So it'll probably be supported some time in the future. But right now it's not possible.
As mentioned above, Dart does not have eval, however it is possible to load new source code in another isolate using spawnUri().
I am not sure if there are any examples of how to use this. Perhaps post a message on the dart discussion group.
Using isolates and spawnUri() is quite a different than using eval, so it may not be the right fit for your project.

A/B testing with Meteor

What's a simple recipe to do A/B testing using Meteor?
In other words, in a Meteor environment, if I want to keep track of 2-5 versions of each view template without getting lost, is there a package or a de facto setup that's meant for this?
if you are using google analytics and content experiments, you could use this:
https://github.com/reywood/meteor-iron-router-ga/
or implement client side content experiments code yourself.
The only A/B testing package available on Atmosphere is manuel:abtest, which hasn't received any updates since January 2015 and either works very well, or hasn't been used much (it has no functionality issues raised by the community).
This is one solution I thought looked pretty interesting:
https://github.com/krzysu/meteor-ab-test
It's written in coffeescript, but the basic idea is that there is a ABTests handlebars helper that manages switching out the templates and measuring results.

Is there an ObserveOnDispatcher for Windows Store Apps?

I'm using reactive extensions (well, trying, learning) in a windows store app. I have a series of async operations that will eventually navigate to an authorization web page for RTM. Given the reading I've done, I would expect to write something like the following:
var result = rtm
.GetFrob()
.Select(s => rtm.GetAuthenticationUrl(s))
.ObserveOnDispatcher()
.Do(uri => AuthWebView.Navigate(new Uri(uri)))
.First();
However, I can't seem to find a method ObserveOnDispatcher, and further there is no Scheduler.Dispatcher property either, leading me to think on a Windows Store application there is something deeper gong on with the main UI thread and how you reference it.
GetFrob, btw, creates an IObservable sequence using Observable.FromAsync (if that helps with this).
BTW, if I remove that line, I fail in the call to the Navigate as posting it from the wrong thread. So, what is the proper thing to do here to make sure I'm back on the correct thread?
BTW, Excuse the ".Do" operation here, I know it isn't "nice", however, I'm still experimenting in throw-away code.
Many thanks in advance!
Argh. Apparently I just am not good enough at search. :(
Turns out that adding the nuget package Rx-Xaml includes the proper assemblies for the scheduler, etc. Details can be found on the main Rx blog. Of course, my app is back to hanging now, but that may be due to something else dumb on my part.

Resources