Skip to content

Instantly share code, notes, and snippets.

setupIndex: function() {
rows = $$('tr.deviceSummary');
for (var i=0; i<rows.length; i++) {
rows[i].onclick = function() {
window.location.href = '/devices/' + this.id.substr(1);
}.bind(rows[i]);
}
$('new_device').observe('click', Devices.showMiniNewForm.bindAsEventListener(this));
Devices.setupAll();
},
check process httpd with pidfile /var/run/httpd.pid
alert [email protected] with reminder on 2 cycles
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then alert
if totalmem > 200.0 MB for 5 cycles then alert
if children > 250 then alert
if loadavg(5min) greater than 20 for 8 cycles then alert
if failed url
## Drop this into a file in db/migrate ##
class AddMissingIndexes < ActiveRecord::Migration
def self.up
# These indexes were found by searching for AR::Base finds on your application
# It is strongly recommanded that you will consult a professional DBA about your infrastucture and implemntation before
# changing your database in that matter.
# There is a possibility that some of the indexes offered below is not required and can be removed and not added, if you require
# further assistance with your rails application, database infrastructure or any other problem, visit:
#
@resources = ApplicationController.subclasses.collect do |controller|
controller.sub(/Controller$/, '').underscore.sub(/\w+\//, '')
end
# -*- coding: utf-8 -*-
module Test
module Unit
class Slow
attr_reader :test_name, :message
def initialize(test_name)
@test_name = test_name
@message = "Too slow."
end
<!DOCTYPE html>
<html lang='en'>
<head>
<title>LiftCalc</title>
<meta http-equiv='Content-type' content='text/html;charset=UTF-8'>
<meta name='viewport' content='width=device-width'>
<meta name='viewport' content='initial-scale=1.6'>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript'>
describe ".ask_all_a_random_anonymous_question" do
before(:each) do
@user1 = Factory(:user)
@user2 = Factory(:user)
@user3 = Factory(:user)
User.stub(:all).and_return([@user1, @user2, @user3])
end
it "should ask each user a random anonymous question" do
@user1.should_receive(:ask_a_random_anonymous_question)
task :cron => :environment do
return false if CronJob.last.created_at.today?
CronJob.create(:name => "Daily Cron #{Time.now}")
ActivityScan.affect.take_action!
time = Time.local(Time.now.year, Time.now.month, Time.now.day, rand(3) + 12, rand(60))
User.send_at(time, :ask_all_a_random_anonymous_question)
CronJob.update_attributes(:completed_at => Time.now)
end
# Warning: Loses any scope it may have been called on!
def send_all_in_batches(batch_size, method, *args)
transaction do
start_id = first(:order => 'id ASC').id
end_id = first(:order => 'id DESC').id
current_id = start_id
while current_id <= end_id
if time = args.delete(:time)
send_at(time, :send_to_batch, current_id, current_id + batch_size, method, *args)
else
Scenario: An non-admin cannot add a user to the featured queue # features/admin.feature:45
Given I am a logged in user # features/step_definitions/user_st
eps.rb:72
uninitialized constant JSON::SAFE_STATE_PROTOTYPE (ActionView::TemplateError) On line #143 of app/views/layouts/application.html.erb
140: var classes = <%= BroadcastsCount.all_broadcasting.collect { |name| ".#{name}
-count" }.to_json %>;
141: var delta_classes = <%= BroadcastsCount.all_broadcasting.collect { |name| ".#
{name}-count-delta" }.to_json %>; 142: if($(classes.join(", ")).length > 0 || $(delta_classes.join(", ")).length > 0
){ 143: window["SOCKET"] = new Pusher(<%= PUSHER_KEY.to_json %>, <%= PUSHER_CHANNEL
.to_json %>);