Skip to content

Instantly share code, notes, and snippets.

@petrosmm
petrosmm / next.config.js
Created September 30, 2023 18:41
working but slightly messy next.config.js with bundle splitting for webpack5 / nextjs 13
/**
* @typedef {import("next").NextConfig} NextConfig
* @typedef {import("webpack").Configuration} WebpackConfig
* @typedef {import("next/dist/server/config-shared").WebpackConfigContext} WebpackConfigContext
* @typedef {(config: WebpackConfig, context: WebpackConfigContext) => any} NextWebpackConfig
* @typedef {import("webpack").optimize.SplitChunksPlugin} SplitChunksPlugin
* @typedef {import("@next/bundle-analyzer")} BundleAnalyzerPlugin
* @typedef {import("copy-webpack-plugin")} CopyPlugin
* https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config
* https://adamjberkowitz.com/blog/post/managing-webpack-vendor-chunks-and-wordpress
@petrosmm
petrosmm / routes.ts
Created February 16, 2023 03:16
nextjs route searcher
#!/usr/bin/env node
// route searcher with some custom params (...page..., ...api... etc) for next.js
import klaw from "klaw";
import * as fs from 'fs'; // OR const fs = require('fs').promises;
import path from "path";
import * as _fs from 'fs'; // OR const fs = require('fs').promises;
@petrosmm
petrosmm / Dockerfile
Last active November 9, 2022 22:07
softether bridge docker (debian)
# inspiration
# https://github.com/AntoineMary/docker-softether-vpn-bridge/blob/master/Dockerfile
# resources
# https://www.sdrplay.com/community/viewtopic.php?t=4209
# https://stackoverflow.com/questions/37818831/is-there-a-best-practice-on-setting-up-glibc-on-docker-alpine-linux-base-image
# https://www.startpage.com/sp/search?query=%22-s+%2Fsbin%2Fnologin%22+debian&t=device&lui=english&sc=XHeLBvq6o3Va00&cat=web
# https://www.startpage.com/do/dsearch?query=dockerfile+groupid&language=english&cat=web&pl=ext-chrome&extVersion=1.1.2
# https://snyk.io/blog/10-docker-image-security-best-practices/
@petrosmm
petrosmm / cli.ts
Last active February 16, 2023 03:12
route builder sample for directus; used when item in questions are linked but self-referencing
#!/usr/bin/env node
// basic commands
// cls && tsc cli.ts --esModuleInterop true --outDir build && node build/cli.js
// REM && pause
import fetch from "node-fetch";
import _ from "lodash";
import Enumerable from "node-enumerable";
@petrosmm
petrosmm / gist:72398d84c5e6cababf935e51b58604fe
Last active September 15, 2021 19:29
sendy add images embedded

I have been searching for a way to properly inline images into emails for Sendy (Sendy.co). I have only found one way to do it. This method involves using src='cid:imagecidnamejpg' as an attribute on the <img /> tags that you intend to inline. Example below if I attach a file named imagecidname.jpg then my cid value in the src tag should be imagecidnamejpg. As another example: if I use img01.png, it will strip anything except a-z, 0-9 chars and you will be left img01png as your corresponding cid value.

Replace $mail->AddAttachment($attachment); in the /scheduled.php and /includes/create/send-now.php with

if (strpos($attachment, '.jpg') !== false || strpos($attachment, '.png') !== false) { $cid = preg_replace('/[^a-zA-Z0-9]+/', '', basename($attachment)); $mail->AddEmbeddedImage($attachment, $cid, basename($attachment)); } else {

@petrosmm
petrosmm / logparser.sql
Last active December 20, 2017 14:56
IIS Errors SQL script using Log Parser with Site Id and local DateTime showing only results from current day
SELECT EXTRACT_SUFFIX(EXTRACT_PATH(LogFilename), 0, '\W3SVC') as Site, TO_LOCALTIME(TO_TIMESTAMP(date, time)) AS [datetime], [LogFilename], [LogRow], [c-ip], [cs-username], [s-sitename], [s-computername], [s-ip], [s-port], [cs-method], [cs-uri-stem], [cs-uri-query], [sc-status], [sc-substatus], [sc-win32-status], [sc-bytes], [cs-bytes], [time-taken], [cs-version], [cs-host], [cs(User-Agent)], [cs(Cookie)], [cs(Referer)], [s-event], [s-process-type], [s-user-time], [s-kernel-time], [s-page-faults], [s-total-procs], [s-active-procs], [s-stopped-procs]
/* remove columns: [date], [time], */
FROM '[LOGFILEPATH]'
WHERE
TO_STRING(TO_LOCALTIME(TO_TIMESTAMP(date, time)), 'dd') = TO_STRING(SYSTEM_DATE(), 'dd') AND
[sc-status] NOT BETWEEN 200 AND 399
ORDER BY datetime desc
@petrosmm
petrosmm / openemr_psych_form.xml
Last active May 18, 2022 20:40
OpenEMR Psych Form
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- I created this form for a Doctor's office that I contract with. Generated by hand. -->
<form>
<!-- Please note that the following variables '{{ }}' at the top of the code need to be implemented. -->
<table type="form">{{table}}_{{date}}</table>
<RealName>{{RealName}} {{date}}</RealName>
<safename>{{safename}}_{{date}}</safename>
<style cells_per_row="5">layout</style>
<acl table="patients">med</acl>
<manual>
@petrosmm
petrosmm / MidpointRounding.AwayFromZero.js
Last active August 18, 2023 03:41
A function to assist in MidpointRounding.AwayFromZero on the client side
function RoundAwayFromZero(startValue, digits) {
var decimalValue = 0;
digits = digits || 0;
startValue *= parseFloat(Math.pow(10, (digits + 1)));
decimalValue = parseInt(Math.floor(startValue)) - (Math.floor(startValue / 10) * 10);
startValue = Math.floor(startValue / 10);
if (decimalValue >= 5) {
startValue += 1;
}
startValue /= parseFloat(Math.pow(10, (digits)));