Skip to content

Instantly share code, notes, and snippets.

View rstrobl's full-sized avatar

Robert Strobl rstrobl

View GitHub Profile
App.Track = DS.Model.extend({
uri: DS.attr('string')
})
App.LikedTracksRoute = Ember.Route.extend({
model: function() {
return this.store.find('track', { filter: 'user_only', limit: 30 })
}
})
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
p user
if user.admin?
can :manage, :all
@rstrobl
rstrobl / application_controller.rb
Last active December 16, 2015 23:19
dashboard_path refers to the rails_admin dashboard path instead of the one from the host app
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from CanCan::AccessDenied do |exception|
if user_signed_in?
flash[:error] = I18n.t('auth.message.access_denied')
session[:user_return_to] = nil
redirect_to dashboard_path
else
flash[:error] = I18n.t('auth.message.admin_login_required')
@rstrobl
rstrobl / gist:939013
Created April 23, 2011 21:48
Getting YouTube download URLs for a given video ID
// fill in the video ID here
$video_id = '';
$info_url = 'http://www.youtube.com/get_video_info?video_id=' . $video_id;
$info_page = file_get_contents($info_url);
// put query strings into local scope
parse_str($info_page);
// parse fmt_stream_map