Skip to content

Instantly share code, notes, and snippets.

View daliborgogic's full-sized avatar
:octocat:
In Git we trust!

Dalibor Gogic daliborgogic

:octocat:
In Git we trust!
View GitHub Profile
@daliborgogic
daliborgogic / index.js
Created May 20, 2019 15:18
Abortable Fetch
// This will allow us to abort the fetch
let controller
// Abort if the user clicks
abortBtn.addEventListener('click', () =>
if (controller) controller.abort()
)
// Load the content
loadBtn.addEventListener('click', async () => {
@daliborgogic
daliborgogic / index.js
Last active November 12, 2025 09:34
Split Business and Native errors Async/Await Node.js
import { parse } from 'node:url'
/*
Native Error types
@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
*/
const nativeExceptions = [
EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError
].filter(except => typeof except === 'function')
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2 default_server;
{
"default-src": [
"'none'"
],
"base-uri": [
"'self'"
],
"block-all-mixed-content": [],
"connect-src": [
"'self'",
@daliborgogic
daliborgogic / wp-config.php
Last active May 12, 2019 18:16
[SMTP WP] #wp
define('SMTP_USER','mail@example.com'); // Username to use for SMTP authentication
define('SMTP_PASS', '############'); // Password to use for SMTP authentication
define('SMTP_HOST', 'mail.host.com'); // The hostname of the mail server
define('SMTP_FROM', 'mail@example.com'); // SMTP From email address
define('SMTP_NAME', 'Example'); // SMTP From name
define('SMTP_PORT', '587'); // SMTP port number - likely to be 25, 465 or 587
define('SMTP_SECURE', 'tls'); // Encryption system to use - ssl or tls
define('SMTP_AUTH', true); // Use SMTP authentication (true|false)
define('SMTP_DEBUG', 0); // for debugging purposes only set to 1 or 2

Valid host expressions can include:

  • https://*.devoops.app Matches all subdomains of devoops.app using the HTTPS scheme but not devoops.app itself.

  • www.devoops.app443 Matches www.devoops.app only on port 443 using any scheme.

  • https://devoops.app:* Matches any port on devoops.app using HTTPS.

Name Options Description
@daliborgogic
daliborgogic / github.js
Last active October 7, 2019 17:44
Request a user's GitHub identity
const uuid = require('uuid')
const {
GITHUB_CLIENT_ID = '#####',
GITHUB_REDIRECT_URL = 'https://example.com/callback',
GITHUB_SCOPE = 'user:email'
} = process.env
const authorize = `https://github.com/login/oauth/authorize`
const states = []
@daliborgogic
daliborgogic / cert.vue
Last active March 29, 2019 19:39
Speech Recognition
<template>
<div>
<IconMic @dictate="dictate"/>
<div>{{ text }}</div>
</div>
</template>
<script>
import IconMic from '@/components/icons/mic'
export default {
@daliborgogic
daliborgogic / highlight.worker.js
Last active March 21, 2019 10:41
From ~729KB to ~24.2KB (~11.2KB Gzip)
// Core import
import hljs from 'highlight.js/lib/highlight'
addEventListener('message', async event => {
const { language, code } = event.data
// Language import
const x = await (await import(`highlight.js/lib/languages/${language}`)).default
// Register language
hljs.registerLanguage(language, x)
const result = hljs.highlightAuto(code)
@daliborgogic
daliborgogic / main.css
Last active February 10, 2025 15:32
Dynamic Metrics Inter font postcss
/* css variables does't work in math... */
/* using postcss-simple-vars */
$a: -0.0223;
$b: 0.185;
$c: -0.1745;
$lineHeight: 1.4;
$fontSize: 16;
@import url('https://rsms.me/inter/inter.css');