Skip to content

Instantly share code, notes, and snippets.

Grant Rodgers grantr

Block or report user

Report or block grantr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@grantr
grantr / gist:1105416
Created Jul 25, 2011
Chef mysql master/slave recipes
View gist:1105416
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
View eventing-sources.md

Packages:

sources.eventing.knative.dev

Package v1alpha1 contains API Schema definitions for the sources v1alpha1 API group

@grantr
grantr / main.go
Last active Apr 8, 2019
CEL int to float conversion bug
View main.go
package main
import (
"fmt"
"log"
"strings"
"github.com/golang/protobuf/jsonpb"
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/google/cel-go/cel"
@grantr
grantr / reconciler.go
Last active Mar 25, 2019
A controller interface that can live peacefully in knative/pkg
View reconciler.go
// ObjectReconciler is what the user implements. This is the generic version.
// The controller MUST be aware of whether it's running with CR or CG.
// With this interface, at least the code will be structured similarly
// and the client interaction can converge over time (or not, as desired)
// This is called ObjectReconciler to avoid confusion with existing Reconciler
// interfaces.
type ObjectReconciler interface {
// This could alternately be called ReconcileObject.
Reconcile(context.Context, runtime.Object) error
}
@grantr
grantr / eventing-and-sources.txt
Last active Feb 26, 2019
Percentage of code 2018Q4 - 2019Q1
View eventing-and-sources.txt
Using https://github.com/Harwayne/github-reviews@3c503f6.
$ go run main.go --token_file=$HOME/.github.oauth --owner=knative --repos=eventing --repos=eventing-sources --users=grantr --start=08-31-2018 --end=02-25-2019
2019/02/26 10:57:46 Searching for PRs between 8-31-2018 and 2-25-2019
2019/02/26 10:58:38 Finished listing PRs. 725
2019/02/26 10:58:38 Finished filtering PRs for time. 464
2019/02/26 10:58:38 Finished filtering PRs for authors. 408
2019/02/26 11:10:32 Total PRs: 408. Commented PRs: 162
2019/02/26 11:37:07 Total lines added: 124303
2019/02/26 11:37:07 Total non-authored lines added: 117903
@grantr
grantr / curvecp_handshake.rb
Last active Jul 19, 2018
CurveCP handshake protocol in Ruby
View curvecp_handshake.rb
# A demonstration of the CurveCP handshake protocol. This protocol has many
# favorable security properties described at http://curvecp.org.
#
# In addition to its security advantages, it has the following favorable properties:
# * Needs only 2 messages (1 from client, 1 from server) before application
# messages can be exchanged (3 before the server can send application messages)
# * Does not require the server to keep protocol state between handshake messages.
#
# An overview of the protocol:
#
@grantr
grantr / ssl.thor
Created Jul 10, 2012
ssl cert generation with thor and openssl (ruby 1.9)
View ssl.thor
# Step 1: gem install thor
# Step 2: thor ssl:generate_ca && thor ssl:generate_cert
require 'thor'
require 'securerandom'
class SSL < Thor
desc "generate_ca", "Generate a Root CA"
method_option :name, type: :string, desc: "Common name"
@grantr
grantr / keybase.md
Last active Apr 13, 2016
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am grantr on github.
  • I am grantr (https://keybase.io/grantr) on keybase.
  • I have a public key ASAJ-N6ihtij2BAlmB2DPy4dvJGOh2A4xz7MDMjXzL5DZwo

To claim this, I am signing this object:

@grantr
grantr / spec_helper.rb
Last active Dec 11, 2015
kill new actors in specs
View spec_helper.rb
RSpec.configure do |config|
# terminate actors created during tests
config.before(:each) do
@running_actors = Celluloid::Actor.all
end
config.after(:each) do
new_actors = Celluloid::Actor.all - @running_actors
new_actors.each { |a| a.terminate if a.alive? }
end
@grantr
grantr / gist:4526886
Created Jan 13, 2013
zmq router sockets double connect
View gist:4526886
>> require 'ffi-rzmq'
=> true
>> ctx = ZMQ::Context.new
=> #<ZMQ::Context:0x00000001ae9d30 @io_threads=1, @max_sockets=1024, @context=#<FFI::Pointer address=0x00000001c46690>>
>> r1 = ctx.socket(ZMQ::ROUTER)
=> #<ZMQ::Socket:0x00000001b05170 @receiver_klass=ZMQ::Message, @socket=#<FFI::Pointer address=0x00000001e44e00>, @name="ROUTER", @int_cache=nil, @longlong_cache=nil, @more_parts_array=[], @option_lookup=[nil, nil, nil, nil, 1, 2, 2, 2, 0, 0, nil, 0, 0, 1, 0, 0, 0, 0, 0, 0, nil, 0, 1, 0, 0, nil, nil, 0, 0, nil, nil, 0, nil, 0, 0, 0, 0, 0, 0]>
>> r2 = ctx.socket(ZMQ::ROUTER)
=> #<ZMQ::Socket:0x00000001b074e8 @receiver_klass=ZMQ::Message, @socket=#<FFI::Pointer address=0x00000001cbbe20>, @name="ROUTER", @int_cache=nil, @longlong_cache=nil, @more_parts_array=[], @option_lookup=[nil, nil, nil, nil, 1, 2, 2, 2, 0, 0, nil, 0, 0, 1, 0, 0, 0, 0, 0, 0, nil, 0, 1, 0, 0, nil, nil, 0, 0, nil, nil, 0, nil, 0, 0, 0, 0, 0, 0]>
>> r1.setsockopt(ZMQ::IDENTITY, "r1")
=> 0
You can’t perform that action at this time.