Skip to content

Instantly share code, notes, and snippets.

/*!
* jQuery JavaScript Library v1.4.4
* http://jquery.com/
*
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
@encryptblockr
encryptblockr / copy_csv_to_db.py
Created May 20, 2021 06:21 — forked from amulya349/copy_csv_to_db.py
This script can be used to copy a CSV file (with header) to a Postgres remote database.
#!/usr/bin/env/python
import psycopg2
# Get a database connection
dsn = "dbname=%s user=%s password=%s host=%s port=%s" % ('db_name','username','password','remote_host_ip','port')
conn = psycopg2.connect(dsn)
query = "COPY public.hiringpattern_new FROM stdin WITH CSV HEADER DELIMITER as ',' "
fp = open('csv_file_path', 'r')
@encryptblockr
encryptblockr / celery.sh
Created May 16, 2021 19:33 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@encryptblockr
encryptblockr / fastapi_app.py
Created May 14, 2021 21:11 — forked from nguqtruong/fastapi_app.py
Integrate Sentry to FastAPI
import os
from fastapi import FastAPI
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
import sentry_sdk
sentry_sdk.init(
dsn='your Sentry dns', # CHANGE HERE
environment=os.getenv('ENV', 'dev'), # You should read it from environment variable
@encryptblockr
encryptblockr / Dockerfile1
Created March 19, 2021 00:38 — forked from xeoncross/Dockerfile1
Examples of using multi-stage builds with docker and Go to reduce the final image size / attack surface.
# Sample from @citizen428 https://dev.to/citizen428/comment/6cmh
FROM golang:alpine as build
RUN apk add --no-cache ca-certificates
WORKDIR /build
ADD . .
RUN CGO_ENABLED=0 GOOS=linux \
go build -ldflags '-extldflags "-static"' -o app
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt \
from fastapi import FastAPI, Query
from fastapi.responses import JSONResponse
from typing import Optional
from pydantic import BaseModel, Field
tags_metadata = [
{
"name": "create-user",
"description": "Create new user based on *ID*. Will **overwrite** existing user.",
},
from typing import Optional
import base64
from passlib.context import CryptContext
from datetime import datetime, timedelta
import jwt
from jwt import PyJWTError
from pydantic import BaseModel
@encryptblockr
encryptblockr / example_locustfile.py
Created September 30, 2020 04:30 — forked from agconti/example_locustfile.py
Example Locustfile Keywords: Locustfile.py. Locust, LocistIo.
from locust import HttpLocust, TaskSet, task
class MostBasicLoadTest(TaskSet):
def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
self.login()
def login(self):
self.client.post("/api/api-token-auth/",
{
@encryptblockr
encryptblockr / docker-compose.yml
Created June 20, 2020 12:54 — forked from smashnet/docker-compose.yml
Docker-Compose: Mastodon v3.1.4 with Traefik v2.2
version: '3'
# Variables to fill in:
# Line 23: <LETSENCRYPT_MAIL_ADDRESS> - your mail address for contact with Let's Encrypt
# Line 36: <TRAEFIK_DASHBOARD_ADMIN_PASSWORD> - MD5 hash of your password (use http://www.htaccesstools.com/htpasswd-generator/)
# Line 54: <POSTGRES_PASSWORD> - the password for the postgres db. Use the same during mastodon:setup!
# Lines 31, 86, 111: <DOMAIN> - e.g. social.yourdomain.com (Must have an A record pointing to your box' IP) (AAAA for IPv6 ;)
services:
traefik:
@encryptblockr
encryptblockr / compose-caddy.yml
Created June 20, 2020 12:29 — forked from pascalandy/compose-caddy.yml
Traefik V2 / my docker compose files
version: "3.3"
services:
caddy:
image: abiosoft/caddy:1.0.3-no-stats
container_name: caddy
hostname: caddy
restart: unless-stopped
volumes: