Skip to content

Instantly share code, notes, and snippets.

@marcomalva
marcomalva / launch-jupyter-notebook.sh
Created September 4, 2022 21:28
[Podman - Launch Jupyter Datascience Notebook]Jupyter Notebook with Python, R, Markdown, and Terminal and RW to ~/work #podman #jupyter
#!/bin/bash
#
# launch datascience-notebook jupypter notebook as podman container with read/write to current folder (~/work folder inside container)
#
# once launched open notebook in web-browser under: http://localhost:10000
# copy token from podman stdout
#
# based on official web site, see https://jupyter-docker-stacks.readthedocs.io/en/latest/using/running.html#using-the-podman-cli
# see also: [Running rootless Podman as a non-root user | Enable Sysadmin](https://www.redhat.com/sysadmin/rootless-podman-makes-sense)
#
@lukaszp
lukaszp / synergyctl
Last active December 31, 2015 02:56
synergyctl
#!/bin/bash
OP=${1}
#-------------
# synergyctl
#
# Lots of fixes to roadst4r/synergyctl "a few minor tweaks" by roadst4r/synergyctl to the script provided by roadst4r @ http://synergy-project.org/wiki/Startup
#
# add support for crypto,logs,screenanme,display values
#-------------
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@liquidgecka
liquidgecka / cron_helper.sh
Last active September 28, 2023 15:35
Cron helper
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]... COMMAND
Execute the given command in a way that works safely with cron. This should
typically be used inside of a cron job definition like so:
* * * * * $(which "$0") [OPTION]... COMMAND
Arguments:
@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@ssimpson89
ssimpson89 / MySQL Replication Check
Last active July 21, 2024 15:05
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=""
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
LAST_ERRNO=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Last_Errno" | awk '{ print $2 }')
SECONDS_BEHIND_MASTER=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"| grep "Seconds_Behind_Master" | awk '{ print $2 }')
IO_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_IO_Running" | awk '{ print $2 }')
SQL_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }')
@massenz
massenz / repset_mongo.sh
Last active March 1, 2017 12:57
Creates and initializes a MongoDb replica set: allows the user to choose the number of members and the starting port number; this should also work on a remote host, but I have only tested it so far on localhost
#!/bin/bash
#
# Starts up a MongoDB replica set
#
# There is a lot of documentation about replica sets:
#
# http://docs.mongodb.org/manual/reference/replica-configuration/
# http://docs.mongodb.org/manual/administration/replica-sets/
#
# To read data from a SECONDARY, when in the client, use:
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@snim2
snim2 / parse_sensors.py
Created January 21, 2012 12:25
Parse the output of the Ubuntu sensors utility
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script parses the output of the Ubuntu 'sensors' utility.
The output of sensors looks like this on my machine:
acpitz-virtual-0
Adapter: Virtual device
@keymon
keymon / mysql_lvm_backupscript.py
Created January 15, 2012 04:17
MYSQL script to backup the DB using LVM
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Requirements
# - Data files must be in lvm
# - Optionally in xfs (xfs_freeze)
# - User must have LOCK TABLES and RELOAD privilieges::
#
# grant LOCK TABLES, RELOAD on *.*
# to backupuser@localhost