Skip to content

Instantly share code, notes, and snippets.

View ploubser's full-sized avatar

Pieter Loubser ploubser

View GitHub Profile
@ploubser
ploubser / ruby
Last active April 21, 2020 15:13
recursive_rename from moodle
#!/usr/bin/env ruby
#coding:utf-8
# This script is used to rename files to the name of their parent directory when downloaded from moodle.
# Given
#├── user1
#│   └── foo.pdf
#└── user2
# └── foo.pdf
#
@ploubser
ploubser / port.rb
Created April 6, 2017 14:19
Port malarkey
require 'socket'
require 'openssl'
def is_ssl_enabled?(tcp_socket)
ctx = OpenSSL::SSL::SSLContext.new
ctx.set_params({ :options=>OpenSSL::SSL::OP_ALL })
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
enabled = true
OpenSSL::SSL::SSLSocket.new(tcp_socket, ctx).tap do |socket|
---
:name: Test Policy 3000
:confine:
:operatingsystem: Darwin
:rules:
- :description: The JGrep package must be installed
:severity: 9.0
:resources:
:package/jgrep:
:ensure: present
psy@Moya ~/work/jjgrep $ cat the.json |jgrep
[
{
"foo": {
"bar": "foo-bar-1"
},
"bar": 1,
"baz": [
1,
2,
diff --git a/plugins/mcollective/pluginpackager/ospackage_packager.rb b/plugins/mcollective/pluginpackager/ospackage_packager.rb
index f8ae444..5c06a6e 100644
--- a/plugins/mcollective/pluginpackager/ospackage_packager.rb
+++ b/plugins/mcollective/pluginpackager/ospackage_packager.rb
@@ -37,7 +37,7 @@ module MCollective
puts "%30s%s" % ["Plugin Type : ", @package.plugintype.capitalize]
puts "%30s%s" % ["Package Output Format : ", @package_type]
puts "%30s%s" % ["Version : ", @package.metadata[:version]]
- puts "%30s%s" % ["Iteration : ", @package.iteration]
+ puts "%30s%s" % ["Revision : ", @package.revision]
On a windows machine, start IRB and
> require 'mcollective'
> result = ""
> cmd = MCollective::Shell.new("echo testing", :stdout => result)
> cmd.runcommand
> cmd.stdout
require 'mcollective'
require 'pp'
require 'json'
# Find the config file. Right now I'm guessing
# This is not going to work in the longrun.
config_file = "/etc/mcollective/client.cfg"
agent = ARGV[0]
action = ARGV[1]
# Arguments go here
require "timeout"
require "systemu"
begin
Timeout::timeout(1) do
systemu("ruby -e 'loop{}'", {}){}
# IO.popen("ruby -e \"exec \"sleep 5\"\"", {}) do |thing|
# puts thing.read
# end
end
HEADERS :
------ ActiveMQ ------
"expires" :
"mc_identity" :
--------- US ---------
"timestamp" :
"reply-to" :
"caller_id" :
require 'mcollective'
require 'pp'
include MCollective::RPC
client = rpcclient("rpcutil")
result = client.agent_inventory
File.open("/tmp/mc_debug.txt", "w") do |f|
result.each do |r|