Skip to content

Instantly share code, notes, and snippets.

@murdercode
murdercode / laravel-fastcgi-cache-config.md
Last active July 3, 2024 10:19
Optimizing Laravel (and Nova) with FastCGI Cache Configuration

Laravel + FastCGI Cache = ❤️

⚠️ Need a more specific guide? See https://medium.com/@murdercode/speed-up-your-laravel-application-up-to-1000x-with-fastcgi-cache-0135b11407e5

Using FastCGI cache allows you to speed up your website up to 1000x. In fact, the FastCGI cache (or Varnish) mechanism consists of putting a server-caching mechanism between a client and your web server. The whole page will be cached as an HTML output, and it will be delivered instead of using the PHP/MySQL/Redis stack, etc. for all users, but only for the first visit (and others after some specified time).

WARNING: This is not a take-away how-to. Please read it carefully and use it at your own risk.

This config is based on the ploi.io stack. We will not cover the FastCGI installation process, so please prepare FastCGI and adapt the next config if you need it.

@devakone
devakone / safe-html.js
Created June 12, 2019 19:34
How to translate partial HTML content with dangerouslySetInnerHTML and react-i18next
import dompurify from 'dompurify';
import useTranslateHtmlElement from './use-translate-html-element';
// Our safe HTML rendering component
// From https://dev.to/jam3/how-to-prevent-xss-attacks-when-using-dangerouslysetinnerhtml-in-react-1464
function SafeHTMLComponent() {
// title is dynamic HTML
const title = response.from.backend.title;
// sanitizer will sanitize the HTML
const sanitizer = dompurify.sanitize;
@devakone
devakone / use-translate-form-errors-with-formik-component-method.js
Created June 12, 2019 18:37
How to use the useTranslateFormErrors hook with Formik's component render method.
...
<Formik component={ContactForm} />;
...
import useTranslateFormErrors from '../../hooks/use-translate-form-errors';
const ContactForm = ({
handleSubmit,
handleChange,
@stewartmcgown
stewartmcgown / partialMatch.js
Created January 15, 2019 12:03
Partial Match properties of Object Array (ES6)
/**
* Are all the values on p present on o
* @param {Object} o object to search
* @param {Object} p object of search values
* @param {Boolean} [c] are loose equality matches ok?
* @return {Boolean} whether there are partial matches
*/
const partialMatch = (o, p, c) =>
Object.keys(p).every(k =>
p[k] && o[k]
@rcoup
rcoup / .gammurc
Last active May 23, 2024 16:59
Gammu config and script for receiving SMS via a USB modem attached to an OSX computer and forwarding it into iMessage, where it will appear on all your devices.
[gammu]
port = /dev/tty.HUAWEIMobile-Modem
connection = at19200
model = at
synchronizetime = yes
logfile = /Users/me/.gammu/log
logformat = errorsdate
gammucoding = utf8
[smsd]