Skip to content

Instantly share code, notes, and snippets.

View bbhoss's full-sized avatar
🎯
Focusing

Preston bbhoss

🎯
Focusing
View GitHub Profile
<h1>Register</h1>
<% form_for(@user) do |f| %>
<%= f.error_messages %>
<% f.fields_for :person do |g| %>
<p>
<%= g.label :firstname %><br />
<%= g.text_field :firstname %>
</p>
<% end %>
require 'bigdecimal'
#Set values to determine output based on how much % of memory is free
CRITICAL=5
WARNING=10
File.open "/proc/meminfo","r" do |line|
@memtotal = BigDecimal.new($1) if line.gets =~ /MemTotal:\s+(\d+)\s+kB/
@memfree = BigDecimal.new($1) if line.gets =~ /MemFree:\s+(\d+)\s+kB/
end
if @memtotal and @memfree
@free_percentage = ((@memfree/@memtotal)*100)
gem "cucumber-rails", :git => "git://github.com/alg/cucumber-rails.git"
MyApplicationName::Application.configure do
# Edit at your own peril - it's recommended to regenerate this file
# in the future when you upgrade to a newer version of Cucumber.
# IMPORTANT: Setting config.cache_classes to false is known to
# break Cucumber's use_transactional_fixtures method.
# For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165
config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
def test_method_names_become_symbols
assert_equal __, Symbol.all_symbols.include?("test_method_names_become_symbols".to_sym)
end
# event.rb
def format_day
self.day.strftime("%B %d, %Y (%A)")
end
def day_types
OpenStruct.new(:day => self.day, :format => self.format_day)
end
# view
Blog::Application.routes.draw do
get "pages/about"
get "pages/contact"
resources :portfolios
resources :links
resources :posts do
@bbhoss
bbhoss / linode.rb
Created November 4, 2011 04:26
Linode Ohai Plugin
#
# Author:: Preston Marshall (<preston@ideamarshal.com>)
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@bbhoss
bbhoss / example.rb
Created February 8, 2012 04:31 — forked from jkutner/example.rb
Possible alternative approach?
class Local
def method_missing(*args)
"hello world"
end
end
def my_val
raise "goodbye cruel world"
end
@bbhoss
bbhoss / bmi.hs
Created March 20, 2012 18:43
BMI Calculator
calcBMI :: Float -> Float -> Float
calcBMI heightIn weightLbs = (weightLbs*703)/heightIn^2
main = do
putStrLn "What is your weight in pounds?"
weight <- readLn :: IO Float
putStrLn "What is your height in inches?"
height <- readLn :: IO Float
putStrLn ("Your weight is " ++ show weight ++ "lbs. and your height is " ++ show height ++ "in.")
putStrLn ("Your BMI is " ++ show(calcBMI height weight))