Skip to content

Instantly share code, notes, and snippets.

View universal's full-sized avatar

Johannes / universa1 universal

View GitHub Profile
class Row
attr_accessor :supervisor_name, :name, :emp_pending, :sup_pending, :approved
def to_s
"Test #{@supervisor_name}, #{@name}, #{@emp_pending}, #{@sup_pending}, #{@approved}, #{total}, #{status}"
end
def total
@emp_pending + @sup_pending + @approved
end
<%= form_for Group.new do |f| %>
<table summary = "groups from trainer">
<tr>
<th><%= f.label(:name) %></th>
<td><%= f.text_field(:name) %></td>
</tr>
<tr>
<th><%= f.label(:area) %></th>
<td><%= f.text_field(:area) %></td>
</tr>
@universal
universal / find.rb
Last active August 29, 2015 14:02 — forked from adammcarth/find.rb
class JTask
# JTask.find()
# Retrieves records from the database file.
# --------------------------------------------------------------------------------
# Eg: JTask.find("test.json", 1) || JTask.find("test.json", first: 10)
# #=> <JTask id=x, ...>
# --------------------------------------------------------------------------------
# See wiki guide for more usage examples...
# https://github.com/adammcarthur/jtask/wiki/find
class BooksController < ApplicationController
before_action :load_book
before_action :check_access
def show
@comments = @book.comments.reversed_nested_set.with_state([:draft, :published])
end
def subscribed
end
private
# config valid only for Capistrano 3.1
set :stages, %w(production staging)
set :default_stage, "staging"
set :application, 'aperture'
set :repo_url, 'ssh://repository/git/aperture.git'
set :user, "rails"
@universal
universal / example.rb
Last active August 29, 2015 14:04 — forked from anonymous/example.rb
task :postcode_import => :environment do
puts "\n\n Importing PostCodes"
lat_long_res = []
CSV.foreach "lib/data/example.csv" do |row|
if row[0].include? " "
postcode = row[0]
else
postcode = row[0][0..3] + " " + row[4..-1]
end
easting = row[1].to_i
def add_emojify_and_kramdown(text)
markdowned = Kramdown::Document.new(text).to_html
raw(emojify(markdowned))
end
def emojify(text)
text.to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match|
if emoji = Emoji.find_by_alias($1)
%Q{<img alt="$1" class="emoji" src="#{ image_path(emoji.image_filename) }">}
class FollowUpVisitGardensController < ApplicationController
def new
#1st you retrieve the group thanks to params[:group_id]
#2nd you build a new comment
@group = Group.find(params[:group_id])
@gardener= Gardener.find(params[:gardener_id])
@follow_up_visit_garden= FollowUpVisitGarden.new
if @gardener.valid?
render "new"
module ApplicationHelper
def title(*parts)
unless parts.empty?
parts << t(:website)
content_for(:title) do
parts.join(' - ')
end
end
end
end
<% content_for :title do %>
<%= @game.SportsLeagueName %>: <%= team_logo @game.away_team %> <%= @game.away_team %> at <%= @game.home_team %>"
<% end %>
<%= team_logo @game.away_team %>
<div>
<% if @game.SportsLeagueName == 'NFL' %>
<%= image_tag "http://151986650d2f98828025-63e4acfff05fd55acad2fbee57a1d69b.r75.cf2.rackcdn.com/#{@game.AwayTeamID}.png" %>
AT
<%= image_tag "http://151986650d2f98828025-63e4acfff05fd55acad2fbee57a1d69b.r75.cf2.rackcdn.com/#{@game.HomeTeamID}.png" %>