Skip to content

Instantly share code, notes, and snippets.

@matthewskelton
matthewskelton / flows_sanitised.json
Created October 24, 2017 18:47
Sample flow configuration for a Node-RED IoT application
[{
"id": "6ffd9e9e.4b3ea",
"type": "tab",
"label": "Flow 1"
}, {
"id": "d14dd126.35451",
"type": "ttn app",
"z": "",
"appId": "matthewskelton-wutheringbytes-2017",
"region": "eu",
@matthewskelton
matthewskelton / gist:5950922
Created July 8, 2013 17:50
Example of how ohai uses WMI under the hood to determine node data on Windows
# From https://github.com/opscode/ohai/blob/master/lib/ohai/plugins/windows/uptime.rb e803a3f
require 'ruby-wmi'
provides "uptime", "uptime_seconds"
uptime_seconds ::WMI::Win32_PerfFormattedData_PerfOS_System.find(:first).SystemUpTime.to_i
uptime self._seconds_to_human(uptime_seconds)
@matthewskelton
matthewskelton / gist:5950649
Created July 8, 2013 17:12
Restore a WMI repository
C:\>sc config winmgmt start= demand
[SC] ChangeServiceConfig SUCCESS
C:\>sc stop winmgmt
SERVICE_NAME: winmgmt
STATE : 3 STOP_PENDING
...
C:\>winmgmt /salvagerepository %windir%\System32\wbem
WMI repository has been salvaged
@matthewskelton
matthewskelton / gist:5949341
Created July 8, 2013 14:33
chef-client output when WMI is not working on a Windows machine - 80041002 in SWbemLocator indicates that the WMI class is not found.
[2013-07-04T11:29:12+01:00] DEBUG: Loading plugin windows::uptime
[2013-07-04T11:29:12+01:00] DEBUG: Plugin windows::uptime threw exception #<WIN32OLERuntimeError: (in OLE method `ConnectServer': )
OLE error code:80041002 in SWbemLocator
Not found
HRESULT error code:0x80020009
Exception occurred.> C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/base.rb:131
:in `method_missing'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/base.rb:131:in `connection'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/base.rb:47:in `find_by_wql'
@matthewskelton
matthewskelton / gist:5046121
Created February 27, 2013 08:04
Outline of drawing an xmas tree with Graphite (see https://github.com/matthewskelton/GraphiteGreetings)
require 'Graphite'
require 'Logger'
# Change these as needed for your environment
server = "my.graphite.server.url"
log = Logger.new(STDOUT)
prefix = "Test.Me.XmasTree."
# Create the logger to send stats to Graphite with specific timings
logger = Graphite::Logger.new(server,log)