Skip to content

Instantly share code, notes, and snippets.

View evizitei's full-sized avatar

Ethan Vizitei evizitei

  • Instructure
  • Columbia, MO
View GitHub Profile
Sub WorksheetLoop()
Dim I As Integer
Dim worksheetName As String
Dim sheet As Worksheet
I = 1
For Each sheet In ActiveWorkbook.Worksheets
worksheetName = "" & I & " - " & sheet.Name
sheet.Name = worksheetName
$elements = $('div.tutorial-index');
heights = $elements.map(function(i, ele){ return $(ele).height(); });
max = 0
$.each(heights, function(i, height){ if(height > max) max = height;});
$elements.height(max);
class Car
def initialize(instruments)
@instruments = instruments
end
def mileage
@_mileage ||= @instruments.select(:odometer).calculate_value
end
end
@evizitei
evizitei / use_savon.rb
Created November 15, 2012 19:38
savon usage
require 'savon'
client = Savon.client('https://dev.tch.com/richapp/Wsdl.action?wsdl=/axis2/services/CardManagementWS')
client.http.auth.ssl.verify_mode = :none
client.wsdl.soap_actions
@evizitei
evizitei / double_join_query.rb
Created June 4, 2012 20:04
a useful sql statement to avoid a subquery
self.class.find_by_sql(["SELECT users.* FROM users
INNER JOIN connections AS second_degree_connections
ON second_degree_connections.target_id = users.id
INNER JOIN connections AS first_degree_connections
ON first_degree_connections.target_id = second_degree_connections.owner_id
WHERE first_degree_connections.owner_id = ?", self.id])
@evizitei
evizitei / seeds.rb
Created March 21, 2012 20:31
A useful seed file for Chris
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Interview.delete_all
User.delete_all
ans = 0
for i in 100..999
for j in (100..999).to_a.reverse
x = i*j
if x == (x).to_s.reverse.to_i
ans = x
break
elsif x < ans
break
end
require 'mathn'
n = 600851475143
Prime.each do |x|
while n % x == 0
n = n/x
end
break if x > n/2
end
puts n