Skip to content

Instantly share code, notes, and snippets.

@op-ct
op-ct / pupcat.rb
Last active September 29, 2020 20:57 — forked from happymcplaksin/pupcat.rb
pupcat.rb
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'yaml'
user = ARGV[0] || %x{id -u -n}.strip
if user == 'root'
dir = '/opt/puppetlabs/puppet/cache/client_data/catalog/'
@op-ct
op-ct / shareterminal.sh
Created September 2, 2020 16:21 — forked from jvaubourg/shareterminal.sh
Share a read-only tmux session over HTTPS with password
#!/bin/bash
# SERVER:
# sudo apt-get install certbot socat tmux
# sudo ./shareterminal.sh
# Your stage: tmux new-session -As remote
# Your spectators: tmux lsc -t remote
#
# CLIENTS:
# curl -N https://tmux.example.com:1337
@op-ct
op-ct / sample_mocking_spec.rb
Created May 8, 2020 21:21 — forked from hlindberg/sample_mocking_spec.rb
An rspec sample showing some override and mocking of 4.x functions/function loading
require 'spec_helper'
# Example rspec_puppet function rspec test (i.e. subject is the function 'min')
# This works for other rspec subjects as well as a compiler is always involved.
# This kind of mocking can be required when it is not enough to simply override
# a function with another implementation (which can be done with a `let(:pre_condition) { 'function min($x, $y) { ... }'}`
#
# The main difficulty that this overcomes is the need to let the compiler initialize and
# create the context in which it will operate before making any mocks.
#
@op-ct
op-ct / virtualbox_create_vm.sh
Last active December 19, 2023 07:51 — forked from mitsuji/create_vm.sh
VirtualBox create vm shell script
#!/bin/sh
#
# adapted from https://gist.github.com/mitsuji/8397836
#
# For usage, run without arguments
#
VM_NAME=$1
DVD_PATH=${2:---}
OS_TYPE="${3:-${OS_TYPE:-RedHat_64}}"
@op-ct
op-ct / README.md
Created March 18, 2019 17:01 — forked from openscript/README.md
This bash script can be used to encrypt secrets for a Travis CI configuration (`.travis.yml`) with the project specific public key.

Usage

  • Download script travis-encrypt.sh
  • Make it executable chmod +x travis-encrypt.sh
  • Run the script with ./travis-encrypt.sh -r username/repositoryname -e example
    • It will return something like O+woVD9K+PeFrcyu5GCjKSFvfcSPwDW0kyDYEQnNbwt/iSkqjpl2OPA9W//KEKEB9UUSZD+XmQ3Ij0gnvJnOowcWY5sSeJlVEVTrSer0kW6uWpa/uWzDHCBz2YhBnI6u9SfYfMkhDl22pcaCEwaUkmK2gjcVo+v0bS8vAQFz0Na5/WiKj0GkSX50iIGgfaXheuC8KgIC25T0h+czpap7vb13OlblMnClfyTH9+TmAwTlcV7ljXpv1QY+K72L8jK1/CQVZ8quBYrBwwxO2V6cpXRMMCIw4m4lqxUyN4FBGnq7cJ7BWLzeqSMpFBoP+ZxAqS5yem8KLh1VkEo7PVjCkZE6M+2meFf2VJEVUs/KJY9xnH3eDzipWkwXon2qVpCkT7FDEzGFs/DapYsSo7eCO6pUYYhcpaYpWeYV9DSSV0QcrOeZp664iJMHWPSmrs/lESbbHpKWsM/AFVB9X75q/OB+QU0tQxpReZmKw3ZHbDVMlmlwhP8VSiQ05LV2W6gYzADGiUiL6n1X8teeHEVDSZnD7nrxMD/FchnWI5La3tZeFovRMf6hH3NItW+QZaGaGNftJrP488J/F2hCycPJk3+YrxbBCGHE2X379QbkMz3S0B5UiAcJKmwuTstF6X3CCurZVYIkUGGXhnmalPtVpEqxeTiLw5RU6C9z2qSwhhw=
  • Use the encrypted secret in your .travis.yml according to https://docs.travis-ci.com/user/encryption-keys/#Usage
@op-ct
op-ct / codesign.sh
Created May 9, 2018 14:07 — forked from vszakats/codesign.sh
Code-signing PE executables using OpenSSL, osslsigncode (and more)
#!/bin/sh -e
# To the extent possible under law, Viktor Szakats (vszakats.net)
# has waived all copyright and related or neighboring rights to this
# script.
# CC0 - https://creativecommons.org/publicdomain/zero/1.0/
# This script will create a self-signed root certificate, along with a code
# signing certificate in various formats, trying to use the best available
# crypto/practice all along. Then, it will create a test executable and code
@op-ct
op-ct / manual_code_deploy.sh
Created August 7, 2017 14:08 — forked from natemccurdy/manual_code_deploy.sh
Manually trigger code-manager and file-sync
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/797fa9128b7eef1f07be
# This script can be run to manually trigger Code Manager to deploy code from your control-repo. This sort of
# thing is neccesary when, for example:
# - You've turned on Code Manager but have not yet made an RBAC token.
# - You want to pull down the latest version of a Puppetfile module without pushing to your GMS.
# - Something has broken the post-receive hook on your GMS that would've triggered Code Manager.
# - Syntax errors in your Puppetfile prevent you from retrieving those fixes to that Puppetfile.
# - Puppetserver has crashed due to file-sync issues between code and code-staging.
@op-ct
op-ct / Vagrantfile
Created July 30, 2017 19:13 — forked from tknerr/Vagrantfile
Sample Vagrantfile that works with all providers (virtualbox, aws, managed) and in combination with the vagrant-omnibus plugin
#
# Vagrantfile for testing
#
Vagrant::configure("2") do |config|
# the Chef version to use
config.omnibus.chef_version = "11.4.4"
def configure_vbox_provider(config, name, ip, memory = 384)
config.vm.provider :virtualbox do |vbox, override|
@op-ct
op-ct / gerrit_munge.rb
Created November 18, 2016 20:21 — forked from trevor-vaughan/gerrit_munge.rb
Script for Importing things from GitHub into GerritHub
#!/usr/bin/env ruby
require 'json'
require 'yaml'
require 'tmpdir'
# Your GitHub Username
USERNAME='trevor-vaughan'
gerrit_url = %(ssh://#{USERNAME}@review.gerrithub.io:29418/)
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
require 'em-ssh'
require 'amqp'
EM.run do
Signal.trap("INT") do
EM.stop