Skip to content

Instantly share code, notes, and snippets.

View smaillns's full-sized avatar

Smail LOUNES smaillns

View GitHub Profile
@smaillns
smaillns / docker-compose.yml
Created May 8, 2022 13:28
Mongo ReplicaSet
version: "3"
services:
mongo1:
hostname: mongo1
container_name: localmongo1
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27011:27017
# Build the app
FROM node:12-alpine as build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm install -g @angular/cli
RUN ng build --prod --output-path=/dist
# Run in NGINX
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
...
<script src="assets/env.js"></script>
</head>
<body>
<app-root>
export const environment = {
apiUrl: window['env']['api'] || null,
gtmScript: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer', '${window['env']['gtm'] || 'GTM-XXXXXXX'}');`
(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"