Skip to content

Instantly share code, notes, and snippets.

<div class="chatboxinput">
<%= form_for([@conversation, @message], :url => conversation_messages_path(@conversation, @message, format: 'js'), :remote => true, :html => {id: "conversation_form_#{@conversation.id}"}) do |f| %>
<%= f.text_area :body, class: "chatboxtextarea", "data-cid" => @conversation.id %>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<% end %>
</div>
class Challenge < AR::Base
belongs_to :category
has_many :participations
has_many :participants, through: :participations
end
@tbuehlmann
tbuehlmann / helper.rb
Last active August 29, 2015 14:07 — forked from wethu/helper.rb
def form_for_login(&block)
form_for(resource,
as: resource_name,
url: session_path(resource_name),
html: {
class: 'navbar-form navbar-right',
role: 'login'
}, &block)
end
end
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
private
def current_cart
@current_cart ||= begin
Cart.find(session[:cart_id])
class Ability
include CanCan::Ability
def initialize(user, *args)
super(*args)
alias_action :new, to: :write
alias_action :create, to: :publish
user ||= User.new # guest user (not logged in)
if user.has_role? :admin
can :manage, :all
class RegistrationsController < ApplicationController
before_filter :authenticate_athlete!, :only => [:new, :create]
def new
@race = Race.find(params[:race_id])
@registration = @race.registrations.new
end
def create
@race = Race.find(params[:race_id])
@tbuehlmann
tbuehlmann / span.haml
Last active December 26, 2015 07:39 — forked from DriesS/span.haml
(
%span{:id => "cart-counter" }
= @cart && [email protected]? ? @cart.size : "0"
)
or
(<span id="cart-counter">#{@cart && [email protected]? ? @cart.size : "0"})
205356 <pothibo> tbuehlmann: https://gist.github.com/pothibo/6167471
205405 <tbuehlmann> thanks a lot
205453 <pothibo> tbuehlmann: a few assumption here: First you use STL for different User e.g User Admin SuperAdmin, etc. You can retrieve the current_user
205515 <pothibo> my_controller.rb allow for controller level restrictions & per-action
205525 <pothibo> they work in conjunction
- player_url = URI.encode('http://'+request.host_with_port + player.url)
- player_title = "AmericanSoccerNow: #{player.title}"
- player_description = player.dek
.detail
.left
- if player.hero_image and player.hero_image.attached
= image_tag player.hero_image.attached.url, :height => 240, :width => 200
%span.imageCaption
= player.hero_image.credit.try(:html_safe)
#!/usr/bin/env bash
time=1500 # 25 minutes
title="Pomodoro"
icon=/home/yorickpeterse/Pictures/icons/tomato.png
notify-send -i "$icon" "$title" "Starting a new Pomodoro timer"
sleep $time