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
View seed data
require 'json'
namespace :seed_data do
task products: :environment do
file = File.new("#{Rails.root}/products.json")
json_array = JSON.parse(File.read(file))
json_array.each_with_index do |json_product, index|
break if index >= 100
@joshmn
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
@joshmn
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></option>
<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>
</select>
<% %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
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>
<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>
</div>
<div class="row">
@joshmn
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('http://www.brewcrewball.com/2014/6/5/5328814/mlb-draft-players-roster-construction-brewers-yankees-red-sox-dodgers')
doc = Nokogiri::HTML(page.body)
i = 0
doc.css('#article-body h3').each do |t|
next if t.text.empty?
team = t.text
@joshmn
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'));
});
You can’t perform that action at this time.