Skip to content

Instantly share code, notes, and snippets.

View forrestwilkins's full-sized avatar

Forrest Wilkins forrestwilkins

View GitHub Profile
def self.score(obj)
up_votes_weight = 0
for vote in obj.votes.up_votes # recent votes on older posts have more weight
up_votes_weight += ((vote.created_at.to_date - obj.created_at.to_date).to_i / 2) + 1
end # plus one for votes on recent posts to still get valued
_score = (up_votes_weight + (obj.comments.size / 2)) -
((obj.votes.down_votes.size.to_i * 2) + (Date.today - obj.created_at.to_date).to_i)
return _score
# also needs to check for clusters of recent votes, giving more
# weight to recent posts that are closer together in time, "hotness"
ZIP_CODE_RANGE = 10
def close_enough(content)
_close_enough = false
zips_in_range = []
for zip in Zip.all
if self.zip_code and self.network_size and content.zip_code
if (self.zip_code - zip.zip_code).abs < ZIP_CODE_RANGE + self.network_size
zips_in_range << zip.zip_code
end
class User
def close_enough(content)
_close_enough = false
zips_in_range = []
for zip in Zip.all
# verifies values and gets zips within constant range
if self.zip_code and self.network_size and content.zip_code
difference = (self.zip_code - zip.zip_code).abs
if difference < Zip.zip_code_range
from Tkinter import *
class Reservation(Frame):
def __init__(self, parent):
Frame.__init__(self, parent, background="gray")
self.parent = parent
self.initUI()
def close_enough(content)
_close_enough = false
# content always close enough when inside current users zip code or cherry picked tab
if content.zip_code and self.zip_code and content.zip_code == self.zip_code or (content.is_a? Tab and \
content.features.where(user_id: self.id).where(action: :cherry_pick).present?)
_close_enough = true
# close enough when within the users specified network size
elsif content.latitude and self.latitude and self.network_size and \
GeoDistance.distance(content.latitude, content.longitude, self.latitude,
self.longitude).miles.number < self.network_size
$(window).bindWithDelay("scroll", function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 150) {
if ($("#more_content_anchor")) {
var param = null;
if (document.URL.search("users") != -1) {
param = $.param({ user_id: document.URL.split("/")[4] });
} else if (document.URL.search("tabs") != -1) {
param = $.param({ tab_id: document.URL.split("/")[4] });
} else if (document.URL.search("notes") != -1) {
param = $.param({ notes: true });
def close_enough(content)
_close_enough = false
# content always close enough when inside current users zip code or cherry picked tab
if content.zip_code and self.zip_code and content.zip_code == self.zip_code or (content.is_a? Tab and \
content.features.where(user_id: self.id).where(action: :cherry_pick).present?)
_close_enough = true
# close enough when within the users specified network size
elsif content.latitude and self.latitude and self.network_size and \
GeoDistance.distance(content.latitude, content.longitude, self.latitude,
self.longitude).miles.number < self.network_size
def current_location
geoip = GeoIP.new('GeoLiteCity.dat').city(self.ip)
if defined? geoip and geoip
self.latitude = geoip.latitude
self.longitude = geoip.longitude
if latitude and longitude
geocoder = Geocoder.search("#{latitude}, #{longitude}").first
if geocoder and geocoder.formatted_address
self.address = geocoder.formatted_address
end
<%= form_for @maintenance do |f| %>
<p>
<%= f.check_box :title %>
</p>
<p>
<%= f.submit translate("Update"), class: "btn btn-default btn-lg btn-block" %>
</p>
<% end %>
Okay so the tool tips should appear in the following order they will have to branch off as the user
visits different aspects of the site. We will start of with what we will call the welcome screen,
which is the first page that the user sees after they have either created an account or log in.
1.hi, this is your site page being used as your welcome screen. It has articles, events that are close
to you. Later I'll show you how to choose a Drop [drop icon here] as your welcome screen
2.This is button will bring you back to the site page from anywhere on the site.
(referring to the elheroe logo that appears in the top left corner of every page.)