Skip to content

Instantly share code, notes, and snippets.

@anwas
anwas / sitesetup.sh
Created July 15, 2021 02:19 — forked from haydar/sitesetup.sh
Bash script to automatically provision LAMP sites
#!/bin/bash
# Bash script to set up local site using LAMP on Ubuntu
# Requires Apache2, MySQL, mkcert (https://github.com/FiloSottile/mkcert)
# See also sitedrop.sh https://gist.github.com/jonattanbossenger/4950e107b0004a8ee82aae8b123cce58
# This version improved by @haydar on github
if [[ $EUID -ne 0 ]];
then
@anwas
anwas / functions.php
Created October 27, 2020 07:48 — forked from justlevine/functions.php
cpt_unique_slug_by_tax.php
<?php
add_filter( 'wp_unique_post_slug', 'cpt_unique_slug_by_tax', 10, 6 );
function cpt_unique_slug_by_tax( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
if ( 'guide' === $post_type ) {
global $wpdb;
$post_tax = get_the_terms( $post_ID, 'guide_cat' );
// Check if another CPT exists in the same taxonomy with the same name.
@anwas
anwas / linux-screen-commands.txt
Created February 12, 2020 17:09
Linux Screen komandos #workflow #ubuntu #cli #howto
Starting Named Session
Named sessions are useful when you run multiple screen sessions. To create a named session, run the screen command with the following arguments:
screen -S session_name
It’s always a good idea to choose a descriptive session name.
Working with Linux Screen Windows
When you start a new screen session, it creates a single window with a shell in it.
@anwas
anwas / package.json
Last active December 22, 2018 04:40
[Webpack workflow]
{
"name": "webpack-dev",
"version": "1.0.0",
"description": "Webpack development workflow with laravel-mix",
"main": "index.js",
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
@anwas
anwas / bcp.sh
Last active October 13, 2022 20:05
Linux command line – CLI #chmod #archive #compress #delete #backup
#!/bin/bash
#
# Резервное копирование каталогов и файлов из домашнего каталога
# Этот командный скрипт можно автоматически запускать при помощи cron
#
DATE=`date +%F` # This Command will add date in Backup File Name.
TIME=`date +%H-%M-%S` # This Command will add time in Backup File Name.
COMPNAME=EB
DESDIR=/home/anwas/clouds/nextCloud-eb/personal-share/backups_srv # Destination of backup file.
@anwas
anwas / GIT aliases
Last active February 9, 2023 18:50
[GIT install, config and snippets] #git #snippets #alias
git init
git add .
git commit -a -m "Initial commit"
git tag -a 1.0.0
git tag -n
git checkout -b develop master
git checkout -b feature-clean-footer develop
git checkout develop
@anwas
anwas / ubuntu-snap-commands.txt
Last active January 17, 2021 17:38
[Ubuntu SNAP commands] #ubuntu #cli #apps #snap
## https://utappia.org/2016/04/22/how-to-search-install-remove-snap-packages-in-ubuntu/
## https://docs.snapcraft.io/core/usage
## https://www.youtube.com/watch?v=5F-1cuBfSm0
sudo snap find : To list the available packages
sudo snap install <package name>: To install a package
sudo snap list: To view all the installed snap packages
sudo snap changes: To view a list of logged actions
sudo snap refresh <package name>: To upgrade a package to its latest available version
@anwas
anwas / change-ubuntu-password.txt
Created July 30, 2018 05:34
[Change Ubuntu password in recovery mode] #ubuntu #password #recovery
From the boot menu, select recovery mode, which is usually the second boot option.
The root account is the ultimate administrator and can do anything to the Ubuntu installation (including erase it), so please be careful with what commands you enter in the root terminal.
In recent versions of Ubuntu, the filesystem is mounted as read-only, so you need to enter the follow command to get it to remount as read-write, which will allow you to make changes:
mount -o rw,remount
If you have forgotten your username as well, type
ls /home
@anwas
anwas / aria-tags.txt
Created June 6, 2018 07:56
[ARIA tags] #aria #accessibility
## https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA
aria-hidden="true"
@anwas
anwas / multiple-php.txt
Last active December 14, 2023 11:03
[Multiple PHP versions on Ubuntu] #php #dev #ispconfig
## Add repository
### https://launchpad.net/%7Eondrej/+archive/ubuntu/php
### https://launchpad.net/~ondrej/+archive/ubuntu/apache2
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get update
sudo apt-get dist-upgrade