Skip to content

Instantly share code, notes, and snippets.

@benlemasurier
benlemasurier / renew-gpgkey.md
Last active October 11, 2022 15:09 — forked from krisleech/renew-gpgkey.md
Renew Expired GPG key

Renew GPG key

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

@benlemasurier
benlemasurier / kitchen-chef-shell.sh
Last active August 29, 2015 14:27 — forked from mattjbarlow/gist:242b66cdae6938d34419
Chef Shell in Test Kitchen
cd /tmp/kitchen
/opt/chef/embedded/bin/gem install chef-zero
/opt/chef/embedded/bin/chef-zero -d
knife cookbook upload -a -c client.rb
chef-shell -z -c client.rb -o '<YOUR RECIPE>'

Keybase proof

I hereby claim:

  • I am benlemasurier on github.
  • I am benlemasurier (https://keybase.io/benlemasurier) on keybase.
  • I have a public key whose fingerprint is 51ED C5B8 263C EA55 55D4 FB07 CD81 7BCC 7AD9 A0B0

To claim this, I am signing this object:

#!/usr/bin/env ruby
# check-smtp
# ===
#
# This is a simple SMTP check script for Sensu
#
require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'net/smtp'
require 'sensu-plugin/check/cli'
@benlemasurier
benlemasurier / random_mac.go
Created May 28, 2014 15:18
Generate a random MAC address
func randomMAC() string {
macBuf := make([]byte, 3)
if _, err := rand.Read(macBuf); err != nil {
panic(err)
}
return fmt.Sprintf("aa:bb:cc:%02x:%02x:%02x", macBuf[0], macBuf[1], macBuf[2])
}
// determines whether a string represents json data
func isJSON(s string) bool {
var js map[string]interface{}
return json.Unmarshal([]byte(s), &js) == nil
}
f, err := os.OpenFile("testlogfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
defer f.Close()
log.SetOutput(f)
log.Println(string(body))
begin
node_storage = data_bag_item('nodes', node.name)
requested_revision = node_storage['deployments'].last['revision']
rescue Net::HTTPServerException
# data bag item does not exist, create it
new_node = {
'id' => node.name,
'deployments' => [{
'date' => Time.now,
'revision' => 'HEAD',
package main
import (
"fmt"
"sync"
"time"
)
func main() {
const n = 100
@benlemasurier
benlemasurier / Session.php
Last active December 30, 2015 06:59
php session wrapper
<?php
/*
* $handler = new \Session();
* session_set_save_handler($handler, true);
* session_start();
*/
use \SparkLib\Fail;
class Session extends SessionHandler {
public function __construct() {