Skip to content

Instantly share code, notes, and snippets.

@belminf
belminf / xsu.sh
Created August 18, 2015 12:57
Export xauth stuff when switching users
#!/bin/sh
# Help
usage() {
echo -e "Usage: $0 <user to switch to>"
}
# Check if we have enough args
if [ $# -ne 1 ]
then
@belminf
belminf / install_tmux.sh
Last active December 14, 2015 14:02
Install tmux statically from source
#!/bin/bash
# Exit on error
set -e
TMUX_URL=https://github.com/tmux/tmux/releases/download/2.1/tmux-2.1.tar.gz
PREFIX=$HOME/local
TMP_DL_DIR="$(mktemp -d --suffix .tmux_install)"
cd $TMP_DL_DIR
## REQUIREMENTS:
@belminf
belminf / install_vim.sh
Created December 14, 2015 13:51
Install VIM from source
## REQUIREMENTS:
# RHEL:
# $ sudo yum install python-devel ruby-devel ncurses-devel
## SOURCE:
# Get from https://github.com/vim/vim/releases
# $ wget https://github.com/vim/vim/archive/v7.4.972.tar.gz
## INSTALL:
@belminf
belminf / public_share.sh
Last active December 31, 2015 23:27
Modify smb.conf to allow guest access to "public" share, using with asuswrt-merlin
#!/bin/sh
# Grant guess access
sed -i '/\[public\]/,/^\[/ s/invalid users.*/guest only = yes\nwritable = yes/' /etc/smb.conf
# Remove user-specific ACLs
sed -i '/\[public\]/,/\[/ {/^\(valid\|invalid\|read\|write\)/d}' /etc/smb.conf
# Kill samba processes running
for pid in $(ps -w | grep [s]mbd | awk '{ print $1 }')
@belminf
belminf / bootstrap.yaml
Last active February 2, 2016 22:47
Ansible playbook used to bootstrap Ubuntu servers. Blog post: http://iambelmin.com/2016/01/03/using-ansible-to-bootstrap-ubuntu/
---
- hosts: all
gather_facts: no
remote_user: root
pre_tasks:
- name: verify python installed
raw: dpkg -s python-simplejson > /dev/null 2>&1
register: python_installed
ignore_errors: True
@belminf
belminf / aws-cli.sh
Last active August 6, 2021 23:27
AWS CLI command to find latest RHEL and Ubuntu images using JMESPath
# Both are limited to HVM-based 64-bit AMIs backed by EBS
# Red Hat's latest GA images
alias ami_rhel="aws ec2 describe-images \
--filters \
'Name=root-device-type,Values=ebs' \
'Name=architecture,Values=x86_64' \
'Name=virtualization-type,Values=hvm' \
'Name=name,Values=*GA*' \
--owners 309956199498 \
@belminf
belminf / test_https_timeout.py
Created March 28, 2016 21:53
Tests timeouts for HTTPS connections
#!/usr/bin/python
#
# Example run:
# time ./test_https_timeout.py example.com 200 10
import httplib
import sys
from time import sleep
@belminf
belminf / log_active_windows.ahk
Created April 21, 2016 19:48
AutoHotkey script to detect current window
LastTitle := ""
while true {
WinGetActiveTitle, Title
if (LastTitle != Title)
{
LastTitle := Title
FileAppend, %LastTitle%`n, %A_Desktop%\active_windows.txt
}
}
@belminf
belminf / watch_apache_log.sh
Created May 19, 2016 20:03
Capture Apache debug
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License <gnu.org/licenses/gpl.html> for more details.
@belminf
belminf / caesar_cipher.py
Last active July 22, 2016 23:57 — forked from tmessinis/caesar_cipher.py
An implementation of a simple caesar cipher
# This is an attempt at creating a caesar cipher using the ord()
# function and taking input from the user.
import re
def caesar_cipher(mode, input_str, key):
return_str = ''
char_as_num = None
num_as_char = None
char_after_cipher = None