Skip to content

Instantly share code, notes, and snippets.

View dmgawel's full-sized avatar

Dawid Gaweł dmgawel

  • Doist
  • Wrocław, Poland
View GitHub Profile
@dmgawel
dmgawel / astro.config.mjs
Last active October 9, 2025 12:48
Serve Astro static pages with Node middleware adapter without trailing slashes
import node from '@astrojs/node'
import { defineConfig } from 'astro/config'
// https://astro.build/config
export default defineConfig({
adapter: node({
mode: 'middleware',
}),
trailingSlash: 'never',
@dmgawel
dmgawel / i18next-to-icu.bun.js
Created May 7, 2024 14:54
Convert i18next JSON format resources to ICU message format
/* eslint-disable */
import { default as ICUConvert } from './icu'
import { isPlainObject, pickBy, set, transform } from 'lodash'
import * as pluralCategories from 'make-plural/pluralCategories'
import { readdir } from 'node:fs/promises'
const cldrPluralCategories = ['zero', 'one', 'two', 'few', 'many', 'other']
const cldrReversed = cldrPluralCategories.reverse()
// Removes files from public/static/locales/<lang>/ that have no matching
// file in public/static/locales/en/
import { readdir, unlink } from 'node:fs/promises'
import { basename, join } from 'node:path'
const TRANSLATIONS_ROOT_DIR = 'public/static/locales/'
/**
* @param {string | Buffer | URL} directoryPath
@dmgawel
dmgawel / i18next-to-icu.bun.ts
Created March 27, 2024 10:53
Convert i18next resources to ICU message format
import { default as ICUConvert } from '@messageformat/convert'
import * as pluralCategories from 'make-plural/pluralCategories'
import { readdir } from 'node:fs/promises'
import { transform, set, isPlainObject, pickBy } from 'lodash'
const cldrPluralCategories = ['zero', 'one', 'two', 'few', 'many', 'other']
/**
* Get country from locale (pt_BR -> pt)
@dmgawel
dmgawel / functions.php
Created July 7, 2015 11:25
ThreeWP Broadcast plugin for Wordpress: allow super admins to broadcast to any blog
// Put it somewhere in your theme's functions.php
add_action('threewp_broadcast_get_user_writable_blogs', function( $action ) {
if ( $action->is_finished() )
return;
$blogs = is_super_admin() ? wp_get_sites() : get_blogs_of_user( $action->user_id );
foreach( $blogs as $blog)
{
$blog = \threewp_broadcast\broadcast_data\blog::make( $blog );