Skip to content

Instantly share code, notes, and snippets.

@wilvk
wilvk / select_list_regex.py
Last active November 21, 2016 04:05
Selects a subset of a list based on a matching regular expression
#!/usr/bin/python
DOCUMENTATION = '''
---
module: select_list_regex
short_description: Selects a subset of a list based on a matching regular expression
'''
EXAMPLES = '''
- name: Select hosts with the word Admin from a list of all hosts
@wilvk
wilvk / .vimrc
Last active October 3, 2018 22:25
My cross-platform Vim settings
set number " enable line numbers
set nocompatible " cygwin cursor compatibility
set backspace=indent,eol,start " allow backspaces
set ignorecase " ignore case-sensitive search
set pastetoggle=<leader>p " toggle paste mode
" begin vundle code
filetype plugin indent off
syntax off
set rtp+=~/.vim/bundle/Vundle.vim " set the runtime path for vundle
@wilvk
wilvk / sg.py
Last active April 21, 2017 02:49
AWS Security Groups: Modifies an EC2 Security Group to only contain your current external ip address and specifies access to a list of ports (defaults to ports 80 and 443 if none specified). Tested with Python 2.7.12. Requires boto3
#!/usr/bin/python
import boto3
import sys
import os
from urllib2 import urlopen
default_region = 'ap-southeast-2'
default_port_array = [ 80, 443 ]
default_replace_ingress = True
@wilvk
wilvk / php_ansible_packages.txt
Last active April 6, 2017 04:44
Atom Packages for PHP Magento web development with Ansible
auto-reveal-in-sidebar
intentions
linter-ansible-linting
linter-htmlhint
monokai
php-integrator-annotations
php-integrator-call-tips
php-integrator-refactoring
save-session
ansible-snippets
@wilvk
wilvk / vgd.sh
Created April 11, 2017 23:21
Vagrant Global Destroy
#!/bin/bash
vagrant global-status | tail -n +3 | cut -d' ' -f1 | sed '/^$/q'|xargs -I %s vagrant destroy %s
#!/usr/bin/python
from selenium import webdriver
from pyvirtualdisplay import Display
import time
import timeit
def click_link_until_page_changes(browser, link_name, timeout_seconds=300):
start_time = timeit.default_timer()
current_page_id = browser.find_element_by_tag_name('html').id
@wilvk
wilvk / kill_open_files.sh
Created August 16, 2017 06:50
Linux - Kill all processes of deleted files that are still open
#!/bin/bash
lsof|grep deleted|awk '{print $2}'|xargs kill -9
@wilvk
wilvk / testrunning.sh
Created January 1, 2018 02:42
bash script to test if a process is running and do an action if it is or isn't
#!/bin/bash
PROCESS_GREP_STRING=eth
PROCESS_COUNT_THRESHOLD=3
SLEEP_TIMEOUT=5
RUNNING_COMMAND="echo 'Running'"
NOT_RUNNING_COMMAND="echo 'Not Running'"
while :
do
@wilvk
wilvk / Cowbell Roland TR-808.rb
Created January 7, 2018 04:23
Roland TR-808 Cowbell loop on Sonic Pi
use_synth :square
with_fx :lpf, cutoff: hz_to_midi(850), _slide_shape: 4 do
for x in 1..100
play hz_to_midi(540), decay: 0.3, sustain_level: 0.0
play hz_to_midi(800), decay: 0.3, sustain_level: 0.0
sleep 0.2
end
end
@wilvk
wilvk / get_idletime
Created April 22, 2018 10:13
Get the total number of seconds that the ec2-user has been idle - useful for shutting down instances
#!/bin/bash
RAW_TIME=$(w -hs ec2-user | awk '{print $4}')
SECONDS=0
MINUTES=0
TOTAL_SECONDS=0
DAYS=0
if [[ $RAW_TIME = *"days"* ]]; then