Skip to content

Instantly share code, notes, and snippets.

View jraczak's full-sized avatar

Justin Raczak jraczak

View GitHub Profile
has_many :my_follows, foreign_key: :follower_id, class_name: 'Follow', dependent: :destroy
has_many :follows, through: :my_follows, source: :followed
has_many :their_follows, foreign_key: :followed_id, class_name: 'Follow', dependent: :destroy
has_many :followers, through: :their_follows
@jraczak
jraczak / gist:4255618
Created December 11, 2012 03:08
Solr error output, missing geodist params in query
Dec 10, 2012 10:04:00 PM org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException: sort param could not be parsed as a query, and is not a field that exists in the index: geodist(location_ll,,)
at org.apache.solr.search.QueryParsing.parseSort(QueryParsing.java:375)
at org.apache.solr.search.QParser.getSort(QParser.java:251)
at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:102)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:173)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1372)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)
crowdscore (master) $ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=2b<RXCSUM,TXCSUM,VLAN_HWTAGGING,TSO4>
/solr ---> org.mortbay.jetty.webapp.WebAppContext@7c0cbf92{/solr,file:/Volumes/UserData/Users/jraczak/.rvm/gems/ruby-1.9.3-p327@crowdscore/gems/sunspot_solr-2.0.0.pre.111215/solr/webapps/solr.war}
SFM0NPDF91L:crowdscore justin.raczak$ initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "justin.raczak".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
creating directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
@jraczak
jraczak / gist:4955640
Last active December 13, 2015 18:28
Working on the activity stream.
#in-progress method for gathering user's social network activity
def get_network_activity
@activities = []
@follows = self.follows.all
@follows.each do |f|
f.venue_scores.each do |a|
@activities << a
end
def facebook_sign_in_and_redirect(resource_or_scope, *args)
options = args.extract_options!
scope = Devise::Mapping.find_scope!(resource_or_scope)
resource = args.last || resource_or_scope
sign_in(scope, resource, options)
redirect_to confirmation_url(resource, :confirmation_token => resource.confirmation_token)
end
def facebook
# find_for_facebook_oauth is defined in User model
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
flash[:notice] = "We've gathered some info from Facebook. Fill out the rest and you're all set!"
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
flash[:notice] = "We've gathered some info from Facebook. Fill out the rest and you're all set!"
def create_snapshot
venue = Venue.find(params[:id])
snapshot = VenueSnapshot.new(
venue_id: venue.id,
venue_scores_count: venue.venue_scores.count,
tip_count: venue.tips.count,
current_crowdscore: venue.computed_score,
score_breakdown1: venue.score_breakdown1,
score_breakdown2: venue.score_breakdown2,
score_breakdown3: venue.score_breakdown3,