Skip to content

Instantly share code, notes, and snippets.

View phil-monroe's full-sized avatar

Phil Monroe phil-monroe

View GitHub Profile
@phil-monroe
phil-monroe / 01_configuration.yaml
Last active June 24, 2024 03:28
Setting up the Davis Vantage Vue with a WeatherLink Live in Home Assistant (https://weatherlink.github.io/weatherlink-live-local-api/)
# Step 1: Ensure that all of the configuration is wired into the main configuration.yaml file.
# I've just so happen to split out my config files, but you can embed all of the following
# in this file if you so choose.
# https://www.home-assistant.io/docs/configuration/splitting_configuration/
sensor: !include sensors.yaml
template sensors: !include template_sensors.yaml
weather: !include weather.yaml
@phil-monroe
phil-monroe / initializers_active_record_extensions.rb
Created March 3, 2022 22:16
Quick way to de-boilerplate Arel usage for ActiveRecord relations
ActiveRecord::Base.include(Maven::ArelProxy::ActiveRecordExtension)
@phil-monroe
phil-monroe / .gitignore
Created December 17, 2020 19:48
Repo specific pry history files
# add this to your project specific .gitignore
# Ignore pry console history for this project - https://gist.github.com/phil-monroe/96bfde675e50ca2dd7080348565b887d
.pry_history
@phil-monroe
phil-monroe / autoload-logging.rb
Last active September 28, 2020 19:06
Debug Logging for Rails Autoloading
# Include this in the config/application.rb of your rails application
require 'colorize'
ActiveSupport::Dependencies.singleton_class.prepend(Module.new do
def load_missing_constant(*args)
arg_str = args.map(&:to_s).select { |arg| arg != 'Object' }.join('::').green
start = Time.now
result = nil
mv_with_indent do |indent|
public class AMIUtils {
static String SELL_WITH_AMI_PACKAGE = "com.maven_labs.maven";
public static void openSellWithAMI(Context context) {
if(isPackageInstalled(SELL_WITH_AMI_PACKAGE, context.getPackageManager())) {
openLink("mavenami://", context);
} else {
try {
openLink("market://details?id=" + SELL_WITH_AMI_PACKAGE, context);
var all = $("[class]")
all.map(function(idx, el) { console.log({ el: el.tagName, id: el.id, class: $(el).attr('class') } ) } )
const crawler = new Apify.PuppeteerCrawler({
launchPuppeteerFunction: () => {
return Apify.launchPuppeteer({
// puppeteer config options
}).then((browser) => {
browser.on('disconnected', console.log)
browser.on('targetchanged', console.log)
browser.on('targetcreated ', console.log)
browser.on('targetdestroyed', console.log)
return browser
@phil-monroe
phil-monroe / oauth_controller.rb
Created June 27, 2019 21:55
Authenticate Active Admin + Sidekiq w/ OmniAuth (Google)
class Admin::OauthController < ApplicationController
def self.authenticated?(request)
session = request.session
session[:email].present? && session[:authenticated_at].present? && (Time.at(session[:authenticated_at]) + 24.hours).future?
end
def self.current_user(request)
session = request.session
OpenStruct.new(email: session[:email],
name: session[:name],
@phil-monroe
phil-monroe / apify-tester.js
Last active November 13, 2018 21:56
Script to test apify page functions
var page = require('webpage').create();
page.onConsoleMessage = function(msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg);
};
page.open('https://seneweb.senegence.com/us/products/anti-aging/collagen-night-pak/', function() {
page.includeJs("https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js", function() {
page.evaluate(function() {

This is a test

  • one
  • two
  • three