Skip to content

Instantly share code, notes, and snippets.

View chris1984's full-sized avatar

Chris Roberts chris1984

View GitHub Profile
@masterzen
masterzen / connect.sh
Created November 15, 2010 07:12
Puppet SSL examples
# this simulates how a puppet agent will connect
openssl s_client -host puppet -port 8140 -cert /path/to/ssl/certs/node.domain.com.pem -key /path/to/ssl/private_keys/node.domain.com.pem -CAfile /path/to/ssl/certs/ca.pem
# outputs:
CONNECTED(00000004)
depth=1 /CN=Puppet CA: master.domain.com
verify return:1
depth=0 /CN=macbook.local
verify return:1
@stevenhaddox
stevenhaddox / server_certificates_to_pem.md
Last active May 8, 2024 07:13
Convert .crt & .key files into .pem file for HTTParty

Two ways to do it, but only worked for me so I'll put it first and the second for reference:

$ openssl pkcs12 -export -in hostname.crt -inkey hostname.key -out hostname.p12
$ openssl pkcs12 -in hostname.p12 -nodes -out hostname.pem

Other options for this method in comments below:

# Note, the -certfile root.crt appends all CA certs to the export, I've never needed these so it's optional for my personal steps
$ openssl pkcs12 -export -in hostname.crt -inkey hostname.key -certfile root.crt -out hostname.p12

Note, I've always had my hostname.crt as part of my .pem, so I keep my certs but apparently you may not have to, hence the nocerts flag being an extra option in this sample

@Integralist
Integralist / 1. sinatra-basic-with-comments.rb
Last active November 9, 2019 20:10
Create basic site using Ruby and Sinatra (and external templates)
#!/usr/bin/env ruby
=begin
install Sinatra: gem install sinatra
install Shotgun: gem install shotgun (this auto-reloads sinatra on every http request - which means every time you make a change in your code you don't have to stop then start sinatra)
To just run your code using Sinatra: ruby name-of-file.rb
To run your code using Shotgun (which is just Sinatra but with ability to auto-reload when changes are made to files): shotgun name-of-file.rb
The following examples are run using Shotgun and the URL is: http://127.0.0.1:9393/
@willurd
willurd / web-servers.md
Last active June 29, 2024 17:26
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@pythonicrubyist
pythonicrubyist / nil_empty_blank_present_ffdierence_in_ruby
Last active February 21, 2024 17:38
Difference between nil?, empty?, blank? and present? in Ruby and Ruby on Rasils.
# nil? can be used on any Ruby object. It returns true only if the object is nil.
nil.nil? # => true
[].nil? # => false
{}.nil? # => false
"".nil? # => false
" ".nil? # => false
true.nil? # => false
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero.
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass
@slouma2000
slouma2000 / install_ruby_1.9.3
Last active May 14, 2019 20:27
Install Ruby 1.9.3 on CentOS, RedHat using RVM
Step 1: Upgrade Packages
# yum update
# yum groupinstall "Development Tools"
Step 2: Installing Recommended Packages
# yum install gcc-c++ patch readline readline-devel zlib zlib-devel
# yum install libyaml-devel libffi-devel openssl-devel make
# yum install bzip2 autoconf automake libtool bison iconv-devel
Step 3: Install RVM ( Ruby Version Manager )
#!/usr/bin/ruby
# Years till 100
require 'optparse'
options = {:name => nil, :age => nil}
parser = OptionParser.new do|opts|
opts.banner = "Usage: years.rb [options]"
opts.on('-n', '--name name', 'Give your own name') do |name|
options[:name] = name;
@jlsherrill
jlsherrill / regenerate_subscription_queues.txt
Last active March 12, 2018 20:21
Re-generate candlepin event queues
CERT=/etc/pki/katello/certs/katello-apache.crt
KEY=/etc/pki/katello/private/katello-apache.key
#create exchange:
qpid-config --ssl-certificate $CERT --ssl-key $KEY -b "amqps://localhost:5671" add exchange topic event --durable
#view exchange:
qpid-config --ssl-certificate $CERT --ssl-key $KEY -b "amqps://localhost:5671" exchanges
#create queue:
qpid-config --ssl-certificate $CERT --ssl-key $KEY -b 'amqps://localhost:5671' add queue katello_event_queue --durable
@mccun934
mccun934 / kt-dbrestore.bash
Last active March 22, 2022 19:07
quick DB restore
## You probably shouldn't run this!
foreman-maintain service stop
systemctl start mongod
systemctl start postgresql
su - postgres -c "dropdb candlepin && createdb candlepin"
su - postgres -c "dropdb foreman && createdb foreman"
mongo pulp_database --eval "db.dropDatabase()"
mongorestore --db pulp_database --host localhost /backup/mongo_dump/pulp_database/
su - postgres -c "pg_restore --disable-triggers -v -d candlepin /backup/candlepin.dump"
@djtech42
djtech42 / jekyllServe.sh
Created December 8, 2015 16:52
Run Jekyll Local Server In the Background Without Output to the Console
jekyll serve > /dev/null 2>&1 &