Skip to content

Instantly share code, notes, and snippets.

View BolajiOlajide's full-sized avatar

Bolaji Olajide BolajiOlajide

View GitHub Profile
FROM python:3.6.8-alpine
LABEL image for a very simple flask application
WORKDIR /docker-flask
COPY . .
RUN ["pip3", "install", "pipenv"]
@BolajiOlajide
BolajiOlajide / regex.py
Created May 3, 2019 00:09
regex to ensure all strings contained in a string are accepted
import re
pattern = r'[A|B]+$'
m = re.compile(pattern)
m = m.match('EAB')
print(m)
<html>
<head>
<style>
main {
height: 4000px;
position: relative;
background: cornflowerblue;
}
h1 {
@BolajiOlajide
BolajiOlajide / class.ts
Created April 22, 2019 17:40
access modifiers in typescript
class FooBase {
public x: number;
private y: number;
protected z: number;
}
// EFFECT ON INSTANCES
var foo = new FooBase();
foo.x; // okay
foo.y; // ERROR : private
@BolajiOlajide
BolajiOlajide / db-dump.sh
Created March 1, 2019 22:36
script to automate postgres backup
pg_dump -U bolaji -h localhost -d lendme > dump.sql
@BolajiOlajide
BolajiOlajide / gist:d7ba403a0d19fcf48f40d1dda0ce4c4d
Created February 17, 2019 02:05 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@BolajiOlajide
BolajiOlajide / mysql_downgrade.txt
Created February 16, 2019 23:55 — forked from 6temes/mysql_downgrade.txt
Downgrade MySQL version with brew
# Kill rails server and guard
bin/spring stop
brew services stop mysql
brew uninstall mysql
brew install mysql@5.5
brew link mysql@5.5 --force
brew services start mysql@5.5
rbenv uninstall 2.3.3
rbenv install 2.3.3
gem install bundle
import asyncio
# Borrowed from http://curio.readthedocs.org/en/latest/tutorial.html.
@asyncio.coroutine
def countdown(number, n):
while n > 0:
print('T-minus', n, '({})'.format(number))
yield from asyncio.sleep(1)
n -= 1
@BolajiOlajide
BolajiOlajide / async_loop.js
Last active January 15, 2019 23:38
comparing how async operations are handled in a forEach loop and normal for loop
const startForLoop = async () => {
const loans = [
'loanOne', 'loanTwo', 'loanThree', 'loanFour', 'loanFive', 'loanSix', 'loanSeven', 'loanEight'
];
let transactionCount = 0;
const transactionLimit = 3;
const waitFor = (ms) => new Promise(r => setTimeout(r, ms));
for (let index = 0; (index < loans.length && transactionCount <= transactionLimit); index += 1) {
@BolajiOlajide
BolajiOlajide / bash.cheat
Created January 13, 2019 21:40 — forked from afair/bash.cheat
Bash Scripting Quick Reference
==========================================
BASH SCRIPTING ==========================================
========================================== TEST COMMAND
==========================================
Invoke: bash [options] file
Shebang: #!/usr/bin/env bash Test: test expression
In script: [ expression ]
========================================== Alternate: [[ espression ]]
LOOP Does not split string words
========================================== Does not expand pathglobs*