Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"log"
gohcl2 "github.com/hashicorp/hcl/v2/gohcl"
hcl2parse "github.com/hashicorp/hcl/v2/hclparse"
)
package main
import (
"fmt"
"io/ioutil"
"log"
"regexp"
"strings"
gohcl2 "github.com/hashicorp/hcl/v2/gohcl"
@mizzy
mizzy / Rakefile
Last active July 26, 2019 06:18
How to share serverspec tests among hosts
require 'rake'
require 'rspec/core/rake_task'
hosts = [
{
:name => 'proxy001.example.jp',
:roles => %w( base proxy ),
},
{
:name => 'proxy002.example.jp',
func compare(t *testing.T, actual, expected interface{}) error {
if actual == nil {
return fmt.Errorf("Expected response should include %#v, but actually %#v", expected, actual)
}
a := actual.(map[string]interface{})
for k, v := range expected.(map[string]interface{}) {
switch p := v.(type) {
case int:
v = float64(p)
package main
import (
"encoding/asn1"
"fmt"
)
type attr struct {
Type int
Version int
#!/usr/bin/env ruby
require 'json'
tfstate_file = ARGV[0]
tfstate = ''
File.open(tfstate_file, 'r') do |f|
tfstate = JSON.load(f)
end
@mizzy
mizzy / dbus-rs.rs
Last active October 11, 2017 04:53
extern crate dbus;
use dbus::{Connection, BusType, Message, Path};
use dbus::arg;
fn main() {
// Get object path by service name
let c = Connection::get_private(BusType::System).unwrap();
let m = Message::new_method_call("org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
dbus-send --system \
--dest=org.freedesktop.systemd1 \
--type=method_call \
--print-reply \
/org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager.ListUnits
dbus-send --system \
--dest=org.freedesktop.systemd1 \
#include "mruby.h"
#include <stdlib.h>
static mrb_value mrb_rand(mrb_state *mrb, mrb_value recv)
{
int n = rand();
return mrb_fixnum_value(n);
}
static mrb_value mrb_srand(mrb_state *mrb, mrb_value recv)
require 'serverspec'
include Serverspec::Helper::DetectOS
include Serverspec::Helper::Exec
p self.methods.grep(/attr/)
# [:attr, :attr_set] と出る
describe {
p self.methods.grep(/attr/)