This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ajaxSend(function (_, xhr) { | |
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content')); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inspired by Gitlab's Admin Logs (app/controllers/admin/logs_controller.rb) | |
Probably should put things in lib. Put in one file for breviety. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"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", |
OlderNewer