Skip to content

Instantly share code, notes, and snippets.

View okparaa's full-sized avatar
💭
personal project

Okpara Ifeanyi okparaa

💭
personal project
  • Beeworks Ltd
View GitHub Profile
@okparaa
okparaa / app.js
Created January 31, 2024 06:37 — forked from prof3ssorSt3v3/app.js
Code for Service Workers 9 - Integrating IndexedDB into site with a Service Worker
const APP = {
SW: null,
DB: null, //TODO:
init() {
//called after DOMContentLoaded
//register our service worker
APP.registerSW();
document
.getElementById('colorForm')
.addEventListener('submit', APP.saveColor);
@okparaa
okparaa / sw.js
Created January 31, 2024 05:46 — forked from logaretm/sw.js
Caching GraphQL responses with Service Workers
const QUERY_CACHE_KEY = 'CACHE_V_0';
const GRAPHQL_URL = 'https://example.com/graphql';
self.addEventListener('fetch', e => {
if (isGraphql(e.request)) {
handleGraphQL(e);
}
});
function fullSync(page = 1) {
let open = indexedDB.open("books", 1);
// Set up the database schema
open.onsuccess = evt => {
let db = open.result;
fullSyncPage(db, 1);
};
}
@okparaa
okparaa / websocket.js
Created June 15, 2023 21:06 — forked from ywwwtseng/websocket.js
websocket
class Socket {
constructor(
domain,
{ reconnection = true, reconnectionDelay = 1000 } = {
reconnection: true,
reconnectionDelay: 1000,
}
) {
this.ws = this.connect(domain);
this.reconnection = reconnection;
// Based on:
// http://github.com/alexanderte/websocket-server-node.js
// http://github.com/Guille/node.websocket.js
function nano(template, data) {
return template.replace(/\{([\w\.]*)}/g, function (str, key) {
var keys = key.split("."), value = data[keys.shift()];
keys.forEach(function (key) { value = value[key] });
return value;
});

#Installing configuring Postfix/Dovecot/Spamassassin/Roundcube

I've documented the steps in short to help me reproduce all the steps. Published it here for improvement and as a reference for others. Of course feel free to comment to improve this document.

This Gist is quite big and not all details are fully explained. But if you're going to run a mailserver you should be able to fill in the missing parts. The most important are covered. But be sure to read up to understand the meaning of all the stuff you configure. Since I used a lot of references of other sources (See at the end) I left out a lot of explanation in this document.

Don't forget that I'm not a Postfix/Dovecot/Spamassasin pro either. I just got it working the way I wanted to.

  • Used Ubuntu 12.04 LTS.
  • Set a root password.
@okparaa
okparaa / midea.tsx
Created January 30, 2023 07:57
midea dev
import { h, FunctionComponent } from 'preact'
import { Device } from 'mediasoup-client'
import { useEffect, useRef } from 'preact/hooks'
import {
Consumer,
Producer,
RtpCapabilities,
Transport,
} from 'mediasoup-client/lib/types'
import { openSocket } from '../../lib/socket'
@okparaa
okparaa / media.ts
Created January 30, 2023 07:55
media dev
import { Consumer, Producer, Transport } from 'mediasoup/node/lib/types'
import WebSocket from 'ws'
import { createWebrtcTransport } from './createWebrtcTransport'
import { createRouter } from './router'
const WebsocketConnection = async (websocket: WebSocket.Server) => {
const { router } = await createRouter()
let producerTransport: Transport
let consumerTransport: Transport
let producer: Producer
@okparaa
okparaa / http2_apache2_ubuntu18.04.md
Created January 3, 2021 08:38 — forked from GAS85/http2_apache2_ubuntu18.04.md
How to Enable HTTP/2 in Apache 2.4 on Ubuntu 18.04

Requirements

  • A self-managed VPS or dedicated server with Ubuntu 18.04 running Apache 2.4.xx.
  • A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.

Step 1: Install Apache2

@okparaa
okparaa / eventemitter.js
Created July 26, 2019 10:45 — forked from mudge/eventemitter.js
A very simple EventEmitter in pure JavaScript (suitable for both node.js and browsers).
/* Polyfill indexOf. */
var indexOf;
if (typeof Array.prototype.indexOf === 'function') {
indexOf = function (haystack, needle) {
return haystack.indexOf(needle);
};
} else {
indexOf = function (haystack, needle) {
var i = 0, length = haystack.length, idx = -1, found = false;