This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="comment" id=<%=comment.id %>> | |
<div class="well"><%= comment.body %><br> | |
<%= comment.user.username %> | |
<small><%= comment.updated_at.strftime('%b %d, %Y at %I:%M %p') %></small> | |
<%= link_to "×", comment_path(comment), :method => :delete, :remote => true, :confirm => "Are you sure you want to remove this comment?", :disable_with => "×", :class => 'close' %></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def good_fact(x) | |
def fact_tail(x,sum) | |
if x == 0 | |
return sum | |
else | |
fact_tail(x-1,x*sum) | |
end | |
end | |
fact_tail(x,1) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
case ARGV[0] | |
when "one" | |
puts "hi" | |
when "two" | |
puts "bye" | |
else | |
puts "otherwise" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog | |
end | |
class Cat | |
def self.new | |
Dog.new | |
end | |
end | |
#[3] amooreniemi (main) » Cat.new | |
#=> #<Dog:0x007fa052063c78> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SatisfactionQuery | |
def self.execute | |
query = <<-SQL.strip_heredoc | |
SELECT pins.id AS pin_id, pins.satisfaction, procedures.name, surgeons.last_name, | |
dense_rank() OVER ( | |
PARTITION BY procedure_id, surgeon_id | |
ORDER BY pins.satisfaction DESC | |
) AS sat_rank | |
FROM pins | |
INNER JOIN procedures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run options: include {:locations=>{"./spec/string_permutations_iterative_spec.rb"=>[13]}} | |
String | |
#permutations | |
op_count: 1 | |
op: + A | |
current strings: [] | |
current stack: ["A:BC"] | |
----------- | |
op_count: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
def perms(str) | |
return [str] if str.length == 1 | |
results = [] | |
str.length.times do |i| | |
substring = str.dup | |
c = substring.slice!(i - 1) | |
perms(substring).map do |s| | |
results << c + s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Definition for a binary tree node. | |
# class TreeNode | |
# attr_accessor :val, :left, :right | |
# def initialize(val) | |
# @val = val | |
# @left, @right = nil, nil | |
# end | |
# end | |
# @param {TreeNode} root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pair the sublists together | |
a.zip(b) | |
=> [[[1], [9]], [[2, 3], [8, 7]], [[4, 5, 6], [6, 5, 4]]] | |
# collect up the lengths | |
a.zip(b).collect {|e| e.map(&:length) } | |
=> [[1, 1], [2, 2], [3, 3]] | |
# i want each pair of lengths to be the same, so | |
a.zip(b).collect {|e| e.map(&:length) }.map(&:uniq) | |
=> [[1], [2], [3]] | |
# after i made them uniq, are they singular? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ===================================================================================== | |
* | |
* Filename: Compose.c | |
* | |
* Description: Proc composition | |
* | |
* Version: 1.0 | |
* Created: 10/01/2016 16:14:22 | |
* Revision: none |