Skip to content

Instantly share code, notes, and snippets.

@Convly
Convly / strapi-content-api.ts
Last active December 17, 2024 19:33
PoC for dynamic content API response types
import type { Attribute, Common, Utils } from '@strapi/types';
type IDProperty = { id: number };
type InvalidKeys<TSchemaUID extends Common.UID.Schema> = Utils.Object.KeysBy<
Attribute.GetAll<TSchemaUID>,
Attribute.Private | Attribute.Password
>;
export type GetValues<TSchemaUID extends Common.UID.Schema> = {
@MrChocolatine
MrChocolatine / TS - More precise return type method Date#toISOString.d.ts
Last active November 22, 2024 15:02
TypeScript – How to accurately type dates in ISO 8601 format
// In TS, interfaces are "open" and can be extended
interface Date {
/**
* Give a more precise return type to the method `toISOString()`:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
*/
toISOString(): TDateISO;
}
type TYear = `${number}${number}${number}${number}`;
@teocci
teocci / ffmpeg_install_latest.md
Last active September 13, 2023 02:17
Easy way to convert MKV to MP4 with ffmpeg

How to install FFmpeg on Ubuntu

FFmpeg is a free and open source command line tool for transcoding multimedia files. It contains a set of shared audio and video libraries such as: libavcodec, libavformat, and libavutil. With this tool, you can convert between various video and audio formats, set sample rates and resize videos.

In this document will show you how to install a stable version and the latest version of FFmpeg. This instructions apply for any Ubuntu based distribution, including Linux Mint and Elementary OS.

Prerequisites

In order to be able to add new repositories and install packages on your Ubuntu system, you must be logged in as a user with sudo privileges.

Installing FFmpeg 4.x on Ubuntu

@Isa3v
Isa3v / README.md
Last active December 19, 2024 23:08
Пагинация в мета-тегах и h1 (Bitrix)

Пагинация в мета-тегах, h1 + canonical (Bitrix)

Задача:

*Добавить на страницах пагинации в title, description и h1 приписку с номером страницы

Решение:

*В bitrix/php_interface/init.php (если нет, то создаем) добавляем в конец функцию разбирающая мета-теги и собирающая обратно

Событие "OnEpilog" вызывается в конце визуальной части эпилога сайта. (После того как битрикс получит уже все данные страницы)

@brenopolanski
brenopolanski / export-svg-inkscape.md
Created December 26, 2017 13:29
Exporting an object as svg from inkscape
  1. Select the object(s) to export
  2. Open the document properties window (Ctrl+Shift+D)
  3. Select "Resize page to drawing or selection"
  4. File > Save As Copy...
  5. Select Optimized SVG as the format if you want to use it on the web
@bob-lee
bob-lee / polyfill-ie11-nodelist-foreach.js
Created November 24, 2017 18:41
Polyfill for IE11 missing NodeList.forEach
if ('NodeList' in window && !NodeList.prototype.forEach) {
console.info('polyfill for IE11');
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
@xameeramir
xameeramir / default nginx configuration file
Last active December 9, 2024 01:45
The default nginx configuration file inside /etc/nginx/sites-available/default
# Author: Zameer Ansari
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
@pongo
pongo / .htaccess
Last active March 5, 2020 07:49
serves a .webp image instead of jpg/png
<IfModule mod_rewrite.c>
RewriteEngine On
# serves a .webp image instead of jpg/png
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} ^(.+)\.(jpe?g|png)$
RewriteCond %1\.webp -f
RewriteRule ^(.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
@bladeSk
bladeSk / SQLite-PHP-quickstart.php
Last active November 22, 2024 14:14
SQLite3 PHP Quickstart Tutorial
<?php
// This file walks you through the most common features of PHP's SQLite3 API.
// The code is runnable in its entirety and results in an `analytics.sqlite` file.
// Create a new database, if the file doesn't exist and open it for reading/writing.
// The extension of the file is arbitrary.
$db = new SQLite3('analytics.sqlite', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
// Errors are emitted as warnings by default, enable proper error handling.
@florianboudot
florianboudot / CSS-transform-blurry-fix.css
Created April 13, 2017 15:26
CSS transform blurry fix
/* translateZ + scale = fix font blurry */
-webkit-font-smoothing: subpixel-antialiased;
transform: translate3d(-50%, -50%, 0) scale(2, 2);
zoom: 0.5;