Skip to content

Instantly share code, notes, and snippets.

View NikolasMelui's full-sized avatar
💭
:octocat: So open Source!

nikolasmelui NikolasMelui

💭
:octocat: So open Source!
View GitHub Profile
@NikolasMelui
NikolasMelui / req.sql
Created April 17, 2018 13:14
SQL temp table create and drop
CREATE TEMPORARY TABLE `temp_table`
AS
SELECT `id` FROM `main_table`;
ALTER TABLE `temp_table` CHANGE `old_name` `new_name_1` int(10);
ALTER TABLE `temp_table` ADD `new_name_2` int(10);
INSERT INTO `temp_table` (`new_name_2`) VALUES (1);
INSERT INTO `main_table_2` SELECT * FROM `temp_table`;
DROP TEMPORARY TABLE `temp_table`;
@NikolasMelui
NikolasMelui / .gitattributes
Last active April 6, 2018 11:17
Exclude strings from files
*.ejs filter=gitignore
*.js filter=gitignore
@NikolasMelui
NikolasMelui / default.conf
Last active April 16, 2018 11:32
NGINX default config file for docker-multikey-modx-template
server {
listen 80 default_server;
root /var/www/html/public;
index index.html index.php;
client_max_body_size 100M;
charset utf-8;
location @modx-rewrite {
rewrite ^/(.*)$ /index.php?q=$1 last;
@NikolasMelui
NikolasMelui / Docker.sh
Created April 3, 2018 14:59
Docker commands
docker exec -it dockermultikeymodxtemplate_nginx_1 bash
docker exec -it dockermultikeymodxtemplate_nginx_1 nginx -s reload
@NikolasMelui
NikolasMelui / .htaccess
Last active April 1, 2018 17:35
Apache rules
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteBase /
RewriteCond %{HTTP:X-HTTPS} !1
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
@NikolasMelui
NikolasMelui / multi
Created March 30, 2018 07:06
Multi plugin for MODX multisite.
<?php
// Работаем только на фронтенде
if ($modx->event->name != 'OnHandleRequest' || $modx->context->key == 'mgr') {return;}
// Определяем запрашиваемый хост
$host = $_SERVER['HTTP_HOST'];
// Выбираем контекст с настройкой base_url
$q = $modx->newQuery('modContextSetting', array('key' => 'http_host', 'value' => $host));
$q->select('context_key');
docker volume create portainer_data
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
@NikolasMelui
NikolasMelui / pm2.config.js
Created February 21, 2018 10:14
PM2 config file
{"apps": [
{
"env": {
"interpreter_args": "--nouse-idle-notification —expose-gc"
},
"env_development": {
"NODE_ENV": "dev"
},
"env_production": {
"NODE_ENV": "prod",
-- Using MySQL with Cloud9 --
# start MySQL. Will create an empty database on first start
$ mysql-ctl start
# stop MySQL
$ mysql-ctl stop
# run the MySQL interactive shell
$ mysql-ctl cli
@NikolasMelui
NikolasMelui / mail.css
Last active March 28, 2018 18:14
Mail.php
.ajax-results
.success, .error
height: 0
opacity: 0
max-height: max-content
margin-top: 10px
overflow: hidden
transition: 0.3s
.active
margin-top: 20px