Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Nichols technicalpickles

View GitHub Profile
View mario_fart_mix_2.rb
# Using Sonic-Pi
samps = "/Users/technicalpickles/Dropbox/sonicpi-samples/"
##| use_bpm 120
define :mario_waha do |options={}|
options ||= {}
sample samps, "mlpit_mario_waha.wav", options
end
@technicalpickles
technicalpickles / whyunosleep.rb
Created Nov 7, 2017
Find out what is keeping your Mac display on
View whyunosleep.rb
#!/usr/bin/env ruby
assertions = {}
lines = `pmset -g assertions`.lines.map {|line| line.chomp }
lines.each do |line|
# pid 329(Slack): [0x00004c1d00058b13] 24:48:54 NoDisplaySleepAssertion named: "Electron"
if line =~ /pid (\d+)\((.*)\): \[.*\] (\d+:\d+:\d+) (\w+) named: \"(.*)\"/
pid = $1.to_i
application = $2
date = $3
assertion_type = $4
View monitor.rb
require 'bundler/setup'
require 'faraday'
require 'typhoeus'
require 'typhoeus/adapters/faraday'
require 'pry'
conn = Faraday.new do |faraday|
faraday.adapter :typhoeus
end
@technicalpickles
technicalpickles / configuration.yaml
Created Oct 4, 2016
HomeAssistant group view with nested group
View configuration.yaml
group:
living_room_lights:
name: Living Room Lights
entities:
- light.living_room_lamp
living_room:
name: Living Room
view: yes
entities:
View sleepiq.py
import logging
from datetime import timedelta
from requests.exceptions import ConnectionError as ConnectError, \
HTTPError, Timeout
from homeassistant.components.sensor import DOMAIN
from homeassistant.helpers import validate_config
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
View icecast-admin.rb
require 'faraday'
require 'faraday_middleware'
module Icecast
class Admin < Faraday::Connection
class Error < RuntimeError
end
class AdminError < Error
end
@technicalpickles
technicalpickles / it.coffee
Created Jun 19, 2015
hubot script example with test
View it.coffee
# Description:
# Get help from @yourorg/it for your information technology problems. Oh by the way.... Your Welcome.
#
# Commands:
# hubot it me <problem> - get help from @yourorg/it about your information technology <problem>
module.exports = (robot) ->
robot.respond /it(?: me)?(?: (.*))?/i, (msg) ->
problem = msg.match[1]
@technicalpickles
technicalpickles / inspector
Last active Nov 8, 2020
hubot with debugging
View inspector
#!/bin/bash
set -e
for opt in $* ; do
case "$opt" in
--debug) hubot_debug="coffee --nodejs --debug";;
esac
done
View gist:a4581caa9378549dd59d
def flaky_code()
unless @flaky_code_works
@flaky_code_works = true
raise 'wtf'
end
puts "works eventually lol"
end
View gist:396a55d2c7198cd7090b
class PostsController < ApplicationController
if ENV['HTTP_AUTH_USERNAME'].present? && ENV['HTTP_AUTH_PASSWORD'].present?
http_basic_authenticate_with name: ENV['HTTP_AUTH_USERNAME'], password: ENV['HTTP_AUTH_PASSWORD']
def index
render plain: "Everyone can see me!"
end
end
You can’t perform that action at this time.