Skip to content

Instantly share code, notes, and snippets.

View universal's full-sized avatar

Johannes / universa1 universal

View GitHub Profile
@universal
universal / _attendance.html.haml
Last active August 29, 2015 13:56
presenter example based on railscast episode: presenters from scratch
- present(attendance).is_attending(attending).is_expired(expired) do |presenter|
%li
= presenter.name
\-
= presenter.attends_set_at
= presenter.edit_link
= presenter.comment
class Inventory < ActiveRecord::Base
belongs_to :user
belongs_to :product
end
class Admin < User
has_one :user, :as => :userable
attr_accessible :user
end
gallery_timelapse GET /timelapses/:id/gallery(.:format) timelapses#gallery
files_timelapse GET /timelapses/:id/files/:year/:month/:day(.:format) timelapses#files
timelapses GET /timelapses(.:format) timelapses#index
POST /timelapses(.:format) timelapses#create
new_timelapse GET /timelapses/new(.:format) timelapses#new
edit_timelapse GET /timelapses/:id/edit(.:format) timelapses#edit
timelapse GET /timelapses/:id(.:format) timelapses#show
PATCH /timelapses/:id(.:format) timelapses#update
PUT /timelapses/:id(.:format) timelapses#update
DELETE /timelapses/:id(.:format) timelapses#destroy
class ApplicationController < ActionController::Base
def render_error(status, messages)
render json: { errors: messages }, status: status.to_sym
end
def render_not_found
render_error :not_found, { base: ['Not found.'] }
end
end
class UserPasswordResetsController < ApplicationController
#personal preferences here
def update
user = User.find_by(password_reset_token: params[:id])
if !user.present?
head :not_found
elsif !(user.is_activated && user.is_active)
head :unprocessable_entity
elsif user.update_password params[:password], params[:password_confirmation]
head :ok
1.upto 15 do |i|
j = (1..i).map {10}.reduce(:*)
puts j
puts "#{helper.distance_of_time_in_words j} || #{helper.distance_of_time_in_words j}"
end
#!/usr/bin/env bash
set -e
oldrev=$1
newrev=$2
run() {
[ -x $1 ] && $1 $oldrev $newrev
}
echo files changed: $(git diff $oldrev $newrev --diff-filter=ACDMR --name-only | wc -l)
def show
@video = Video.find(params[:id])
@related = @video.find_related_tags.limit(4)
end
=====
<h4>Similar videos:</h4>
<ul class="large-block-grid-4 small-block-grid-2 medium-block-grid-3">
<%= @related.size %>
<ul>
<% @users.each do |user| %>
<li>
<%= link_to("1. Letter of Representation", letter_of_user_path(user) %>
</li>
<% end %>
</ul>