Skip to content

Instantly share code, notes, and snippets.

Josh Nichols technicalpickles

Block or report user

Report or block technicalpickles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Aug 10, 2017
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
@technicalpickles
technicalpickles / error.coffee
Created Jun 20, 2014
Simple hubot error handling
View error.coffee
module.exports = (robot) ->
robot.error (err, msg) ->
robot.logger.error "#{err}\n#{err.stack}"
if msg?
msg.reply "#{err}\n#{err.stack}"
You can’t perform that action at this time.