Skip to content

Instantly share code, notes, and snippets.

View aiphee's full-sized avatar

Jiří Forst aiphee

View GitHub Profile
@aiphee
aiphee / StringToNode.tsx
Last active April 29, 2024 09:36
Fragment with dangerouslySetInnerHtml replacement -
import React from 'react';
interface IProps {
children: unknown;
}
/**
* Takes node content and makes JSX element out of it (kind of like dangerouslySetInnerHTML)
* Careful, always sanitize input!
* credit @yairEO https://github.com/facebook/react/issues/12014#issuecomment-1621382570
@aiphee
aiphee / nginx.conf
Last active September 4, 2020 08:49
Webpack dev server with hot reload on remote machine
http {
upstream webpack_hot_server {
server 127.0.0.1:9821;
}
}
location ~ /js/compiled/webpack_hot/.*\.(js|json)$ {
# Pass these requests to upstream of `yarn dev-hot` (webpack dev server)
proxy_pass http://webpack_hot_server;
@aiphee
aiphee / TranslationsController.php
Last active June 27, 2020 09:43
CakePhp manage pot translations simple gui
<?php
namespace App\Controller\Admin;
use App\Application;
use App\Controller\AppController;
use App\Model\Entity\User;
use Cake\Filesystem\File;
use Cake\Filesystem\Folder;
use Cake\Http\Response;
use Cake\I18n\I18n;
@aiphee
aiphee / ConvertDefaultTranslationsCommand.php
Created February 16, 2020 09:20
Cakephp console which converts secondary language to primary for 18n table
<?php
namespace App\Command;
use App\Application;
use App\Model\Entity\I18n;
use App\Model\Table\I18nTable;
use Cake\Console\Arguments;
use Cake\Console\Command;
use Cake\Console\ConsoleIo;
use Cake\Core\Configure;
@aiphee
aiphee / AppController.php
Last active January 16, 2020 20:23
Cakephp save execution time
<?php
//...
public function shutdownProcess()
{
$result = parent::shutdownProcess();
try {
$this->savePerformance();
} catch (\Throwable $e) {
$this->log('Nepovedlo se uložit výkon', LogLevel::WARNING);
@aiphee
aiphee / LokaliseShell.php
Created October 29, 2019 22:46
Lokalise.com for CakePhp 3.6 using official API
<?php
namespace App\Shell;
use Cake\Console\Shell;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Network\Http\Client;
use Cake\Utility\Hash;
use ZipArchive;
@aiphee
aiphee / scrollbooster.js
Last active February 28, 2019 21:33
ScrollBooster requirejs (amd?)
"use strict";
define([], function () {
"use strict";
var exports = {};
Object.defineProperty(exports, "__esModule", {
value: true
});