Subtract code from app.js - ember.js

To tackle some touch-related problems I have written a script in app.js to reopen and enhance the EventDispatcher. The script is pretty long and contaminates the normally so clean app.js.
So I'd like to have my script in a seperate file and than somehow be imported in app.js. What in your opinion is the best (cleanest) way to do this?
FYI I'm using Ember CLI

I would place the script in file in in public/assets/js and load the script using Modernizr.load (Modernizr's implementation of yes nope) like this inside of script tags just before the closing body tag of your index.html file. In this situation, you could use Modernizr.touch to detect for touch event support on the user's device and, if present, load the touch polyfill/script.
Alternatively, place the file in the same place and load the script inside an if statement using $.getScript(url) in an initializer or the application view.
In both situations the script will not be imported into app.js but will still be loaded and ran.

Related

adding a custom plugin to google-fluentd

I need to capture file descriptors for a given process. This is simular to what collectd's processes plugin does, but need to get this on the fluentd, google-fluentd specifically rails.
I've added my plugin under /etc/google-fluentd/plugin directory and no luck, it is not getting registered. I've even moved under /opt/google-fluentd/embedded/lib/ruby/gems/2.6.0/gems/fluentd-1.7.4/lib/fluent/plugin still no luck. Out of desperation I have also tried renaming in_tail.rb to in_tail2.rb and tail plugin is gone.
2020-08-14 18:28:16 -0700 [error]: fluent/log.rb:362:error: config error file="/etc/google-fluentd/google-fluentd.conf" error_class=Fluent::ConfigError error="Unknown input plugin 'tail'. Run 'gem search -rd fluent-plugin' to find plugins"
Which tells me that there is some other place where plugin must be mentioned. Is it too naive to think that I can just write a single file plugin under /etc/google-fluentd/plugin?
After a few hours of going up and down the call stack in the fluentd trying to figure out the logic behind why and which plugins fluentd loads here is what I figured out.
#type has to match registration call and filename!
ie i had used
#type fc_count
my filename was
/etc/google-fluentd/in_fd.rb
with
Fluent::Plugin.register_input('fd_count', self)
Although type and registration matched, fluent couldn't match file path to plugin/in_fd.rb as it loads configuration. Basically if you don't use a plugin it won't load it and the way it determines it is by going through config. This is the reason why when I renamed an existing input plugin it was no longer found.

Testbox 2.1 - Skip an entire directory or CFC file

We want to create a HelperUtility.cfc with common methods for our tests to use. If we put the file in /tests/lib/HelperUtility.cfc, can we tell TestBox, don't try running any tests in /tests/lib? If not, can we add something to the component tag to skip the entire file, rather than adding skip to all the methods in the component individually?
There's no way to do that unfortunately.
I have tried to skip some manual mocks that were created inside a tests/mock folder, but you cannot configure TestBox at runtime to skip a specific folder if you decide to run the tests for a parent folder.
The only work around that worked for me was to create a specs subfolder in the parent tests and then call the testbox runner with a directory argument of the specs...
For example: http://localhost:8500/testbox/system/runners/HTMLRunner.cfm?directory=tests.specs

What are advantages of using babel-plugin-react-intl?

I've been trying to learn and understand react-intl library and I encountered babel-plugin-react-intl library. There is a description in the library's page like that;
Extracts string messages for translation from modules that use React Intl.
I wonder that which string messages would be extracted?
Also, what are the benefits of extracted messages?
From: https://blog.johnphoto.se/2016/03/21/react-intl-v2/ (couldn't comment without more rep)
Once it is time to get all these messages translated, you only have to
do a webpack build with the babel-plugin react-intl plugin. This will
extract all the defined messages from the code base into JSON files.
These files are then sent to your translators and they translate all
of these messages and the translations is put into a flat JSON hash
and this is then loaded into your code and you have a i18n enabled
app. So enough with theory!
I am using babel-plugin-react-intl to automatically extract all the labels in my React application.
I'd point as main advantages the following two:
Using the plugin, all the labels from my application are automatically extracted to json files. Instead of having to manually update the json files that will be translated. This way, I don't need to worry about this file, as the plugin will push the labels to it.
If I accidentally create a duplicated ID for a label, the plugin tells me that by throwing an error on webpack.
Extra: I am not using, but, if you want to force developers to add a context description for each label, this plugin also has an option to force this behavior so that, if the developer forgets it, an error is thrown on webpack.

What is the format of the django config file for manage.py?

I'm hooking up selenose (selenium) tests and using liveserver in the process. It appears that I automatically start running into problems with ports being used so want to configure liveserver to use more that one port. I see how to do that via the command line (--liveserver=localhost:8100-8110) but would like to use a config file.
I have one I'm using for nose already and thought I might be able to reuse it but can't find anything to support that belief and my test runs say it won't work. I was expecting to be able to add something like the following:
[???]
liveserver=localhost:8100-8110
but replace the '???' with an actual header.
for some reason django uses an environment variable for this. you can set it in your settings if you want
import os
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = 'localhost:8000-9000'

Magento programmatically appending code to template pages

I am developing a Magento extension and would like to run some jQuery script in the footer of the html template.
I have manually edited page.xml layout file to load my jQuery source and manually edited the footer.phtml template file to test my code, but I now want to package it up into an extension. The question is how to do this within my extension configuration, to tell magento to load the new jQuery source library in the header, and to append code somewhere in the footer (or anywhere) in the magento generated theme html.
Create a custom Magento Module
Use this module to add a customer Package Layout Update XML File
Use this Package Layout Update XML files to add a javascript src link to a (CDN?) jQuery, and add a custom block to the before_body_end block
Use this custom block to output your needed Javascript code
Use Magento Connect System->Magento Connect->Package Extensions to package up your customer Magento Module file, as well as any other files on the system you used (phtml template, jQuery files if not using a CDN, etc) into an Extension.
Wouldn't it be easier to use a static block? This way the client or yourself could update the jQuery right in the admin area without going into code. You could also add logic with multiple blocks if you needed. You can display a static block in a template like so:
<?php echo $this->getChildHtml('staticblockname') ?>
Otherwise you might want to read this tutorial on creating a module (which you call an extension): http://magento4u.wordpress.com/2009/06/08/create-new-module-helloworld-in-magento/