Skip to content

Instantly share code, notes, and snippets.

View mtovmassian's full-sized avatar

Martin Tovmassian mtovmassian

View GitHub Profile
@jbaranski
jbaranski / OracleOpenPort80Centos.md
Created September 26, 2020 02:00
Open Port 80 Oracle Cloud Compute Instance (CentOS)

Open Port 80 Oracle Cloud Compute Instance (CentOS)

FYI This was harder than it needed to be:

  1. Looking at your instance info, find VNIC section, click "Public Subnet".
  2. Click on your security list.
  3. Add a new entry with the following options:
  • "Stateless" = No, "Source" = 0.0.0.0/0, "IP Protocol" = TCP, "Source Port Range" = All, "Destination Port Range" = 80
  1. SSH to your instance.
  2. While SSH'ed in your instance, run command firewall-cmd --permanent --add-service=http.
  3. While SSH'ed in your instance, run command firewall-cmd --reload.
  4. Now start Apache, NGINX, or whatever server you need to on port 80. You can now access from the internet.
@BigOokie
BigOokie / pgrep-regex-example.txt
Last active April 13, 2023 10:58
Use pgrep with regex patterns to identify specific processes and command line flags
Use the following pattern for `pgrep` to identify a running process that contains specific commandline parameters
Note the following pgrep options are needed:
-a, --list-full list PID and full command line
-f, --full use full process name to match
-c, --count count of matching processes
To find a specific process with a specific commandline parameter use the following:
pgrep -a -f "{processname}.*{commandline param}"
@caruccio
caruccio / getopts.md
Last active May 22, 2024 13:27
Read shell options with positional arguments

This example shows how to read options and positional arguments from a bash script (same principle can be applied for other shells).

# some global var we want to overwrite with options
force=false
help=false
log=info
ARGS=() ### this array holds any positional arguments, i.e., arguments not started with dash

while [ $# -gt 0 ]; do
@william8th
william8th / .tmux.conf
Last active June 28, 2024 00:02
Tmux open new pane in same directory
# Set the control character to Ctrl+Spacebar (instead of Ctrl+B)
set -g prefix C-space
unbind-key C-b
bind-key C-space send-prefix
# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
@mihow
mihow / load_dotenv.sh
Last active June 14, 2024 02:15
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@subfuzion
subfuzion / curl.md
Last active July 3, 2024 11:43
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@dedunumax
dedunumax / .gitignore Java
Last active July 4, 2024 00:02
A complete .gitignore file for Java.
##############################
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
@thomasfr
thomasfr / autossh.service
Last active May 9, 2024 16:59
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@shawnbutts
shawnbutts / bytesto.py
Created October 17, 2012 17:33
bytes to to mb, gb, etc in python
def bytesto(bytes, to, bsize=1024):
"""convert bytes to megabytes, etc.
sample code:
print('mb= ' + str(bytesto(314575262000000, 'm')))
sample output:
mb= 300002347.946
"""
a = {'k' : 1, 'm': 2, 'g' : 3, 't' : 4, 'p' : 5, 'e' : 6 }