Skip to content

Instantly share code, notes, and snippets.

/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/entity/base.rb:26:in `update_attributes': undefined method `each_pair' for :ams1:Symbol (NoMethodError)
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/entity/base.rb:22:in `initialize'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/entity/associations.rb:14:in `new'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/entity/associations.rb:14:in `block in has_one'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/entity/base.rb:52:in `instance_exec'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/entity/base.rb:52:in `_cast_value'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/entity/base.rb:28:in `block in
@kke
kke / cli.rb
Created May 24, 2016 14:02
create_device problem
# getting this:
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/client.rb:59:in `fail_on_error': {"errors"=>["#<Packet::Plan:0x007fb5e3946df8> is not a valid plan"]} (Packet::Error)
# from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/packethost-0.0.5/lib/packet/client.rb:24:in `block (2 levels) in <class:Client>'
require 'packet'
API_KEY=''
PROJECT_ID=''
FACILITY_CODE=''
OS_SLUG=''
#!/usr/bin/env bash
_foo_complete() {
COMPREPLY=()
if [ "$ZSH_VERSION" == "" ]; then
local src="${BASH_SOURCE[0]}"
else
local src="${(%):-%x}"
fi
local dir=$( cd "$( dirname "$src" )" && pwd )
@kke
kke / rubyscript.sh
Last active February 17, 2017 08:29
Ruby version requirement auto discovery wrapper / "conditional shebang"
#!/bin/sh
for ruby in $(which -a ruby); do
if $ruby -e "exit 1 if RUBY_VERSION < '2.1'"; then
exec $ruby -x "$0" "$@"
fi
done
echo "No suitable ruby 2.1+ interpreter found" >&2
exit 1
#!ruby
rvm:
- 2.1.10
- 2.2.6
- 2.3.3
- 2.4.1
env:
- secure: "abcd1234"
- secure: "defg4567"
matrix:
exclude:
stream = Class.new(Queue) { alias_method :write, :push }.new
orig_stdout = $stdout
$stdout = stream
Thread.new do
loop do
puts Time.now
sleep 0.5
end
end
@kke
kke / dsl.rb
Last active June 27, 2017 09:00
module Recipe
Version = Class.new(Gem::Version)
class Definition
attr_reader :options
def initialize(recipe_name, options = {})
@options = options
recipe recipe_name
end
add_message "SensorReport" do
optional :device_id, :uint32, 1
optional :sensor_id, :uint32, 2
optional :timestamp, :uint32, 3
oneof :value do
optional :f, :float, 4
optional :percentage, :uint32, 5
optional :val, :int32, 6
optional :b, :bool, 7
end
SensorReport message = SensorReport_init_zero;
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
message.device_id = 1;
message.sensor_id = (uint32_t)2;
message.which_value = SensorReport_f_tag;
message.value.f = currTemp;
status = pb_encode(&stream, SensorReport_fields, &message);
message_length = stream.bytes_written;
if (!status) {
syntax = "proto3";
message SensorReport {
uint32 device_id = 1;
uint32 sensor_id = 2;
uint32 timestamp = 3;
oneof value {
float f = 4;
uint32 percentage = 5;
int32 val = 6;