Is it possible to run Google Page speed from the command line? - google-chrome

Is it possible to run Google Page speed from the command line? If so, how? I'm interested in automating nightly or daily Google PageSpeed calls that will inform me after a commit or daily if I've caused a drop in the Google PageSpeed 'grade' (for a given page).

It's possible to use the PageSpeed Insights from the command line:
Install via:
$ npm install --global psi
Usage:
$ psi <url> --key=<key> --prettyprint=<true> --userIp=<userIp> --locale=<locale> --strategy=<desktop|mobile>
Run it like this: $ psi http://stackoverflow.com
Also for mobile insights: $ psi http://stackoverflow.com --strategy=mobile
UPDATE: You can use the PageSpeed Insights within your local development environment (internet connection required) with grunt + grunt-pagespeed + ngrok. Checkout the sample project for grunt-pagespeed and ngrok for further information.
Note: Run $ ngrok -authtoken <your-token> 80 and check the web interface parameters to make sure to set the right port in your Gruntfile.js!

There is a Google Page Speed API. It won't work directly from a command line but you can easily write a script in your language of choice that will interact with the API.

You can use curl to run PageSpeed from command line like so:
curl "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=http://your_url/&prettyprint=true&strategy=mobile&key=your_api_key"
It will return human readable results in json. cmd-F "score" to locate the overall score.
Reference : Official Google api.

Related

Open up multiple PWA using the google-chrome cli option

I wanted to open multiple PWA's (Progressive Web Apps) like Twitter, Google-Keep, and Youtube Music at the StartUp of Ubuntu.
There are particular app-id for each of the above sites, which are located as a folder at ~/.config/google-chrome/Default/Extensions/
Twitter - jgeocpdicgmkeemopbanhokmhcgcflmi
Google Keep - hmjkmjkepdijhoojdojkdfohbdgmmhki
YouTube Music - cinhimbnkkaeohfgghhklpknlkffjgod
So currently, to open these three PWA's at startup, I need to use three different CLI commands like the below at Ubuntu's Startup Application Preferences
/usr/bin/google-chrome --profile-directory=Default --app-id=jgeocpdicgmkeemopbanhokmhcgcflmi
/usr/bin/google-chrome --profile-directory=Default --app-id=hmjkmjkepdijhoojdojkdfohbdgmmhki
/usr/bin/google-chrome --profile-directory=Default --app-id=cinhimbnkkaeohfgghhklpknlkffjgod
How do I combine the above three commands to present an array of app-ids? I couldn't find anything in the man pages as well.
Is there any documentation related to the above?
Asked a similar question #here
Posted on your similar question...
The following code is modified from code based on this site's example.
For your shell script
for appid in "$#"
do
/usr/bin/google-chrome --profile-directory=Default --app-id=$appid &;
done
The command to call it
sh my-script.sh jgeocpdicgmkeemopbanhokmhcgcflmi hmjkmjkepdijhoojdojkdfohbdgmmhki
Further Ideas
Have a configuration file that houses the IDs you want to open, and use the shell script to loop through the IDs in the config as opposed to the command line arguments.

Clasp Could not read API credentials. Are you logged in globally?

I'm logging in with clasp login --creds <file> which produces a local .clasprc.json file.
It says that I am logged in, but when I run another command I get:
Could not read API credentials. Are you logged in globally?
Any thoughts on why its not looking at my local clasprc file first?
Currently using version clasp v. 2.2.0
I ran into the same problem on Windows 10 and found that you need to login both globally and locally to use clasp run. There should be a .clasprc.json file in both your project folder and user folder.
I think I have finally found the solution for the same problem
Follow along with the comments from this github issue
Add the "oauthScopes" field to your local code and push it to your app
If you can't push, then copy-paste it to manifest file in the browser
Then you have to publish the app, and there were few things I've done, not sure which one helped. In the app in browser:
add the app version in File->Manage Versions
Publish -> Deploy as API executable
try to login with clasp and creds.json file
try to run something clasp run testRun
it may show the error that you're missing some oauth permissions, but it will list which ones, and you can add them
In my case, one weird thing that also helped was to enable some Google API
so in the app in browser: Resources -> Advanced Google Services -> enable some API
then try to do clasp run
if it works, you can disable the API that you have enabled previously.
Hope that helps

How to access repo directory in a Perl program in Openshift?

I hit the 404 error when I use the following the code in index.pl (I only create one perl app in my account)
my $hello_link = "$ENV{'OPENSHIFT_REPO_DIR'}hello.pl";
Click <font color="FF00CC">here</font> to run hello world cgi.</br>
When I log to my web autortl-rdlgen.rhcloud.com and click on ¨Here"to run hello program. The error message showed
Not Found
The requested URL /var/lib/openshift/550f4df1fcf933b971000030/app-root/runtime/repo/hello.pl was not found on this server.
I do have uploaded hello.pl to my repo directory and can find it after SSH to my account:
[autortl-rdlgen.rhcloud.com repo]\> ls -tr hello.pl
hello.pl
You need to use a relative link like this "./hello.pl" instead of using the other link with the ENV variable, which is showing the complete filesystem path to your perl file.
You may want to check out some Perl tutorials to help you get started with your Perl web programming: http://www.tutorialspoint.com/perl/perl_cgi.htm

Why won't RHC tell me what all apps are available?

I write rhc apps and the reply is...
...
Deployment: auto (on git push)
php-5.4 (PHP 5.4)
-----------------
Gears: 1 small
←[32mYou have access to 2 applications.←[0m
but it won't tell me their names. How can I get a verbatim list of the application names?
Strange.. ! but when i tried my machine with that command i got the list of apps .
Try these commands also
rhc apps -l <your login>
rhc apps --mine

Copy PDF file from Google drive to remote server

I've built nice browsing window which shows all of the pdf files on my (or any user) Google Drive for managing purposes.
What i looking to do is simple, i want to take a pdf file from my google drive (i have all the info related to this file - "downloadUrl","webContentLink" etc) and just copy it to my server (remote).
Any thoughts?
I guess I'm pretty late here, but this may help other people too.
You could try using Grive. Here's a straightforward tutorial: http://xmodulo.com/2013/05/how-to-sync-google-drive-from-the-command-line-on-linux.html
Even if you don't have root access on the server, you can simply build from source, and:
$ mkdir ~/google_drive
$ cd ~/google_drive
$ grive -a
You'll receive an auth URL which you need to paste on your browser and click on "Allow Access" and you're done. Go to the google_drive dir on your server and run grive to sync between your local dir and your GDrive.