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 / gist:f4eb8797939da1dadfb1
Created Jun 5, 2014
MLB Draft 2014: If teams were comprised solely of players they drafted (results of each team)
View gist:f4eb8797939da1dadfb1
require 'httparty'
require 'nokogiri'
page = HTTParty.get('')
doc = Nokogiri::HTML(page.body)
i = 0
doc.css('#article-body h3').each do |t|
next if t.text.empty?
team = t.text
joshmn / gist:c5f05792a7afb654c52f
Created Jun 5, 2015
simple up/down/remove/add for select
View gist:c5f05792a7afb654c52f
<div class="row">
<div class="col-sm-4">
<input type="text" placeholder="Item To Add" class="form-control arrayable_item">
<div class="col-sm-8">
<a class="create btn btn-info add_to_arrayable" href="#"><i class="icon-plus icon-white"></i> Add To List</a>
<div class="row">
joshmn / _form.html.erb
Created Jun 9, 2015
Multiple specific cropped positions a single Paperclip record
View _form.html.erb
<!-- to your form partial. yes, you could do this more dynamically, but for illustrative purposes. -->
<select id="style_select">
<option value="cover" data-style-options='{"option": "setCropBoxData", "data": {"width": 1200, "height": 628}}'>Cover</option>
<option value="medium" data-style-options='{"option": "setCropBoxData", "data": {"width": 628, "height": 840}}'>Medium</option>
<option value="small_sq" data-style-options='{"option": "setCropBoxData", "data": {"width": 470, "height": 470}}'>Small Square</option>
<option value="thumb" data-style-options='{"option": "setCropBoxData", "data": {"width": 128, "height": 128}}'>Thumb</option>
<% %w{cover large medium medium_sq small small_sq thumb}.each do |w| %>
<%=w%>: <input class="form-control style_data" data-style-for="<%=w%>" type="text" name="image[crop][<%=w%>]" placeholder=""><br/>
joshmn / spotify.rb
Created Jun 29, 2015
Import Artists from List to Spotify
View spotify.rb
require 'rspotify'
RSpotify::authenticate("key", "secret")
artists_list = ["12th Planet", "3LAU", "4B", "A-lusion", "Aaron Jackson", "Above & Beyond", "AC Slater", "Adrenalize", "Adventure Club", "Afrojack", "Alesso", "Alex Kidd", "Alison Wonderland", "Aly & Fila", "Amine Edge & DANCE", "Andrew Rayel", "Andy C", "Armanni Reign", "Armin van Buuren", "Art Department", "Arterial", "Arty", "Astrix", "Astronomar", "ATB", "Audien", "Audiotricz", "Avicii", "AWE", "Baggi Begovic", "Barrels", "Bassnectar", "Baumer", "Benny Benassi", "Bingo Players", "Bixel Boys", "Black Sun Empire", "Blaise James", "Blasterjaxx", "Bones", "Brandon Elliot", "Breach", "Breathe Carolina", "Brennan Heart", "Brillz", "Burn Unit", "Calvin Harris", "Camo & Krooked", "Carl Cox", "Carnage", "Chevy Chase", "Chris Liebing", "Chris Lorenzo", "Chuckie", "Chus & Ceballos", "Cookie Monsta", "Coone", "Cosmic Gate", "Crisis Era", "Crizzly", "CSTNZA", "D-Block & S-te-Fan", "Da Tweekaz", "Dada Life", "Dannic", "Danny Avila", "Darksiderz", "Darren Styl
View seed data
require 'json'
namespace :seed_data do
task products: :environment do
file ="#{Rails.root}/products.json")
json_array = JSON.parse(
json_array.each_with_index do |json_product, index|
break if index >= 100
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]
file ='schema.rb')
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 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 / gist:6831378
Created Oct 4, 2013
Accept non-GET AJAX via jQ while Authenticated inside a Ruby on Rails application (devise, simpleauth)
View gist:6831378
$(document).ajaxSend(function (_, xhr) {
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
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",
You can’t perform that action at this time.