!!
This file contains hidden or 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
# See if last statement executed was successful | |
./runSomething | |
if [ $? -eq 0 ]; then | |
echo OK | |
else | |
echo FAIL | |
fi | |
# The return value can also be stored as a variable |
This file contains hidden or 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
# Specific number of iterations | |
for i in $(seq 1 10) | |
do | |
echo $i | |
done | |
# Specify list | |
for x in test.txt misc.txt other.txt | |
do | |
rm $x |
This file contains hidden or 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
# Simple user prompt | |
echo -n "Enter name: " | |
read name | |
echo $name | |
# Read with a prompt | |
read -p "Enter name: " name | |
echo $name | |
# If reading from current shell and not running a separate process, use -e |
This file contains hidden or 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
; maps_caps_to_esc.ahk | |
; AutoHoyKey script to remap Caps lock to Escape key | |
; Double-click the file or run it directly from the | |
; command line to start the script in the background. | |
; To run the script on startup, place in the Startup directory | |
; by pressing `Windows Key + r` and running `shell:startup`. | |
Capslock::Esc |
This file contains hidden or 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
#!/usr/bin/python3 | |
from ftplib import FTP | |
import glob | |
from os import system, path, remove | |
from os.path import join | |
from datetime import datetime | |
import logging | |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') | |
This file contains hidden or 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
# appname/management/commands/django_backup_db.py | |
# Then run with manage.py django_backup_db | |
from ftplib import FTP_TLS | |
from glob import glob | |
from os import system, remove | |
from os.path import join, getmtime, exists | |
from socket import gethostname | |
from django.core.management import BaseCommand, call_command | |
from django.utils.datetime_safe import datetime |
This file contains hidden or 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
# pip install pyopenssl | |
from OpenSSL import crypto, SSL | |
from socket import gethostname | |
from pprint import pprint | |
from time import gmtime, mktime | |
CERT_FILE = "cert.pem" | |
KEY_FILE = "key.pem" | |
def create_self_signed_cert(): |
This file contains hidden or 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
#!/usr/bin/bash | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script needs escalated privs. Exiting" | |
exit 1 | |
fi |
This file contains hidden or 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
# /etc/systemd/system/gunicorn_app.service | |
# sudo python3 -m pip install gunicorn | |
[Unit] | |
Description=My WSGI app | |
After=network.target | |
[Service] | |
Type=simple | |
User=pi | |
WorkingDirectory=/var/www/my_wsgi_ap |