Skip to content

Instantly share code, notes, and snippets.

View smaillns's full-sized avatar

Smail LOUNES smaillns

View GitHub Profile
(function(window) {
window.env = window.env || {};
// Environment variables
window["env"]["api"] = "${API_URL}";
window["env"]["google_maps_api"] = "${GOOGLE_MAPS_API}";
window["env"]["gtm"] = "${GTM}";
})(this);
@smaillns
smaillns / env.js
Last active January 8, 2022 15:12
(function(window) {
window["env"] = window["env"] || {};
// Environment variables
window["env"]["api"] = "http://localhost:8000";
window["env"]["google_maps_api"] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
window["env"]["gtm"] = "GTM-xxxxxxx";
})(this);
@smaillns
smaillns / Http entrypoints
Last active January 1, 2022 19:29
Nameko http endpoints
import json
from marshmallow import ValidationError
from nameko_sqlalchemy import DatabaseSession
from werkzeug import Response
from books.exceptions import HttpError, NotFound, BadRequest
from books.models import DeclarativeBase, Book, Author
from books.schemas import BookSchema, CreateBookSchema
from datetime import datetime, timezone
@smaillns
smaillns / Marshmallow
Created January 1, 2022 00:08
Marshmallow schemas
from marshmallow import Schema, fields
class AuthorSchema(Schema):
id = fields.Int(required=True)
name = fields.Str(required=True)
gender = fields.Str(required=True)
created_at = fields.Date()
updated_at = fields.Date()
@smaillns
smaillns / models
Created January 1, 2022 00:01
SQLALchemy models
import datetime
import enum
from sqlalchemy import (Column, DateTime, ForeignKey, Integer, String, Enum)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
class GenderEnum(enum.Enum):
Male = 'Male'
@smaillns
smaillns / Pipfile
Last active December 31, 2021 23:42
Pipefile
[packages]
nameko = "==3.0.0-rc9"
nameko-sqlalchemy= "==1.5.0"
alembic = "==1.6.5"
marshmallow= "==2.19.2"
sqlalchemy= "==1.4.22"
psycopg2-binary= "==2.9.1"
[dev-packages]
pytest= "==4.5.0"
// component.ts
myLatLng = { lat: 48.829677, lng: 2.239609 };// Map Options
mapOptions: google.maps.MapOptions = {
center: this.myLatLng,
zoom: 10,
};
markerOptions: google.maps.MarkerOptions = { icon: 'https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi-dotless.png' };
<!-- component.html -->
<google-map [options]="mapOptions" width="100%">
<map-marker
*ngFor="let spot of spots"
[position]="{ lat: spot.lat, lng: spot.lng }"
[options]="markerOptions"
[clickable]="true"
(mapClick)="selectMarker(spot)"
></map-marker>
</google-map>
// component.ts
myLatLng = { lat: 48.829677, lng: 2.239609 }; // Map Options
mapOptions: google.maps.MapOptions = {
center: this.myLatLng,
zoom: 10,
};
markerOptions: google.maps.MarkerOptions = {};
<!-- component.html -->
<google-map [options]="mapOptions" width="100%">
<map-marker *ngFor="let spot of spots"
[position]="{ lat: spot.lat, lng: spot.lng }"
[options]="markerOptions"></map-marker>
</google-map>