Skip to content

Instantly share code, notes, and snippets.

Ethan Vizitei evizitei

Block or report user

Report or block evizitei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View make_heights_equal.js
$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);
View car.rb
class Car
def initialize(instruments)
@instruments = instruments
end
def mileage
@_mileage ||= @instruments.select(:odometer).calculate_value
end
end
View use_savon.rb
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
View subject_footer.rb
View subject_footer.rb
@evizitei
evizitei / double_join_query.rb
Created Jun 4, 2012
a useful sql statement to avoid a subquery
View double_join_query.rb
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 Mar 21, 2012
A useful seed file for Chris
View seeds.rb
# 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
View palindrome.rb
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
View good_primes.rb
require 'mathn'
n = 600851475143
Prime.each do |x|
while n % x == 0
n = n/x
end
break if x > n/2
end
puts n
View config.rb
module Tandem
class Config
def self.current_user(&block)
SomeController.send(:define_method, :current_user, block)
end
end
end
You can’t perform that action at this time.