Skip to content

Instantly share code, notes, and snippets.

@philk
philk / zen34-blueprint.yaml
Created March 18, 2021 23:51
Zooz Zen34 Home Assistant Blueprint
blueprint:
name: Zooz ZEN34
description: Zooz ZEN34 Switch using the ZWave-JS integration.
domain: automation
input:
zwave_device:
name: Zooz ZEN34
description: "List of available Zooz ZEN34 switch."
selector:
device:
# two keyword args
def method_with_keyword_args(name:, greeting:)
puts "#{greeting} #{name}"
end
# these are the same thing, note how position doesn't matter
method_with_keyword_args(name: "Phil", greeting: "Hello!")
method_with_keyword_args(greeting: "Hello!", name: "Phil")
# one hash arg, opts is just a common variable name for a hash (options or optional hash depending on who you ask)

Keybase proof

I hereby claim:

  • I am philk on github.
  • I am philk (https://keybase.io/philk) on keybase.
  • I have a public key whose fingerprint is BE7D A362 31D6 75AD DD5D 253E 245B F217 B98B B3EA

To claim this, I am signing this object:

@philk
philk / gist:c858c8c6b10ad4db2227
Created January 13, 2015 01:34
list comprehension
results = []
for dev in devices:
if device_byname in dev:
results.append(dev)
{
"facets": {
"0": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "\"server is active\" AND audit_log_event_source:true"
}
},
module Shrinkwrap
class Unwrap
class << self
def download_package(url)
open(url,
:content_length_proc => lambda {
|content_length| puts content_length
},
:progress_proc => lambda {
|size| puts size
Dir['site-cookbooks/*/metadata.rb'].each do |metadata_rb|
cb_path = File.dirname(metadata_rb)
cb_name = File.basename(cb_path)
cookbook cb_name, :path => cb_path
end
def run_container(**kwargs):
if kwargs['once']:
ctrs = s.containers(
image=kwargs['image'],
command=kwargs['command']
)
if len(ctrs) == 1:
return s.inspect(ctrs[0])[0]
else:
ctr = s.run(**kwargs)
@philk
philk / gist:6187361
Created August 8, 2013 18:33
json_event rsyslog forwarder template
$ModLoad imfile
$MaxMessageSize 64k
$template JSON_EVENT,"%msg:::drop-last-lf%\n"
$InputFileName /var/log/cassandra/logstash.log
$InputFileTag cassandra:
$InputFileStateFile cassandra-state
$InputRunFileMonitor
$ActionQueueType LinkedList # use asynchronous processing
$ActionQueueFileName cassandrafwd # set file name, also enables disk mode
$ActionResumeRetryCount -1 # infinite retries on insert failure
2013-06-21_17:08:16.40001 ERROR - Error when processing event
2013-06-21_17:08:16.40005 java.io.IOException: Cannot run program "unzip" (in directory "."): java.io.IOException: error=2, No such file or directory
2013-06-21_17:08:16.40006 at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
2013-06-21_17:08:16.40007 at java.lang.Runtime.exec(Runtime.java:593)
2013-06-21_17:08:16.40008 at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
2013-06-21_17:08:16.40009 at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:254)
2013-06-21_17:08:16.40009 at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:319)
2013-06-21_17:08:16.40010 at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
2013-06-21_17:08:16.40011 at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
2013-06-21_17:08:16.40012 at backtype.storm.util$exec_command_BANG_.invoke(util.clj:324)