Skip to content

Instantly share code, notes, and snippets.

def index
@bugs = nil
if request.post?
mappings = Hash.new{|k,v|v}
allowed_user_attrib = [:company_name, :name]
allowed_bug_attrib = [:submitter]
user_attrib = params[:user].reject{|k,v| ! allowed_user_attrib.include?(k)}
<h1>Index:</h1>
<% form_tag :action => "index" do %>
<fieldset>
<legend>Enter Search Criteria</legend>
<div>
<label for="Company">Company Name:</label>
<%= collection_select( :user, :company_name, User.all,
:company_name, :company_name, options = {:prompt => "-Select a Company"}) %>
<!--- RENDERED PARTIAL >
<tr>
<td><%=h bug.user.company_name %> </td>
<td>Submitted by <%=h bug.submitter %></td>
<td><%=h bug.subject %> </td>
<td> <%=h truncate(bug.description.gsub(/<.*?>/,''), :length => 80) %> </td>
<td> <%= link_to 'Show', bug %> </td>
<% if session[:admin] %>
<td> <%= link_to 'Edit', edit_bug_path(bug)%> </td>
class Node
#sigmoid and derivitive of sigmoid. Might be useful
def self.sigmoid(num)
1.0 / (1 + Math.exp(-num) )
end
def self.sigderiv(num)
return (Math.exp(-num) ) / ( (Math.exp(-num) + 1)**2)
end
infile = ARGV[0]
@gridsize = ARGV[1].to_i
@world = Array.new(@gridsize+2){|i| Array.new(@gridsize+2){"."}}
File.open(infile, "r") do |f|
(1..@gridsize).each do |i|
row = f.gets
rowarr = row.split(" ")
//attempts to add the given request together, fulfilling all prefs.
//if ALL preferences cannot be fulfilled, no change is made and method returns false
public boolean add_with_prefs(String[] reqs)
{
String[][] tokend = new String[reqs.length][];
//tokenize reqs
for(int i = 0; i < reqs.length;i++)
{
tokend[i] = reqs[i].split("/");
puts "Welcome to uber-calculator"
puts "Please enter commands in the format:"
puts "\tX op Y"
puts "Prefix 0x for hex, 0b for binary"
puts "... hell, lets do octal too!"
puts "Type q(uit) to, y'know, QUIT!"
puts "Output in base 10, change output base with base = N"
class String
def to_10
require 'securerandom'
require 'thread'
mutex = Mutex.new
pause = false
pauser = Thread.new do
while (true) do
s = gets
mutex.synchronize do
require 'securerandom'
require 'thread'
mutex = Mutex.new
pause = false
pauser = Thread.new do
while (true) do
s = gets
mutex.synchronize do
#!/usr/bin/ruby
require 'rubygems'
require 'yaml'
require 'chronic'
require 'date'
require 'time'
FILENAME = File.expand_path "~/.growls"