Skip to content

Instantly share code, notes, and snippets.

View ajepe's full-sized avatar
🏠
Working from home

Babatope Ajepe ajepe

🏠
Working from home
View GitHub Profile
@ajepe
ajepe / Odoo POS Over HTTP
Created June 11, 2018 14:58
Odoo POS Over HTTP
# Redirect POS to http
location ~ ^/pos/web {
rewrite ^(.*) http://$host:8069$1 permanent;
}
@ajepe
ajepe / email.js
Created August 5, 2018 01:16
email
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
}
/*
@ajepe
ajepe / psql_encoding.markdown
Created August 8, 2018 10:44 — forked from joshteng/psql_encoding.markdown
This solves Postgresql's encoding issue (happened to me when running postgres on my vagrant box) The error happens when trying to create db "rake db:create": Error message: "encoding UTF8 does not match locale en_US; the chosen LC_CTYPE setting requires encoding LATIN1"
sudo su postgres
psql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate=true where datname='template1';
<?php
/**
* Created by PhpStorm.
* User: Raihan
* Date: 10-Jul-17
* Time: 4:37 AM
*/
class CryptOpenssl{
private $hash;
@ajepe
ajepe / random number
Last active January 25, 2019 10:12
my crazy random number and otp
''.join([str(random.randint(0, 9)) for _ in range(11)])
def otp(length=5, lowerband=1, upperband=9):
return ''.join(
random.sample([str(random.randint(lowerband, upperband))
for _ in range(upperband+1)], length)
)
curl -gkvLI -H 'User-Agent: updown.io daemon 2.2' -H 'Accept: */*' -H 'Connection: Close' -H 'Accept-Language: en' -m 30 --connect-timeout 5 http://odoosme.ng
@ajepe
ajepe / md
Created January 15, 2019 07:56
Nigeria Banks sort code
{
"070010": "ABBEY MORTGAGE BANK-070010",
"044": "ACCESS BANK PLC-044",
"323": "AccessMobile-100013",
"090134": "ACCION MICROFINANCE BANK-090134",
"090160": "ADDOSSER MICROFINANCE BANK-090160",
"100028": "AG MORTGAGE BANK PLC-100028",
"090133": "AL-BARAKAH MICROFINANCE BANK-090133",
"090180": "AMJU UNIQUE MICROFINANCE BANK-090180",
"090116": "AMML MFB-090116",
@ajepe
ajepe / nginx
Created April 15, 2019 11:12
Odoo basic nginx conf
#odoo server
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
# http -> https
# server {
wget -P build -nv -nH -r -E localhost:3000
@ajepe
ajepe / database.sql
Created October 16, 2019 06:49
Get database size
select t1.datname AS db_name,
pg_size_pretty(pg_database_size(t1.datname)) as db_size
from pg_database t1
order by pg_database_size(t1.datname) desc;