Skip to content

Instantly share code, notes, and snippets.

View johnhamelink's full-sized avatar
🔨
Building

John Hamelink johnhamelink

🔨
Building
View GitHub Profile
{
"platform": [
{
"title": "Visited TA Site",
"value": 2000
},
{
"title": "Visited Minutes App",
"value": 2000
description "Find a Player API"
setuid deploy
setgid deploy
start on runlevel [2345]
stop on runlevel [016]
expect stop
respawn
defp ensure_sso_defaults(changeset) do
# One of these fields needs to exist
# for us to overwrite the email & password
is_sso = (
get_field(changeset, :digits_id) ||
get_field(changeset, :facebook_id) ||
get_field(changeset, :sms_verification_id)
)
changeset =
defmodule Mix.Tasks.MigrateContactDetails do
use Mix.Task
import Ecto.Query, only: [from: 2]
@shortdoc "Migrate ContactDetails data into NewContactDetails"
def run(), do: run(0)
def run(_args) do
Mix.Task.run "app.start", []
if player.state == Player.states[:requested_to_join]
message = "#{current_user.name} has requested to join '#{player.play.event.name}'"
uri_opts = {notif_event: "request_to_join", from_id: player.id}
category = "request_to_join"
# -> UriBuilder.build([["user", 1]], {view: "stats"})
# => "fap://user/1?view=stats"
# -> UriBuilder.build([["user", 1]])
# => "fap://user/1"
# -> UriBuilder.build([["event", 1], ["play", 5], ["player_mgmt"]])
# => "fap://event/1/play/5/player_mgmt"
schema "venues" do
field :name, :string
field :description, :string
field :address, :string
field :cover_photo, :string
field :postcode, :string
field :is_private, :boolean
belongs_to :owner, DB.Session
end
module DistanceScopable
extend ActiveSupport::Concern
included do
# Select a specified distance from the coordinate of the table (in meters)
scope :distance_to_point, lambda { |table_name: self.table_name, srid: 4326, lat: nil, lng: nil, distance: 5000|
fail 'Attributes missing' if distance.nil? || lat.nil? || lng.nil? || srid.nil?
select(<<-SQL.squish
ST_Distance(
#{table_name}.coordinates,
def find_events_by_coordinate(event)
return event if @coordinates.nil?
return event if @coordinates['latitude'].nil? || @coordinates['longitude'].nil?
if @coordinates['latitude'].is_a? String
@coordinates['latitude'] = @coordinates['latitude'].to_f
end
if @coordinates['longitude'].is_a? String
@coordinates['longitude'] = @coordinates['longitude'].to_f