Skip to content

Instantly share code, notes, and snippets.

@mdnmdn
mdnmdn / portainer-stack.yaml
Last active September 6, 2023 12:49
traefik + portainer on docker
version: "3.3"
services:
portainer:
image: portainer/portainer-ce:2.19.0
container_name: portainer
restart: always
labels:
- "traefik.docker.network=public-web"
- "traefik.enable=true"
Mix.install([
{:postgrex, "~> 0.15.0"}
])
{defmodule MyMod do
def main do
{:ok, pid} =
Tds.start_link(
hostname: "localhost",
username: "sa",
@mdnmdn
mdnmdn / shortid_sid.sql
Last active June 12, 2023 21:48
postgres short uuid custom domain for human management with cast and equality operators
CREATE DOMAIN public.sid AS CHAR(8);
CREATE OR REPLACE FUNCTION cast_uuid_as_sid(uuid)
RETURNS sid
LANGUAGE SQL AS
$$ SELECT substr($1::text,1,8)::sid $$;
CREATE OR REPLACE FUNCTION eq_uuid_sid(id1 uuid, id2 sid)
RETURNS BOOLEAN
LANGUAGE SQL AS
@mdnmdn
mdnmdn / custom.css
Last active November 18, 2019 14:28
sample-css
.grigua-css h1 {
font-style: italic;
}
@mdnmdn
mdnmdn / custom.css
Created November 18, 2019 14:28
sample-css
.grigua-css h1 {
font-style: italic;
}
@mdnmdn
mdnmdn / custom.css
Created November 18, 2019 14:28
sample-css
.grigua-css h1 {
font-style: italic;
}
@mdnmdn
mdnmdn / mongo.js
Created August 14, 2019 22:03
Node mongo connection with promises
// npm i mongodb
const { MongoClient } = require('mongodb');
const MONGODB_URI = 'mongodb://localhost:27021/testdata';
let mongoConnection = null;
const getMongo = async () => {
if (!mongoConnection){
@mdnmdn
mdnmdn / create-user.sql
Created March 18, 2019 09:43
TSQL - Create user / enable mixed auth
CREATE LOGIN myUserName WITH PASSWORD = 'pwd';
USE My_Database
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'myUserName')
BEGIN
CREATE USER [myUserName] FOR LOGIN [myUserName]
EXEC sp_addrolemember N'db_owner', N'myUserName'
END;
@mdnmdn
mdnmdn / splitstrings.sql
Last active August 23, 2018 12:03
TSQL SplitInts, SplitStrings: string to list of string and to list of ints
CREATE FUNCTION SplitInts
(
@list varchar(8000),
@delimiter char(1) = '#'
)
RETURNS TABLE WITH SCHEMABINDING
AS
RETURN (
SELECT [value] from (
SELECT [value] = cast(y.i.value('(./text())[1]', 'varchar(8000)') as int)
@mdnmdn
mdnmdn / bulk_rename.js
Created January 2, 2018 22:19
node bulk rename with regex replace
const fs_orig = require('fs');
const util = require('util');
const fs = {
readdir: util.promisify(fs_orig.readdir),
rename: util.promisify(fs_orig.rename),
}
const l = console.log.bind(console);