This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
try: | |
output = subprocess.check_output(['sudo', 'iwgetid']) | |
print("Connected Wifi SSID: " + output.split('"')[1]) | |
except Exception, e: | |
print e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To modify a python script started from from rc.local follow below steps. | |
1. Login using putty | |
2. ps aux | grep 'the-name-of-your-progam' (The number in the second column is the pid. Use that pid to send the process a termination signal) | |
3. kill -TERM [put-your-pid-here] | |
4. Now check again >> ps aux | grep 'the-name-of-your-progam' | |
5. If program is stopped now modify the program and test it before adding to rc.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Most relay boards are 'ACTIVE LOW' which means: 0 or LOW (0V) = Relay ON, 1 or HIGH (3V3) = Relay OFF. | |
Some relay board have high and low level trigger mode selection. We can use jumper pin to select the mode the mode. | |
If low level level trigger mode is selected then Relay on will occure for control signal 0 / false / ground | |
If high level trigger mode is selected then Relay on will occure for control signal 1 / true / 3V3/ Vcc or Vdd | |
Ref. https://robu.in/product/songle-single-channel-5v-30a-relay-module-power-failure-relay/ | |
Above 5V 30A relay module has trigger mode selection. I have tested it with Low level trigger mode only. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using optocoupler from Raspberry pi GPIO to control the single channel relay board(5v,30A). | |
Optocoupler will protect the Raspberry PI from any back EMF from inductive load like water pump, Cooler or exhaust fans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Add proxy to node.js | |
npm config set https-proxy http://165.225.104.34 | |
## Remove proxy from node.js | |
npm config delete proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VS Code ships with a Git source control manager (SCM) extension. | |
But to use it with GitHub public/private repository please install Git on PC. Make sure to install the latest version of Git. | |
Go to 'https://github.com/' and create new repository for your project. e.g. gitTest | |
Now click on 'Clone or Download' and copy the url .e.g. https://github.com/satishgunjal/gitTest.git | |
Now open the terminal from VS Code and go to the location where you want to create this project directoty. | |
e.g. terminal path:> C:\Users\satish.gunjal\Google Drive\My Projects\Node.js\Workspace | |
'gitTest' Project folder will be created under 'Workspace' folder in file system | |
Now select Terminal Window and type: | |
git config --global user.name <github userID> | |
git clone <URL from github link copied earlier> >> this will create the 'gitTest' folder under 'Workspace' folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ref. https://blog.cloudboost.io/nodejs-pm2-startup-on-windows-db0906328d75 | |
In above document Ref Section : [1b]> PM2 save | |
This section explains how to configure one application and save the configurations. | |
But if we run 'pm2 save' cmd it will override the previous configurations. | |
In order to start multiple applications together load all the applications using command 'pm2 reload ecosystem.config.js --env=production' | |
and then run 'pm2 save' command at the end. It takes a snapshot of currently running Node applications. | |
We can then restore these applications using 'pm2 resurrect'. Same command will be called during windows reboot. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Run below command on terminal from where you want to copy the packeges or supprting files | |
"npm pack" | |
for more details about this command ref. https://docs.npmjs.com/cli/pack.html | |
2. Now copy the entire source code folder icluding 'node_modules' on host PC | |
3. And run below command from host PC terminal 'npm install <name>-<version>.tgz'. Here name is from step 1 | |
4. Now your code should work on host PC. | |
5. In case any error change the project name in 'package.json' on host PC. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Go to C:\Users\<my_username>\AppData\Roaming and locate the .gitkraken folder | |
2. Inside this folder you can find a localRepoCache file. | |
3. Remove the entries that areunwanted/ duplicated, and restart the Gitkraken. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pkg_resources | |
import types | |
def get_imports(): | |
for name, val in globals().items(): | |
if isinstance(val, types.ModuleType): | |
name = val.__name__.split(".")[0] | |
elif isinstance(val, type): | |
name = val.__module__.split(".")[0] |
OlderNewer