Skip to content

Instantly share code, notes, and snippets.

View wolfieorama's full-sized avatar
🎯
Focusing

wolfieorama

🎯
Focusing
  • Nairobi, Kigali and else where
View GitHub Profile
weekly_performance_reviews_controller.rb
class WeeklyPerformanceReviewsController < InheritedResources::Base
before_action :set_weekly_performance_review, only: [:show, :edit, :update, :destroy]
before_action :authenticate_admin!
def index
@weekly_performance_reviews = WeeklyPerformanceReview.all
end
class Employee < ActiveRecord::Base
has_many :subordinates, class_name: "Employee", foreign_key: "manager_id"
belongs_to :manager, class_name: "Employee"
belongs_to :team
has_one :team, foreign_key: "manager_id"
end
# see https://github.com/ankane/blazer for more info
data_sources:
main:
url: <%= ENV["BLAZER_DATABASE_URL"] %>
# statement timeout, in seconds
# applies to PostgreSQL only
# none by default
# timeout: 15
def prev
JobQueue.where(["queue_owner = ? and queue_name = ? and id < ?", queue_owner, queue_name, id]).last
end
# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
jQuery ->
jobs = $('#job_queue_id').html()
console.log(jobs);
$('#project_queue_id').change ->
project = $('#project_queue_id :selected').text()
options = $(jobs).filter("optgroup[label='#{project}']").html
if options
$('#job_queue_id').html(options)
else
$('#job_queue_id').empty()
$(document).ready ->
cities = $('#person_city_id').html()
# console.log(cities)
$('#person_country_id').change ->
country = $('#person_country_id :selected').text()
options = $(cities).filter("optgroup[label='#{country}']").html()
# console.log(options)
if options
$('#person_city_id').html(options)
else
<%= form_for(@person) do |f| %>
<% if @person.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@person.errors.count, "error") %> prohibited this person from being saved:</h2>
<ul>
<% @person.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
function testClosure (){
var x = 4;
function closeX(){
return x; // NB: x is not stored anywhere in the innermost function its a global variable
}
return closeX;
}
var checkLocalX = testClosure();
function testClosure (){
var x = 4; // local variable
return x;
}
testClosure(); // this will return 4
x; // will return undefined because a function variable are not available once the scope has closed