Skip to content

Instantly share code, notes, and snippets.

View pboling's full-sized avatar
🏓
Ping me if you need me!

Peter Boling pboling

🏓
Ping me if you need me!
View GitHub Profile
@pboling
pboling / gist:5167673
Created March 15, 2013 05:27
Failed to recover with SEVERE error
$ sudo /var/lib/neo4j/bin/neo4j console
Starting Neo4j Server console-mode...
05:23:30,210 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
05:23:30,211 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
05:23:30,211 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/usr/share/neo4j/system/lib/neo4j-server-1.8.1.jar!/logback.xml]
05:23:30,232 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@52c05d3b - URL [jar:file:/usr/share/neo4j/system/lib/neo4j-server-1.8.1.jar!/logback.xml] is not of type file
05:23:30,351 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
05:23:30,357 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
05:23:30,362 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
0
@pboling
pboling / messages.log
Created March 15, 2013 05:35
Latest messages/log output after delete/restart
2013-03-15 05:30:16,530 INFO [neo4j.txmanager]: TM new log: tm_tx_log.1
2013-03-15 05:30:16,556 INFO [neo4j.xafactory]: Opened logical log [/var/lib/neo4j/data/graph.db/index/lucene.log.1] version=0, lastTxId=1 (clean)
2013-03-15 05:30:16,560 DEBUG [neo4j.diagnostics]: --- STARTUP diagnostics START ---
2013-03-15 05:30:16,561 DEBUG [neo4j.diagnostics]: Neo4j Kernel properties:
2013-03-15 05:30:16,563 DEBUG [neo4j.diagnostics]: forced_kernel_id=
2013-03-15 05:30:16,563 DEBUG [neo4j.diagnostics]: read_only=false
2013-03-15 05:30:16,563 DEBUG [neo4j.diagnostics]: neo4j.ext.udc.host=udc.neo4j.org
2013-03-15 05:30:16,564 DEBUG [neo4j.diagnostics]: logical_log=nioneo_logical.log
2013-03-15 05:30:16,564 DEBUG [neo4j.diagnostics]: node_auto_indexing=false
2013-03-15 05:30:16,564 DEBUG [neo4j.diagnostics]: intercept_committing_transactions=false
@pboling
pboling / facebook_throttle.rb
Last active July 10, 2018 14:47
Facebook API Rate Limit Throttler using Sidekiq, does not execute the job inside the lock, to maintain some semblance of performance, just marks it in a counter, which other jobs from the same queue and using the same token will also update, and which will be throttled. Jobs from other queues will not be able to bust the lock until the timer run…
# Mixin to (i.e. include in) any worker class that does FB API calls and should be throttled.
module FacebookThrottle
def perform_throttled(*args, &block)
options = args.extract_options!
user = User.find_by_fb_uid(options[:fb_uid])
if user
if !user.valid_facebook_token? # A bitwise flag managed by flag_shih_tzu gem
puts "Skipping #{self.class} #{user.fb_uid}: Invalid Oauth Token for #{user}"
return false
# DESCRIPTION:
# For auto lazy loading of namespaced objects nested in sub-directories
# This is a custom library loader - Written by Peter Boling
# INSTALLATION:
# 1. Add 'gist-dep' to your Gemfile
# 2. bundle install
# 3. gist-dep add --path lib/handy_gists/nested_lib_loader.rb 6265104/nested_lib_loader.rb
# 4. add the following lines (uncommented) to your config/application.rb inside the `class Application < Rails::Application`
# require "#{config.root}/lib/handy_gists/nested_lib_loader"
# include HandyGists::NestedLibLoader
@pboling
pboling / color_logger.rb
Last active December 28, 2015 03:59
Log Formatter
# Patterned after this LogFormatter:
# https://github.com/QutBioacousticsResearchGroup/bioacoustic-workbench/blob/master/config/initializers/log_formatting.rb
# And some of this:
# http://95.154.230.254/ip-1/encoded/Oi8vcGFzdGViaW4uY29tL1hxRU1keGRT
# Makes as much as possible constant values to not bog down GC and make it whip fast
class ColorLogger
SEVERITY_TO_TAG_MAP = {'DEBUG' => 'meh', 'INFO' => 'fyi', 'WARN' => 'hmm', 'ERROR' => 'wtf', 'FATAL' => 'omg', 'UNKNOWN' => '???'}
SEVERITY_TO_COLOR_MAP = {'DEBUG' => '0;37', 'INFO' => '32', 'WARN' => '33', 'ERROR' => '31', 'FATAL' => '31', 'UNKNOWN' => '37'}
USE_HUMOROUS_SEVERITIES = begin
@pboling
pboling / phone_finder.rb
Last active August 29, 2015 14:11
Find Phone Numbers in Dirty Database
# SQL_PHONE_NORMALIZER Example:
# Lead.find_by_sql(PhoneFinder::SQL_PHONE_NORMALIZER.call(table: 'leads', column_name: 'phone', phone: '(555) 760-2012'))
# User.find_by_sql(PhoneFinder::SQL_PHONE_NORMALIZER.call(table: 'users', column_name: 'phone', phone: '555-223-4027'))
#
# AREL_PHONE_NORMALIZER Example:
# PhoneFinder::AREL_PHONE_NORMALIZER.call(rel: Lead.where(email: 'peter.boling@example.org'), table: 'leads', column_name: 'phone', phone: '(555) 760-2012')
# PhoneFinder::AREL_PHONE_NORMALIZER.call(rel: User.where(email: 'peter.boling@example.org'), table: 'users', column_name: 'phone', phone: '555-223-4027')
#
# See: https://coderbits.com/posts/pCl7og
module PhoneFinder
@pboling
pboling / api_logger.rb
Last active August 29, 2015 14:13 — forked from dblock/api_logger.rb
require 'ext/grape_middleware_logger'
module TrumakerAPI
module Middleware
class ApiLogger < Grape::Middleware::Logger
def after
logger.info "[api] Requested#{request_log}" if !request_log.blank?
if Rails.env.development?
response_body = JSON.parse(response.body.first)
@pboling
pboling / nested_filters.rb
Last active August 29, 2015 14:16
Concern::NestedFilters
module Concern
module NestedFilters
extend ActiveSupport::Concern
CACHE_EXPIRATION = 1.days
NULL_SORT = "LAST"
NestedFilter = Struct.new(:filter_klass, :filter_param_key, :filter_name, :filter_options)
NestedFilterOption = Struct.new(:id, :name)
included do
# Download all repos for an organization
ORG_NAME=trumaker
curl -s https://api.github.com/orgs/$ORG_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
# Download all repos for a user
USER_NAME=pboling
curl -s https://api.github.com/users/$USER_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@pboling
pboling / boolean.rb
Created April 3, 2015 00:01
TrueClass & FalseClass => Boolean Comparable hack
module Boolean
include Comparable
# true > false
def <=>(other)
raise ArgumentError, "Do not know how to compare #{other.class} with TrueClass and FalseClass" unless [TrueClass, FalseClass].include?(other.class)
other ? (self ? 0 : -1) : (self ? 1 : 0)
end
end