Skip to content

Instantly share code, notes, and snippets.

View chrisruffalo's full-sized avatar

Chris Ruffalo chrisruffalo

  • Red Hat
  • Charleston, SC
View GitHub Profile
@chrisruffalo
chrisruffalo / clickercheat
Last active December 23, 2015 11:19
Cookie Clicker cheating. This script REQUIRES cookie monster (and JQUERY) to be loaded first!Install Cookie Monster from here: http://cookieclicker.wikia.com/wiki/Cookie_Monster_(JavaScript_Add-on)
// create variable
function ClickerCheat() {
// external settings
this.enabled = false; // enabled at all
this.build = true; // should it build things?
this.click = true; // should it click on the big cookie?
this.golden = true; // should it auto-click golden cookies?
this.upgrade = true; // should it upgrade when available?
this.interval = 1; // ms between 'clicks'
@chrisruffalo
chrisruffalo / mediahelper
Last active August 29, 2015 13:55
Helper for renaming recalcitrant movie files.
#!/usr/bin/perl -w
use File::Basename;
use IMDB::Film;
use XML::Writer;
use IO::File;
use String::Util qw(trim);
@files = (<*.avi>, <*.mkv>, <*.mp4>);
@suffixlist = (".avi", ".mkv", ".mp4");
@chrisruffalo
chrisruffalo / self signed certs
Last active August 29, 2015 13:55
I can almost never remember how to make self-signed certs and I feel like I have to read every guide 3-4 times for it to make sense. I'm collecting the wisdom in one place for me to be able to work it out.
# generate private key
openssl genrsa -aes256 -out fqdn.key 2048
# generate certificate signing request for key
openssl req -new -key fqdn.key -out fqdn.csr
# sign request and generate x509 out (public key)
openssl x509 -req -days 1095 -in fqdn.csr -signkey fqdn.key -out fqdn.crt
# import keys into p12 package
@chrisruffalo
chrisruffalo / cfme_vsphere_create_folder.rb
Last active August 15, 2017 17:08
Add a vSphere folder in CFME 4.2+
# require rbvmomi, should be installed already because it is used by CFME
require 'rbvmomi'
# todo: input options/dialog values/etc
data_center = "RHC-DC-VMware"
folder_path = "test_folder/test_folder/test_folder2"
# todo: possibly validate to make sure folder_path doesn't start with '/' and/or if it does remove it
# determine full path .. the "vm" is because it is a vm folder
@chrisruffalo
chrisruffalo / guac.sh
Created April 11, 2018 16:10
A script that will allow a docker host to start a guacd system of hosts and initialize the postgres database all in one go
#!/bin/bash
POSTGRES_USER=guac
POSTGRES_PASS=guac
POSTGRES_DB=guac
# create storage for postgres container
NEW_VOLUME=false
if [[ "" == $(docker volume ls | grep guac-postgres-volume) ]]; then
printf "Creating a new volume for guac-postgres...\n"
@chrisruffalo
chrisruffalo / cfme_locking.rb
Last active June 4, 2018 18:38
A proposal for a mechanism for creating locks around critical sections in CFME.
###############################################################################################################
# Author: Chris Ruffalo <cruffalo@redhat.com>
#
# -------------------------------------------------------------------------------------------------------------
# Description:
# -------------------------------------------------------------------------------------------------------------
# In some situations in CFME automation it is necessary to access a resource that does not
# support shared access. This code was initially developed to work with a web API that could
# return the same result to multiple workflows and end up with virtual machines having identical
# properties where they should've been unique.
@chrisruffalo
chrisruffalo / download.sh
Created September 19, 2018 19:45
medium article - top1m csv handling
[user@host]$ curl -o top-1m.csv.zip http://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip
[user@host]$ unzip top-1m.csv.zip
[user@host]$ awk -F "\"*,\"*" '{print $2}' top-1m.csv > top-1m.list
@chrisruffalo
chrisruffalo / RandomIterator.java
Created October 19, 2023 15:54
Random Iterator in Java
package io.github.chrisruffalo.pintle.resolution.resolver;
import java.util.*;
/**
* Randomly iterates through a list. This class is not thread
* safe. This is a lot more efficient than the following:
* <pre>
* final List<T> copy = new ArrayList(source);
* Collections.shuffle(copy);