Skip to content

Instantly share code, notes, and snippets.

{
"geocoded_waypoints": [],
"routes": [
{
"bounds": {}
},
"copyrights": "Map data ©2020",
"legs": [
{
"distance": {
require 'json'
class MapsAPI
def get_directions(origin, destination, real_request = false)
response = api_endpoint(google_maps_api_key(real_request), origin, destination, real_request)
parsed = JSON.parse(response)
{
'status': parsed['status'],
'distance': parsed['routes'][0]['legs'][0]['distance']['value'].to_i,
class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :email
t.string :display_name
t.string :password_digest
t.timestamps
end
end
class CreateAnonymousUsers < ActiveRecord::Migration[6.0]
def change
create_table :anonymous_users do |t|
t.string :display_name
t.belongs_to :user, null: false, foreign_key: true
t.timestamps
end
end
end
class UsersController < ApplicationController
skip_before_action :authenticate_request, only: [:anon]
# create/register a user
def create
# transition anonymous account to full account
updateStatus = @current_user.update(email: params[:email], display_name: params[:display_name], password: params[:password])
if updateStatus
# delete the associated anonymous user
Rails.application.routes.draw do
get 'users/anon', to: 'users#anon'
get 'users/current', to: 'users#current'
post 'users/login', to: 'users#login'
resources :users, only: [:create]
end
class User < ApplicationRecord
def anon_display_name
if self.anonymous_user
self.anonymous_user.display_name
else
nil
end
end
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-image',
templateUrl: './image.component.html',
styleUrls: ['./image.component.scss']
})
export class ImageComponent implements OnInit {
@Input() imageUrl: string;
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-image',
templateUrl: './image.component.html',
styleUrls: ['./image.component.scss']
})
export class ImageComponent implements OnInit {
@Input() imageUrl: string;
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-image',
templateUrl: './image.component.html',
styleUrls: ['./image.component.scss']
})
export class ImageComponent implements OnInit {
@Input() imageUrl: string;