Skip to content

Instantly share code, notes, and snippets.

View BolajiOlajide's full-sized avatar

Bolaji Olajide BolajiOlajide

View GitHub Profile
@ichux
ichux / sm25.py
Last active November 5, 2018 09:32
send localmails
import email.utils
import smtplib
from email.mime.text import MIMEText
# Create the message
msg = MIMEText('Hello SMTPD!')
msg['To'] = email.utils.formataddr(("Local Mail", "localmail@localhost"))
msg['From'] = email.utils.formataddr(('Chukwudi Nwachukwu', 'chukwudinwachukwu@localhost'))
msg['Subject'] = 'Local mail using SMTP'
@chumaumenze
chumaumenze / Dockerfile
Created August 13, 2019 00:51
Using Pipenv in Docker
FROM python
ENV RUNNING_MODE production
WORKDIR /app
COPY Pipfile Pipfile.lock /app/
RUN pip install pipenv && \
pipenv install --system --deploy --ignore-pipfile
@mykeels
mykeels / inline-email-templates.script.ts
Created April 21, 2021 23:48
A script to inline styles on *.hbs files in a directory
import { promises as fs } from 'fs';
import path from 'path';
import inlineCss from 'inline-css';
import env from '../common/config/env';
/**
* So there are multiple *.hbs files, in a directory, and one of them, contains a link reference to tailwind cdn like:
* <link rel="stylesheet" href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css">
* In this script, we inline all their styles by
* - reading each file's content
@ivanleoncz
ivanleoncz / flask_app_logging.py
Last active May 23, 2021 07:25
Demonstration of logging feature for a Flask App.
#/usr/bin/python3
""" Demonstration of logging feature for a Flask App. """
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
__author__ = "@ivanleoncz"
import logging
@AndrewJHart
AndrewJHart / jwt_authentication.py
Created April 13, 2016 18:47
JWT authentication middleware for django rest framework that populates the request.user object
from django.utils.functional import SimpleLazyObject
from django.contrib.auth.models import AnonymousUser
from rest_framework.request import Request
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
def get_user_jwt(request):
"""
Replacement for django session auth get_user & auth.get_user for
@jameslyons
jameslyons / caesarCipher.py
Last active February 10, 2022 19:53
Caesar Cipher Python
# we need 2 helper mappings, from letters to ints and the inverse
L2I = dict(zip("ABCDEFGHIJKLMNOPQRSTUVWXYZ",range(26)))
I2L = dict(zip(range(26),"ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
key = 3
plaintext = "DEFEND THE EAST WALL OF THE CASTLE"
# encipher
ciphertext = ""
for c in plaintext.upper():
@romansorin
romansorin / .storybook
Created November 10, 2019 00:52
Gatsby, TailwindCSS, Storybook configuration
- addons.js
- config.js
- webpack.config.js
@lambdahands
lambdahands / _readme.md
Created September 28, 2015 17:09
FlowType and CSS Modules

Huh?

So basically FlowType doesn't know about CSS Modules, a really handy way of dealing with the plagues of CSS in codebases (global variables and dependency wackiness mainly).

What WebPack allows us to do is "require" CSS files and use their class names:

import styles from "my_styles.css";
import React from "react";
@Rich-Harris
Rich-Harris / README.md
Last active January 25, 2023 19:03
Unifying Rollup options

Rollup 0.48 introduces a few changes to the options object, because the current options are confusingly different between the CLI and the options exported by your config file.

Changes to the config file

  • entry is now input
  • sourceMap and sourceMapFile are now sourcemap and sourcemapFile (note casing)
  • moduleName is now name
  • useStrict is now strict

The dest and format options are now grouped together as a single output: { file, format, ... } object. output can also be an array of { file, format, ... } objects, in which case it behaves similarly to the current targets. Other output options — exports, paths and so on — can be added to the output object (though they will fall back to their top-level namesakes, if unspecified).

@zmts
zmts / knex_ssl.md
Last active September 3, 2023 23:21
Can't connect to PostgreSQL. SSL error with Nodejs/Knexjs (Digital ocean)

Can't connect to PostgreSQL. SSL error with Nodejs/Knexjs (Digital ocean)

Issues:

Case 1

{
  client: 'pg',
  connection: {
    host: process.env.DB_HOST,
    port: process.env.DB_PORT,