Skip to content

Instantly share code, notes, and snippets.

@PowerKiKi
PowerKiKi / nginx.conf
Last active December 23, 2020 20:21
Angular Universal SSR with i18n - `yarn dev-ssr` does not work (yet), but production does work and so should pm2
# Everything else that does not exists on disk redirect to Angular
location ~ ^/(?<selectedLanguage>ar|br|cs|de|en|es|fr|is|it|ku|lb|pl|pt|zh) {
# If bot, give a SSR prerendered page
error_page 419 = @ssr;
if ($http_user_agent ~* "yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|facebookexternalhit|twitterbot") {
return 419;
}
try_files $uri /$selectedLanguage/index.html?$args;
}
@PowerKiKi
PowerKiKi / .nanorc
Created December 20, 2017 16:48
Nano configuration for git commit message (~/.nanorc)
syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(new file|modified|deleted|renamed).*"
color yellow start="# Changes.*" end="# Changed.*"
color cyan start="# Untracked.*" end="diff"
color cyan start="# Untracked.*" end="$$"
color brightred "^deleted file mode .*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "^(diff|index|---|\+\+\+).*"
@PowerKiKi
PowerKiKi / generate-wildcard-certificate.sh
Created December 4, 2015 07:31
Generate self-signed wildcard SSL certificate for development environment
#!/usr/bin/env bash
# print usage
DOMAIN=$1
if [ -z "$1" ]; then
echo "USAGE: $0 domain.lan"
echo ""
echo "This will generate a non-secure self-signed wildcard certificate for given domain."
echo "This should only be used in a development environment."
@PowerKiKi
PowerKiKi / gist:9571aea8fa8d6160955f
Created August 25, 2014 06:12
PHP array_map memory usage
<?php
// Memory benchmark related to http://stackoverflow.com/questions/11657835/how-to-get-a-one-dimensional-scalar-array-as-a-doctrine-dql-query-result
// Build an array of 50 MiB
$data = [];
for ($i = 0; $i < 1024; $i++) {
$data[] = ['id' => str_repeat(' ', 1024 * 50)]; // store 50kb more
}
@PowerKiKi
PowerKiKi / gist:2487758
Created April 25, 2012 07:29
SVN to GitHub mirrors
<?php
/**
* This script should be used with CRON to synchronise read-only mirror of SVN to Github.com.
* It will automatically create repositories on github.com
*
* REQUIREMENT: svn2git from https://github.com/nirvdrum/svn2git
*
* The configuration file should look similar to:
*
#!/usr/bin/ruby
=begin
If you have subversion repository with many externals, it may take a bit too long to update it, as updates happen one after another.
This bit of script updates each external in parallel, making it oh so much faster.
(note: if you add an external or change an external property in another way, you'll need to run the standard svn up once)
Last seen on http://codesnippets.joyent.com/posts/show/548
=end
@PowerKiKi
PowerKiKi / ubuntu_fresh_install_for_user.sh
Last active July 11, 2022 14:19
ubuntu fresh install
# apache+mariadb+php+misc
sudo apt-add-repository ppa:ondrej/php
sudo apt update
sudo apt install vim curl git git-gui gitk htop nginx nginx-extras mariadb-server zip graphicsmagick php-cli php-gd php-xml php-mysql php-sqlite3 php-mbstring php-curl php-imagick php-xml php-zip php-bcmath php-bz2 php-soap php-intl php-apcu php-pcov php-fpm
# wp-cli
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
function getDb()
{
require($_SERVER['DOCUMENT_ROOT'] . '/typo3conf/localconf.php');
$db = new DBMysql($typo_db_host, $typo_db_username, $typo_db_password);
$db->connect($typo_db);
return $db;
}
/**
Ext.ns("TYPO3.Extjsformsample.UserInterface");
TYPO3.Extjsformsample.UserInterface.MyForm = function() {
TYPO3.Extjsformsample.UserInterface.MyForm.superclass.constructor.call(this, {
id: 'myformid',
title: 'My test form',
defaultType: 'textfield',
items: [{
fieldLabel: 'Name',
name: 'name',