Skip to content

Instantly share code, notes, and snippets.

Josh Brody joshmn

Block or report user

Report or block joshmn

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
@joshmn
joshmn / routes.rb
Created Sep 28, 2018
actual routes
View routes.rb
class SiteConstraint
def matches?(request)
request.subdomain != 'my' && request.domain != 'localhost'
end
end
class AppConstraint
def matches?(request)
request.subdomain === 'my' || request.domain == 'localhost'
end
@joshmn
joshmn / config.ru
Last active Jun 5, 2018
this rack app will return whatever http status code you want, too.
View config.ru
# https://gist.github.com/wwalexander/febbc1ba76c8eafa9f94f5cb2573b34d
# https://news.ycombinator.com/item?id=17235270
#
# Make sure this is named config.ru
# install the gem with
# $ gem install rack
#
# Usage: rackup
require 'rack'
@joshmn
joshmn / gemfile_sort.rb
Created Aug 1, 2017
sort your gemfile lol
View gemfile_sort.rb
file = File.read("test.gemfile")
open_group = false
default_groups = [:general]
current_groups = default_groups
gem_groups = {}
gems = {}
file.split("\n").each do |line|
@joshmn
joshmn / contact.rb
Created May 4, 2017 — forked from endymion/contact.rb
Example of integrating a Ruby on Rails app with Zapier using the REST hooks pattern. With support for triggering the REST hooks from Resque background jobs.
View contact.rb
class Contact < ActiveRecord::Base
...
def after_create
if Hook.hooks_exist?('new_contact', self)
Resque.enqueue(Hook, self.class.name, self.id)
# To trigger directly without Resque: Hook.trigger('new_contact', self)
end
end
@joshmn
joshmn / fish.conf
Created May 5, 2016 — forked from Epigene/fish.conf
Fish2 configuration file
View fish.conf
# Path to Oh My Fish install.
set -gx OMF_PATH /Users/augusts/.local/share/omf
source $OMF_PATH/init.fish
# Path to your oh-my-fish.
set PATH /Applications/Postgres.app/Contents/Versions/9.4/bin $PATH
set PATH ~/bin $PATH
set PATH /usr/local/bin $PATH
set -x RACK_ENV development
set -x EDITOR atom
@joshmn
joshmn / powerball.json
Created Jan 13, 2016
Powerball winners
View powerball.json
[{
"date": "2016-01-09",
"winners": [16, 19, 32, 34, 57],
"powerball": 13
}, {
"date": "2016-01-06",
"winners": [2, 11, 47, 62, 63],
"powerball": 17
}, {
"date": "2016-01-02",
View gist:220fe03bc162118e23da
# backup
echo Performing Mediawiki backup...
# Perform MySQL dump
echo Performing MySQL dump...
mysqldump <database_name> -h<database_host> -u<database_username> -p<database_password> > /opt/backup/data/mysql.bck
# Create mediawiki tarball
echo Creating mediawiki tarball...
cd /opt/mediawiki/
@joshmn
joshmn / Readme
Last active Sep 18, 2015
ActiveAdmin Logs
View Readme
Inspired by Gitlab's Admin Logs (app/controllers/admin/logs_controller.rb)
Probably should put things in lib. Put in one file for breviety.
View Generate schema.rb as JSON
# hack of the year
require 'json'
class String
def string_between_markers marker1, marker2
self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
end
end
file = File.read('schema.rb')
You can’t perform that action at this time.