Skip to content

Instantly share code, notes, and snippets.

@lutter
lutter / keybase.md
Created November 28, 2015 00:51
keybase.md

Keybase proof

I hereby claim:

  • I am lutter on github.
  • I am lutter (https://keybase.io/lutter) on keybase.
  • I have a public key ASAMdYOKJIvnSEUJQf8C8NeUA6UwsXyEw_DgOMYhgzUr9go

To claim this, I am signing this object:

#include <locale>
#include <boost/locale.hpp>
int main() {
boost::locale::generator gen;
std::locale loc = gen("");
std::string lang = std::use_facet<boost::locale::info>(loc).language();
std::string country = std::use_facet<boost::locale::info>(loc).country();
std::cout << "Locale: " << loc.name() << std::endl;
@lutter
lutter / TestMessages_de.properties
Last active May 26, 2016 17:16
Test resources for i18n
# test/puppetlabs/i18n/TestMessages_en.properties
msg1=Das ist deutsch
#! /usr/bin/ruby
# To use this, untar the forge backup tarball from
# http://forge-dl-backup.s3-website-us-west-2.amazonaws.com/ somewhere and
# then run this script, passing the name of the directory where you
# unpacked the tarball.
#
# The script will print the names of the latest version of each tarball;
# you can feed that into something like 'xargs -iF tar xf DIR/F'
@lutter
lutter / shell
Created June 7, 2016 21:21
Puppet augeas and ODBC inst
> puppet apply /tmp/test.pp
Notice: Compiled catalog for host.example.com in environment production in 0.04 seconds
Error: /Stage[main]/Main/Augeas[oracle odbc driver config]: Could not evaluate: Saving failed, see debug
Notice: Applied catalog in 0.02 seconds
# The debug information shows that the tree correctly has a node { "Oracle" { "Driver Logging" = "7" } }
# The failure comes from the Augeas ODBC lens which does not allow spaces in the names of the entries.
# Please file a bug at https://github.com/hercules-team/augeas/issues to make sure this gets addressed
@lutter
lutter / idempotent.rb
Created October 28, 2016 19:32
Idempotent augeas
# We want a function that makes it easier to write down how
# to make idempotent changes with augeas rather than the
# clunky mechanism the augeas Puppet type gives you today.
#
# I was thinking we could achieve this with a function like the following:
augchange(
:find => "/files/etc/hosts/*[ipaddr = '127.0.0.1']",
:create => ["ins 01 before /files/etc/hosts/*[1]",
"set /files/etc/hosts/01/ipaddr 127.0.0.1"],
:tree => {
@lutter
lutter / ssh_authorized_key.prov
Last active March 4, 2017 22:07
Sketch of a libral provider using mruby
#! /usr/bin/env mruby
# -*- ruby -*-
class SshAuthorizedKey
AUTH_KEYS=".ssh/authorized_keys"
LENS="Authorized_keys"
# All methods that get called by the runtime get a context argument that
# provides access to convenience methods
diff --git a/augeas/ffi.py b/augeas/ffi.py
index 6f4b639..6d145a1 100644
--- a/augeas/ffi.py
+++ b/augeas/ffi.py
@@ -5,7 +5,8 @@ ffi.set_source("augeas",
"""
#include <augeas.h>
""",
- libraries=['augeas'])
+ libraries=['augeas'],
@lutter
lutter / test.yaml
Last active March 31, 2017 19:51
Provider testing
---
# Test the behavior of a specific provider.
#
# The tests will generally be destructive; there's no good way to mock what
# external providers do (we could try and intercept execve and/or open, but
# that would still leave lots of ways in which providers can alter a
# system)
desc: check sysv provider
# The name of the provider to test
@lutter
lutter / gist:916731a5503fd5967da7124eb344267b
Created April 8, 2017 05:57
puppet resource for core types
for typ in $(puppet resource -t); do echo $typ; puppet resource $typ > /dev/null; done
augeas
Error: Could not run: Provider augeas has not defined the 'instances' class method
computer
cron
exec
file
Error: Could not run: Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc
filebucket