Skip to content

Instantly share code, notes, and snippets.

View td512's full-sized avatar

Kid td512

View GitHub Profile
@td512
td512 / flickelectric_metering.rb
Last active July 23, 2020 02:06
Meter counting script for Flick Electric users
require 'csv'
csv = CSV.parse(File.read("/tmp/csvdata"), headers: true)
hash = Hash.new
total = 0.0
csv.by_col[3].each_with_index do |val,index|
hash[Date.parse(val)] = 0.0 unless hash.key?(Date.parse(val))
hash[Date.parse(val)] += csv.by_col[5][index].to_f
puts "Processed data for #{Date.parse(val)}: #{csv.by_col[5][index]} kWh"
end
66e7156a-35b0-4799-bcb3-5c933c85b4ab

Keybase proof

I hereby claim:

  • I am td512 on github.
  • I am td512 (https://keybase.io/td512) on keybase.
  • I have a public key ASC5k1PsNIliYEyLeIRDU2f4rYCH_CTPTCWsHX-voQtlQwo

To claim this, I am signing this object:

#!ipxe
# The SAN mounts
set keep-san 1
set iscsi-rootfs iscsi:10.10.10.50::::iqn.2018-06.local.jupiter:windows
sanboot --drive 0x80 ${iscsi-rootfs}
# The Windows-specific files you need (from the Windows installation media)
kernel wimboot
initrd bootmgr bootmgr
@td512
td512 / spotify.scpt
Created April 20, 2018 15:33
Updated Spotify AppleScript for Textual
(*
Copyright © 2018, Theo Morra. All rights reserved.
https://theom.nz/
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
[No password prompt]
Identity=unix-group:sudo
Action=*
ResultActive=yes
class HelloWorld
include Cinch::Plugin
match "hello"
def execute(m)
m.reply "Hello, World"
end
end
@td512
td512 / convert2vz
Last active February 18, 2018 21:54
Quickly converts physical machines to VZ
#!/bin/bash
#
# Monarch Solutions VZ conversion script
CTID=$1
HOST=$2
IP=$3
NS=$4
echo "Starting VZ conversion, CTID $CTID"
# The IP. In this example we'll get it from the environment
ip = ARGV[0]
# First, let's split the IP into octets and map them to integers
ip = ip.split(".").map(&:to_i)
# Now that's done, let's loop through each octet
ip.each do |octet|
# Check if the length of the integer is still more than 1 AND the first character in the octet is 0
while octet.digits.count > 1 && octet[0] == '0' do
# Strip the 0 out
octet[0] == ''

Download files

curl -o file http://url/file

Headers

curl -H "header: value" http://url/path

POST method

curl -XPOST -d "{'key1':'value1'}" http://url/path

POST file to server

curl -XPOST -F "file_param=@file" http://url/path