Skip to content

Instantly share code, notes, and snippets.

View adrianpike's full-sized avatar

Adrian Pike adrianpike

View GitHub Profile
@adrianpike
adrianpike / sunny_graphite.rb
Created May 12, 2020 02:07
Ardexa Sunny Boy to Graphite
#!/usr/bin/env ruby
require 'socket'
require 'time'
$file = ARGV[0] || "opt/ardexa/sma/logs/{}/latest.csv"
puts "Streaming readings from #{$file}..."
sock = TCPSocket.new 'localhost', 2003
@adrianpike
adrianpike / ff.sh
Created July 3, 2018 22:13
Quick way to find a filename in the usual way you're wanting to find a filename :)
function find_filename() {
if [ "$1" != "" ]
then
find . -not -path '*/\.*' | grep -i $1
else
echo "Need a filename"
fi
}
alias ff=find_filename

Keybase proof

I hereby claim:

  • I am adrianpike on github.
  • I am adrianpike (https://keybase.io/adrianpike) on keybase.
  • I have a public key ASBP5KHHMa5rjc4RMAqTrRocTCxPhivxYiXrUqigzoavpAo

To claim this, I am signing this object:

# https://blog.nvisium.com/2015/06/using-rails-5-attributes-api-today-in.html
class Foobar
def initialize
@foobar = '123'
end
end
require 'active_resource'
class ActiveResource::ConnectionError
def to_s
message = super
message << " Response body = #{response.body}." if response.respond_to?(:body)
message
end
end
@adrianpike
adrianpike / archive.scpt
Created March 26, 2015 17:51
Outlook Archived
-- Put this into your Outlook scripts folder (~/Library/Application Support/Microsoft/Office/Outlook Script Menu Items/)
on run {}
tell application "Microsoft Outlook"
set msgs to current messages
if ((count of msgs) < 1) then return
set mailFolders to mail folders
repeat with fld in mailFolders
if (name of fld is "Archived") then

Keybase proof

I hereby claim:

  • I am adrianpike on github.
  • I am adrianpike (https://keybase.io/adrianpike) on keybase.
  • I have a public key whose fingerprint is 01E0 8AF8 07B0 DB71 C2D4 E6CF 8E7F 01E8 848A 6AB4

To claim this, I am signing this object:

counts: {
foo: {
a: 50
b: 60
}
bar: {
a: 6312
}
zulu:{
c: 21
foo = ['a','b','c']
bars = _.map(foo, function(obj) {
return 'a' + obj;
})
#### VS ####
bars = 'a' + obj for obj in foo
@adrianpike
adrianpike / mp.rb
Last active December 10, 2015 14:29
class MagicalPresenter < Draper::Base
extend ActiveModel::Naming
include ActiveModel::Conversion
attr_reader :changes
def initialize(model, opts = {})
@changes = {}
super(model)
end