Skip to content

Instantly share code, notes, and snippets.

View jphenow's full-sized avatar
💻
👋🏻 :octocat:

Jon Phenow jphenow

💻
👋🏻 :octocat:
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jphenow on github.
  • I am jphenow (https://keybase.io/jphenow) on keybase.
  • I have a public key ASDK6Z0QVCc08S2Lyl-7s7wfn3B7v7HAfNlaV9eiH7HiyQo

To claim this, I am signing this object:

@jphenow
jphenow / lpstat_email.py
Created July 10, 2011 22:42
Quick little script for Linux admins. Run periodically and setup to email someone with a description of printers that may happen to go down. Currently only written to run lpstat on localhost, so must be printers avilable to the localhost.
#! /usr/bin/python
"""
Description: Will run an lpstat -p and send an email to jtrutwin notifying him of a disabled printer, if there is one, so that he can take action.
TODO:
1) Add parameter to override the recipient of the email
2) Add functionality for only sending email when a printer hasn't been found to be disabled today - ie. email sent at 5am shouldn't be sent again if only that same printer is disabled as of 8am, should only send another email if another printer has been disabled or if the original printer has been disabled, enabled and re-disabled.
"""
import commands
#!/usr/bin/env bash
set -e
# Set to your project name
project="Highrise.VisualStudio.Plugin"
assetPath="$project/bin/Release/net461"
targetReleaseDir="./release"
# Find mpack asset from bin dir and make sure it's the latest one
@jphenow
jphenow / scrape
Created January 26, 2017 22:28
Scrape Slack html for a team's emojis, download them and rename them so you can use elsewhere
#!/usr/bin/env ruby
# Go to emoji customization page on your Slack org
# download the html for that page
# Also need "nokogiri" installed
#
# Usage: scrape <htmlfile>
require 'nokogiri'
require 'open-uri'
file = ARGV[0]
@jphenow
jphenow / active_record_mongoid_query_differences.rb
Created December 23, 2013 17:00
ActiveRecord/Mongoid query combing differences
##################
# Mongoid #
##################
League.org_id(1)
#=> #<Mongoid::Criteria
# selector: {:org=>{"$in"=>[1]}},
# options: {},
# class: League,
# embedded: false>
@jphenow
jphenow / circle.yml
Last active June 14, 2016 17:08
9.5 became the Postgres Default on Circle CI
# ...
dependencies:
override:
# Delete these two lines
- sudo service postgresql stop 9.4
- sudo cp -v /etc/postgresql/9.{4,5}/main/pg_hba.conf && sudo service postgresql restart 9.5
# ...
database:
override:
# Delete lines like these below. Yours won't be the same, but we had to do something
@jphenow
jphenow / .bashrc
Created March 9, 2016 18:01
Run all go tests in a project without running through vendor dir
# ...
gta() {
base=$(echo $PWD | sed "s|$GOPATH/src/||")
go test $(go list ./... | grep -v vendor | sed "s|$base/|./|")
}
@jphenow
jphenow / tmux.conf
Created February 9, 2016 18:04
a tmux conf that works with new keybindings blah blah
# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# quick pane cycling
@jphenow
jphenow / ams_custom_roots.rb
Created January 8, 2014 16:25
ActiveModel Serializers with custom root bits
require File.expand_path("../config/environment", __FILE__)
require 'rspec'
# Disable for all serializers (except ArraySerializer)
ActiveModel::Serializer.root = false
#
# # Disable for ArraySerializer
ActiveModel::ArraySerializer.root = false
class AMSEnvelope
@jphenow
jphenow / venue_scopes.rb
Created November 20, 2013 19:31
Scope confusion
# Tried on Rails 3.2.{11,12} so far
class Venue < ActiveRecord::Base
scope :org_id, ->(ids) { where org_id: Array(ids) }
end
Venue.org_id(1).org_id(2)
# => Venue Load (0.3ms) SELECT `venues`.* FROM `venues` WHERE `venues`.`org_id` IN (2)
Venue.where(org_id: [1]).where(org_id: [2])
# => Venue Load (0.5ms) SELECT `venues`.* FROM `venues` WHERE `venues`.`org_id` IN (1) AND `venues`.`org_id` IN (2)