Globally configuring Javascript for notebooks on Jupyterhub - javascript

I would like to replace each user's custom.js file with a global version. The only way I can figure out how to do this currently is to overwrite ~/.ipython/profile_default/static/custom/custom.js after a user runs their first ipython notebook and their .ipython directory gets instantiated.
There must be a better way, either by providing some global version of custom.js or by replacing the default custom.js file during installation. In theory, one could also create symbolic links to a global custom.js but this didn't work for me for some reason.
I see that there is a file /srv/notebook/notebook/static/custom/custom.js on my system - but modifying it doesn't alter the custom.js that gets installed for each user.
Any suggestions?

I'm running jupyterhub with dockerspawner, and have just found a solution here.
To make the custom.js file adopted by each user, you can derivate the jupyter/base-notebook image by adding it to each user's custom directory:
ADD ./custom.js /home/$NB_USER/.jupyter/custom/custom.js
Note this path is the path defined in the jupyter notebook doc.
Hope this helps anyone having the same problem.

Related

How to disable backups for custom widgets in Vaadin 7

In my Vaadin application a custom widget which extends AbstractJavaScriptComponent has several files as follows. These files are available in browser:
Comp1Html.js.exe
Comp1Html_bak.js
Comp1Htmlold
Are these bak and old files required? Also, how to remove these unwanted files?
You need to preserve all files that are directly referenced through e.g. a #JavaScript annotation or indirectly referenced by e.g. being included from another script file. The exact details on that is highly depending on the specifics of this particular component.
The easiest way to find out which files are actually needed might be to temporary put a copy of all the files somewhere else and then try removing each file and checking if everything still seems to work.

Versioning in javascript

I have multiple javascript files that are bundled and minified in one file "bundle-min.js" and is linked in one of my html page. Now I want to introduce versioning in those js files. Means when I change any of my js file, I want my bundle file version to be updated. I have found gulp-version-append but I am not sure whether it will help me or not. Also I don't want to update the reference link of bundle-min.js in my html file again and again. I want my html page to get the latest version it self somehow. Is this possible and what's the best approach? Any help?
There are plenty of modules available for this. it depends on your module loader.
Webpack
https://www.npmjs.com/package/webpack-version-file-plugin
https://www.npmjs.com/package/versioning-webpack-plugin
or you can use define plugin for this
https://webpack.js.org/plugins/define-plugin/
Refer
How can I inject a build number with webpack?

How can I effectively edit jupyter notebook's javascript files?

So notebook's js files are all stored in python_packages_folder/notebook/static/notebook/js however when I edit them, no change happens and checking the loaded js files on the browser I find them look like as if they were not edited. Why does this happen?
I had the same problem when I want to temporarily test some use cases. I hacked it by doing the following:
cd python_packages_folder/notebook/static/notebook/js
mv main.min.js main.min.js.bak
cp main.js min.min.js
Then you restart your jupyter and open one notebook you will see all the original (not-minified) javascript files. They all come with an ?v=timestamp suffix, indicating they will be reloaded when you modify them.

How to Overriding Mage_Catalog_Block_Product_View_Options_Type_Select.php in Magento

I am new user of Magento (in customization). I want to override Mage_Catalog_Block_Product_View_Options_Type_Select.php file in local folder. Till I am doing overriding functionality.
Please can any one suggest me which steps should I follow for override this file. And for overriding which other files need to add in local folder.
There are two way to do it
if you want to just override block then copy that file from core to your local folder, please maintain the same folder structure as core.
second way I think this is the bese way to do it by creating an extension you can get more details from here
http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/
Let me know if you have any query
Thanks

Including pdfmake in client side of MEAN-stack project

I have a website built on the MEAN.io stack and am trying to generate PDF files on the client side with pdfmake. One can install pdfmake with bower (it looks like they used browserify to generate the client-side version).
I am struggling to get it to work. Either the injection of pdfmake does not work (I assume it cannot be found) or the pdfmake object is undefined (if I don't add pdfmake as a dependancy). I assume pdfmake needs to be packaged in some way to make it accessible, but I don't know how.
In config/assets.json I added:
"bower_components/pdfmake/build/pdfmake.js"
In the HTML corresponding to the JS file in which I want to use pdfmake I added:
<script src="bower_components/pdfmake/build/pdfmake.js"></script>
<script src="bower_components/pdfmake/build/vfs_fonts.js"></script>
I have set up a basic version on Github. I would really appreciate it if someone could explain to me how to make it possible to make pdfmake available for use in packages/system/public/controllers/index.js, for example.
I was recently have a similar problem. It seems to come from the fact that pdfmake isn't yet "browserfiable." After much troubleshooting, I was able to get it working through simply including the two client-side scripts pdfmake.min.js and vfs_fonts.js via script tags in my build directory. That's it.
Try moving the two script tags out of the bower_components directory and into your build directory. Make sure they're before your bundle.js, or generally whatever scripts need pdfmake.
I don't fully understand how bundled scripts are able to see the global objects created by these two files, but I think it's because they're setting pdfMake to the window object:
(The vfs_fonts.js file starts like this:)
window.pdfMake = window.pdfMake || {}; window.pdfMake.vfs
Since Browserify sets the global object to window, this approach seems to work. (Though I don't fully understand why... see this Github issue on their repo for more explanation and the deglobalify npm package.)
Here's another relevant post I was able to find.

Categories

Resources