Reduce network traffic for Native Client installation from Chrome Web Store - google-nativeclient

My Chrome app contains three .nexe files for arm, x86-32 and 64-bit processors. When I install this app from Chrome web store, the size of downloaded package is the same as the size of the app containing all .nexe files. Is it possible to optimize this network traffic?
My .nmf file bundled in the app looks like this:
{
"program": {
"arm": { "url": "arm.nexe" },
"x86-32": { "url": "x86_32.nexe" },
"x86-64": { "url": "x86_64.nexe" }
}
}
Thanks

Yes, you can add a platform specific section to your manifest.json. Then the packages will only download the components that are specified for that CPU architecture.
There is documentation for that feature here: https://developer.chrome.com/native-client/devguide/distributing#reducing-the-size-of-the-user-download-package
And there is an example in the SDK as well: examples/tutorial/multi_platform
To summarize the documentation above:
First create a _platform_specific directory in your App package. For each architecture, create a subdirectory with that name:
|-- my_app_directory/
| |-- manifest.json
| |-- my_app.html
| |-- my_module.nmf
| +-- css/
| +-- images/
| +-- scripts/
| |-- _platform_specific/
| | |-- x86-64/
| | | |-- my_module_x86_64.nexe
| | |-- x86-32/
| | | |-- my_module_x86_32.nexe
| | |-- arm/
| | | |-- my_module_arm.nexe
| | |-- all/
| | | |-- my_module_x86_64.nexe
| | | |-- my_module_x86_64.nexe
| | | |-- my_module_x86_32.nexe
Then in the manifest.json file, specify the location of these directories:
...
"platforms": [
{
"nacl_arch": "x86-64",
"sub_package_path": "_platform_specific/x86-64/"
},
{
"nacl_arch": "x86-32",
"sub_package_path": "_platform_specific/x86-32/"
},
{
"nacl_arch": "arm",
"sub_package_path": "_platform_specific/arm/"
},
{
"sub_package_path": "_platform_specific/all/"
}
]
You'll want your .nmf to point to the location of these nexes. The SDK build system has an option to do all of this for you automatically, I'd suggest using it.

Related

Deploy Drupal 9 site from ubuntu local machine to shared hosting

I am newbie with drupal. My Drupal 9.4.3 sit dev.xyz.in created with composer is ready for deployment. I have a linux based shared hosting plan.
My Local web development environment/IDE is :
OS Ubuntu 18.04LTS
php 7.4.3
mariaDB 15.1
local server nginx
My website directory structure – var/www/dev.xyz.in
dev.xyz.in
| - config
| | - sync
| | | - .htaccess
| - drush
| | - Commands
| | - sites
| | - drush.yml
| | - README.md
| - scripts
| | - composer
| - vendor
| | - composer
| | - drush
| | - bin
| | - twig
| | - symphony
| | - …. more
| - web
| | - core
| | - modules
| | | - contrib
| | | - ds
| | - profiles
| | - sites
| | | - default
| | | - default.services.yml
| | | - default.settings.php
| | | - settings.local.php
| | | - settings.php
| | - themes
| | | - contrib
| | | - custom
| | - update.php
| | - .htaccess
| | - …. more
| - .github
| - composer.json
| - composer.lock
| - load.environment.php
| - phpunit.xml.dist
| - README.md
| - .editorconfog
| - .env.example
| - gitattributes
| - .gitignore
I have changed some settings locally on settings.php as given below:
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
include $app_root . '/' . $site_path . '/settings.local.php';
}
and
$settings['trusted_host_patterns'] = [
'^localhost',
];
I have changed some settings locally on settings.local.php as given below:
$settings['rebuild_access'] = TRUE;
changed it to
$settings['rebuild_access'] = FALSE;
How can I deploy my website to linux based shared hosting using ftp (filezilla) and what necessary change will taken before deployment of local website? please help me!

Nginx root directory with nested symlinks

Our website (laravel) project directory is like this:
/home/user/project/{app,route,public_html,storage,...}
New releases are placed in:
/home/user/releases/v1
For some reason we have to link public_html directory for every release, so:
/home/user/releases/v1/public_html > /home/user/project/public_html
Nginx root diretory is:
/home/user/www/site/public_html
Which:
/home/user/www/site > /home/user/releases/v1
Since NGINX will follow symlinks, final root directory would be:
/home/user/project/public_html
Is there a way to fix this situation?
Since the root of your virtual host is /home/user/www/site/public_html and since /home/user/www/site/public_html is a symlink to /home/user/project/public_html and since /home/user/project/public_html is a symlink to your latest release - nginX location blocks will actually search inside /home/user/releases/v1/public_html.
Here is an example. Let's say we have a folder /my_releases. Everytime I publish/deploy a new release I will create a new subfolder inside /my_releases with the version of the release (/my_releases/v1, then /my_releases/v2 and so on). All assets of the release will be inside the corresponding subfolder - so I will have
/my_releases
|
+---- /v1
| |
| +--- /css
| | |
| | +--- /home.a120cd8.css
| |
| +--- /img
| | |
| | +--- /logo.7f40c3a.svg
| |
| +--- /js
| | |
| | +--- /main.ba4de98.js
| |
| +--- /api
| | |
| | +--- /index.php
| | |
| | +--- /routes
| | |
| | +--- /login.php
| +--- /index.html
|
+---- /v2
| |
| +--- /css
| | |
| | +--- /home.7845c7.css
| |
| +--- /img
| | |
| | +--- /logo.23038ad.svg
| |
| +--- /js
| | |
| | +--- /main.acb33f1.js
| |
| +--- /api
| | |
| | +--- /index.php
| | |
| | +--- /routes
| | |
| | +--- /login.php
| +--- /index.html
........ next releases until the end of the world
My nginX is configured in such a way, that my virtual host has
server {
server_name my.personal.web.site;
root /var/www/public_html;
.....
}
Before starting nginX, I have run the following 2 commands:
ln -s -f -n /my_releases/current /my_releases/v1
ln -s -f -n /var/www/public_html /my_releases/current
Then I started nginX - service nginx start. It will now serve v1 of my web site/application.
Now, any time I deploy a new release, I run the following command (replace v2 with the relevant revision)
ln -s -f -n /my_releases/current /my_releases/v2
Don't forget to set the proper filesystem permissions and ownership.

Thymeleaf Template Resolver prefix with Gradle

I'm trying to deploy a Spring Boot application built with Gradle in AWS Elastic Beanstalk but I keep getting this error:
2017-07-05 13:47:17.913 ERROR 2804 --- [nio-5000-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates//articulos/index.html]")] with root cause
java.io.FileNotFoundException: class path resource [templates//articulos/index.html] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) ~[spring-core-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
at org.thymeleaf.spring4.templateresource.SpringResourceTemplateResource.reader(SpringResourceTemplateResource.java:103) ~[thymeleaf-spring4-3.0.3.RELEASE.jar!/:3.0.3.RELEASE]
...
This is my Configuration class:
#Bean
public ViewResolver viewResolver() {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
resolver.setCharacterEncoding("UTF-8");
return resolver;
}
private TemplateEngine templateEngine() {
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.addDialect(new Java8TimeDialect());
engine.addTemplateResolver(templateResolver());
engine.getConfiguration();
return engine;
}
#Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setCacheable(false);
templateResolver.setPrefix("classpath:/templates/");
templateResolver.setSuffix(".html");
return templateResolver;
}
#Bean
public UrlTemplateResolver urlTemplateResolver() {
return new UrlTemplateResolver();
}
And the generated folder structure goes like this:
I've tried changing the prefix of the TemplateResolver to:
/templates
templates
templates/
/templates/
classpath:templates/
classpath:/templates/
My app is packed in a WAR file, with the following Gradle configuration:
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.flywaydb:flyway-core')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile ("org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.0.RELEASE")
compile ("org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.0.RELEASE")
compile ("io.github.jpenren:thymeleaf-spring-data-dialect:3.1.1")
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('mysql:mysql-connector-java')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
ext["thymeleaf.version"] = "3.0.3.RELEASE"
And this is the tree output for the unpacked WAR file, the folder 'templates' seems to be in the classpath:
.
|-- META-INF
|-- WEB-INF
| |-- classes
| | |-- ar
| | | `-- com
| | | `-- reweb
| | | `-- data
| | | `-- repository
| | |-- db
| | | `-- migration
| | |-- static
| | | |-- bootstrap
| | | | |-- css
| | | | |-- fonts
| | | | `-- js
| | | |-- css
| | | |-- img
| | | |-- jquery
| | | | `-- ui
| | | | |-- css
| | | | `-- js
| | | `-- js
| | | `-- articulos
| | `-- templates
| | |-- articulos
| | | |-- aplicaciones
With no luck, any idea? Thanks
One thing to note is that if Thymeleaf doesn't find the template, a differently worded exception is thrown:
org.thymeleaf.exceptions.TemplateInputException: Error resolving
template "articulos/index", template might not exist or might not be
accessible by any of the configured Template Resolvers
FWIW, your code works fine on my machine with a minor modification (casting the TemplateEngine to a SpringTemplateEngine)
This makes me think that your problem is within the template itself - perhaps you are dynamically including a fragment (f.i. via th:replace ot th:include) that tries to link back to '/articulos/index.html' and that doesn't resolve correctly.
I'd try replacing the index.html with the most simple version possible, like this:
<!DOCTYPE html>
<html>
<body>
<div>
Hello world!
</div>
</body>
</html>
and see if it gets loaded.
If that works, try to double check the template's syntax, especially for the double slash (//), because that does look suspicious.

docker - multiple projects on one Dockerfile and docker-compose.yml

I'm starting with Docker and in my opinion is great! Now I'm looking solution for this organization:
Now I have this structure:
Applications
| +--app1
| | +--node_modules
| | +--package.json
| | +--...
| +--app2
| | +--node_modules
| | +--package.json
| | +--...
| ....
| docker-compose.app1.yml
| docker-compose.app2.yml
| ....
| Dockerfile //my personalized image for all projects
But I want reach this:
Applications
| +--app1
| | +--node_modules //empty in host
| | +--package.json
| | +--docker-compose.app1.yml //override compose
| | +--...
| +--app2
| | +--node_modules //empty in host
| | +--package.json
| | +--...
| ....
| +--node_modules //global node_modules folder (linked to projects)
| docker-compose.yml //principal compose
| Dockerfile //my personalized image for all projects
I thinking too about create one global "server" and link all projects on VHosts but how I'll get access to each of project?
You are looking for docker-comopose extends. Thas permits you override previus configurations.
web:
extends: file: common-services.yml
service: webapp
See full documentation in : https://docs.docker.com/compose/extends/#extending-services

convert a `find` like output to a `tree` like output

This question is a generalized version of the Output of ZipArchive() in tree format question.
Just before I am wasting time on writing this (*nix command line) utility, it will be a good idea to find out if someone already wrote it. I would like a utility that will get as its' standard input a list such as the one returned by find(1) and will output something similar to the one by tree(1)
E.g.:
Input:
/fruit/apple/green
/fruit/apple/red
/fruit/apple/yellow
/fruit/banana/green
/fruit/banana/yellow
/fruit/orange/green
/fruit/orange/orange
/i_want_my_mommy
/person/men/bob
/person/men/david
/person/women/eve
Output
/
|-- fruit/
| |-- apple/
| | |-- green
| | |-- red
| | `-- yellow
| |-- banana/
| | |-- green
| | `-- yellow
| `-- orange/
| |-- green
| `-- orange
|-- i_want_my_mommy
`-- person/
|-- men/
| |-- bob
| `-- david
`-- women/
`-- eve
Usage should be something like:
list2tree --delimiter="/" < Input > Output
Edit0: It seems that I was not clear about the purpose of this exercise. I like the output of tree, but I want it for arbitrary input. It might not be part of any file system name-space.
Edit1: Fixed person branch on the output. Thanks, #Alnitak.
In my Debian 10 I have tree v1.8.0. It supports --fromfile.
--fromfile
Reads a directory listing from a file rather than the file-system. Paths provided on the command line are files to read from rather than directories to search. The dot (.) directory indicates that tree should read paths from standard input.
This way I can feed tree with output from find:
find /foo | tree -d --fromfile .
Problems:
If tree reads /foo/whatever or foo/whatever then foo will be reported as a subdirectory of .. Similarly with ./whatever: . will be reported as an additional level named . under the top level .. So the results may not entirely meet your formal expectations, there will always be a top level . entry. It will be there even if find finds nothing or throws an error.
Filenames with newlines will confuse tree. Using find -print0 is not an option because there is no corresponding switch for tree.
I whipped up a Perl script that splits the paths (on "/"), creates a hash tree, and then prints the tree with Data::TreeDumper. Kinda hacky, but it works:
#!/usr/bin/perl
use strict;
use warnings;
use Data::TreeDumper;
my %tree;
while (<>) {
my $t = \%tree;
foreach my $part (split m!/!, $_) {
next if $part eq '';
chomp $part;
$t->{$part} ||= {};
$t = $t->{$part};
}
}
sub check_tree {
my $t = shift;
foreach my $hash (values %$t) {
undef $hash unless keys %$hash;
check_tree($hash);
}
}
check_tree(\%tree);
my $output = DumpTree(\%tree);
$output =~ s/ = undef.*//g;
$output =~ s/ \[H\d+\].*//g;
print $output;
Here's the output:
$ perl test.pl test.data
|- fruit
| |- apple
| | |- green
| | |- red
| | `- yellow
| |- banana
| | |- green
| | `- yellow
| `- orange
| |- green
| `- orange
|- i_want_my_mommy
`- person
|- men
| |- bob
| `- david
`- women
`- eve
An other tool is treeify written in Rust.
Assuming you have Rust installed get it with:
$ cargo install treeify
So, I finally wrote what I hope will become the python tree utils. Find it at http://pytree.org
I would simply use tree myself but here's a simple thing that I wrote a few days ago that prints a tree of a directory. It doesn't expect input from find (which makes is different from your requirements) and doesn't do the |- display (which can be done with some small modifications). You have to call it like so tree <base_path> <initial_indent>. intial_indent is the number of characters the first "column" is indented.
function tree() {
local root=$1
local indent=$2
cd $root
for i in *
do
for j in $(seq 0 $indent)
do
echo -n " "
done
if [ -d $i ]
then
echo "$i/"
(tree $i $(expr $indent + 5))
else
echo $i
fi
done
}

Resources