Stuck on Google Home Tutorial - go

I am working on an intro to Actions on Google tutorial. I made it to page 4 and I am stuck on the "Fulfillment Webhook and Deployment" stage. I put the sample backend code into a Go file called populationai.go. I'm confused as to how to do the commands listed in the "Using ngrok to locally run the Webhook" section in Windows, as they are designed for a different operating system. Should I be doing these steps in the command prompt of Windows in the first place? Thanks.
https://www.programmableweb.com/news/how-to-get-started-google-actions/how-to/2017/01/31?page=4
Here are the steps I'm confused on:
We start up the Go application, which exposes the API Server via go run populationapi.go
$ go run populationapi.go
We start ngrok to expose a secure public tunnel on port 9000 via the following command:
$ ngrok http 9000
Edit: every time I try the "go run populationapi.go" command it says
'go' is not recognized as an internal or external command,
operable program or batch file.
Edit: my go file is located on my desktop. Is the issue the location of the file? The installer put Go distribution in c:\Go.

The error means you do not have Go installed.
You need to install go, also known as Golang to run that example code they provide on Step 4.
Make sure to follow the installation instructions as well.
It was just an example. You can write the code in any language as well.

Related

Golang run on Windows without deal with the Firewall

I'm working on a Rest API with Go, but everytime I try to run my application with
go run main.go
the Windows Firewall tells me that has blocked some features of my app. I would like to know if there's some way to make my executions without have to Accept everytime.
Change
http.ListenAndServe(":3000", r)
to
http.ListenAndServe("127.0.0.1:3000", r)
If you are calling go run main.go following is happening:
your programm is compiled inside a temporary folder
the compiled binary is executed
But the temporary folder is just for one execution. So the next time when you run your programm via go run another folder is used.
The windows firewall does give you always the information which path your server has and if you remember the paths after each time you will see that there is always a different path.
The windows firewall is so configuread that it remembers the path of each programm. So when the path is changing you will always need to comfirm that the new path is allowed to run on that port.
To fix this you should compile your server. Just run go build and exeute the binaries then inside you project folder. Then you will just have to accept just one time.
Hi I had the same problem:
Try that:
Go to Windows Defender Firewall, in Left side menu you saw Inbound Rules click there, then Right Side menu you will see New Rule... click.
Choose Port opened from window -> Next
Select TCP, then define which ports you want I choose 8080 click Next again, Choose Allow the connection Next, Check All Next, Give any Name Goland or anything you want and press Finish. Thats it
based on #apxp answer
in windows cli this works for me
go build main.go && main.exe
this work for me
go build main.go && .\main.exe
and run using makefile
I think #apxp's answer is the complete explanation of the situation; some time after ask this question I found a way to run my application with:
go build -o ejecutable.exe ; if($?) { .\ejecutable.exe }
Just go to your Windows Firewall notification settings:
Control Panel -> Windows Defender Firewall -> Change notification settings
Uncheck the option for Notify me when Windows Defender Firewall blocks a new app to prevent it from showing the popup.
You can use CompileDaemon to auto re-build your project on file changes, because it runs a build anyway, you'll only have to accept once. Plus, your project will re-build automatically!
Install:
go get https://github.com/githubnemo/CompileDaemon
Example usage:
# Assuming your project looks like and you're in your project working dir
# hello/
# hello.go
# Rebuild on .go file edits and run the hello command after
CompileDaemon -command="./hello"
The WSL run under VM, so you have to execute ifconfig
You will see your IP in the section (eth0:) inet x.x.x.x
This x.x.x.x is the IP you have to put in your browser.

Ros Environment in root

I have a ros (kinetic) environment set up on a raspberry pi 3 and am trying to get ros to execute upon startup via a simple bash script which calls roslaunch. Ros works in the user domain but fails when called from root.
Here is my launch_ros.sh script:
#!/bin/bash
source /home/pi/ros_catkin_ws/devel/setup.bash
export PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages
roslaunch my_pkg pkg_launch.launch
When I run sudo /home/pi/Desktop/ros_launch.sh the roscore crashes with
ERROR: cannot launch node of type [rosout/rosout]: can't locate node
[rosout] in package [rosout] failed to start core service [/rosout]
The traceback for the exception was written to the log file
But, if I comment out
source /home/pi/ros_catkin_ws/devel/setup.bash
and execute /home/pi/Desktop/ros_launch.sh, ros works fine.
Also worthy of noting is if I leave the above source line uncommented when running in the user domain I get the same error as I do in the root. I think this might be pointing me to the solution but I am still very new to ros.
Has anyone come across this issue and found a solution?
In order to run a node as root after changing your shell to root using commands like sudo -i, You can source your current bash profile thats located inside your normal user .bashrc and use it inside root shell.
Try the following code:
#!/bin/bash
source /opt/ros/kinetic/setup.bash
source /home/pi/ros_catkin_ws/devel/setup.bash
export PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages
roslaunch my_pkg pkg_launch.launch
You need to source your workspace devel to be able to find your own package.
But, you need to source ROS devel to be able to use roscd, roslaunch, ...
In the code below I added:
source /opt/ros/kinetic/setup.bash
to source ROS and be able to use it.
PS: If it's still not working you should try a short delay before running roslaunch.
I was accidentally in a conda environment (base only) and it was messing up big-time. Try disabling any Python virtual environments.
It really worked and it inspired me to report that I didn't have rosnode as a program when I was planning to call ROS scripts in my own applications. Calling source .bashrc directly from the Raspberry Pi's system would refresh the terminal, but there was no way for my program to take over. The solution was to place the required ROS environment scripts in a separate script like name init_env.sh and then call source init_env.sh before any other ROS scripts were executed.

Running Aurelia without a server in Firefox

I know a lot of 'recent' JS tech require a server to work, but is there a way to run a simple Aurelia hello world without a server installation, just opening index.html and see my hello world app shown in the browser. It works for angular 1.x and many other JavaScript libraries.
Is the System.import mechanism going to force me to use a server ? Or is there a workaround to read local files, I tried the usual hacks but it did not help as I still get Error: [Exception... "File error: Unrecognized path" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" but the path shown in the error (not pasted here) matches my local path.
The Aurelia starter pack recommends using Firefox to accomplish this goal if you are using the ES2016 starter kit. Firefox is the only browser that supports the use case you are asking about.
For any other browser, you will need to run a server. I recommend using the extremely simple to use http-server that runs on NodeJS.
From within your project directory type the following two commands:
npm install -g http-server
http-server
Then open your browser and navigate to http://localhost:8080 (8080 is http-server's default port. This port can be changed using the -p command line argument.

How to setup Pydevd remote debugging with Heroku

According to this answer I am required to copy the pycharm-debug.egg file to my server, how do I accomplish this with a Heroku app so that I can remotely debug it using Pycharm?
Heroku doesn't expose the File system it uses for running web dyno to users. Means you can't copy the file to the server via ssh.
So, you can do this by following 2 ways:
The best possible way to do this, is by adding this egg file into requirements, so that during deployment it gets installed into the environment hence automatically added to python path. But this would require the package to be pip indexed
Or, Commit this file in your code base, hence when you deploy the file reaches the server.
Also, in the settings file of your project if using django , add this file to python path:
import sys
sys.path.append(relative/path/to/file)

Zend Framework 2 Getting Started on WAMP server

I have been trying to follow this tutorial: Tutorial
I can't get past page 2. When I try to run the command:
php composer.phar create-project --repository-url="http://packages.zendframework.com" C:\wamp\www\zendTutorial
I get these messages:
[RuntimeException]...[Composer\Downloader\TransportException]<br>
The "http://packages.zendframework.com/packages.json" file could not be downloaded: failed to open stream: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
I enabled ssl_module in the Apache modules and php_openssl in PHP extensions and a runtime error window popped up which I didn't read because I thought I would restart the server and everything would be okay.
Then I found out I had to create a private/public key pair so I followed this tutorial: tutorial
But I realized I skipped the step where I have to download WSAS (the 3rd application to download just to get this pig to oink) to export my pk from the keystore and I decided to put on the brakes and ask "really?" Is there a shortcut I can take to bypass all this crap so I can start with the tutorial? I've been at this for the past 3 hours and I am so fed up - it's demoralizing.
Note Another way to install the ZendSkeletonApplication is to use github. Go to https://github.com/zendframework/ZendSkeletonApplication ...
Try it this way. Get git and clone the repository from
https://github.com/zendframework/ZendSkeletonApplication.git
To do this, change in console (cmd.exe) to your workspace and type
git clone https://github.com/zendframework/ZendSkeletonApplication.git
It should create a subfolder ZendSkeletonApplication with the skeleton application inside.
Later when you have your skeleton application project you can run composer as described in the tutorial to get the dependencies.

Resources