Skip to content

Instantly share code, notes, and snippets.

@phil-monroe
phil-monroe / .gitignore
Created Dec 17, 2020
Repo specific pry history files
View .gitignore
# 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 Sep 28, 2020
Debug Logging for Rails Autoloading
View autoload-logging.rb
# 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|
View AMIUtils.java
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);
View client-side-style-validation.js
var all = $("[class]")
all.map(function(idx, el) { console.log({ el: el.tagName, id: el.id, class: $(el).attr('class') } ) } )
View apify-browser-events.js
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 Jun 27, 2019
Authenticate Active Admin + Sidekiq w/ OmniAuth (Google)
View oauth_controller.rb
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 Nov 13, 2018
Script to test apify page functions
View apify-tester.js
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() {
View Description.md

This is the title

  • bullet point
  • thing 2
View console_error.txt
TypeError: Cannot read property 'heroku__app' of undefined
at /bundles/kibana.bundle.js?v=9910:92503
at baseFindIndex (/bundles/commons.bundle.js?v=9910:5797)
at Function.<anonymous> (/bundles/commons.bundle.js?v=9910:8712)
at /bundles/kibana.bundle.js?v=9910:92495
at arrayEach (/bundles/commons.bundle.js?v=9910:6760)
at Function.<anonymous> (/bundles/commons.bundle.js?v=9910:8816)
at Object.filterManager.add (/bundles/kibana.bundle.js?v=9910:92493)
at Scope.$scope.filterQuery [as updateFilterInQuery] (/bundles/kibana.bundle.js?v=9910:22553)
at fn (eval at compile (/bundles/commons.bundle.js?v=9910:40962), <anonymous>:4:529)