Skip to content

Instantly share code, notes, and snippets.

View thecodeholic's full-sized avatar

TheCodeholic thecodeholic

View GitHub Profile
@thecodeholic
thecodeholic / php.json
Created February 26, 2024 19:29
PHP/Laravel Live snippets for VSCode
{
"Create public function": {
"prefix": "pubf",
"body": [
"public function $1()",
"{",
"\t$2",
"}",
],
"description": "Create public function"
@thecodeholic
thecodeholic / delete_git_branches.md
Created December 12, 2023 12:22
Delete Git branches locally that are deleted on remote
git fetch --prune && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs -r git branch -d

List all docker containers

docker ps -a

Delete all docker containers

docker rm $(docker ps -a -q)
@thecodeholic
thecodeholic / apache_vhost.conf
Created January 20, 2023 20:43
Sample Apache Virtual Host file
<VirtualHost *:80>
ServerName laravelexample.net
ServerAdmin webmaster@thedomain.com
DocumentRoot /var/www/laravelexample/public
<Directory /var/www/laravelexample>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
@thecodeholic
thecodeholic / fadeout-html-element.js
Last active May 20, 2022 09:05
Fade-out HTML element every day until it fully disappears
const el = document.querySelector('[style*=waska]')
const parent = el.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
const futureDate = new Date('2022-06-28 12:00:00')
const startDate = new Date('2022-05-19');
const interval = setInterval(() => {
const nowDate = Date.now();
const percent = Math.round((futureDate.getTime() - nowDate) * 100 / (futureDate.getTime() - startDate.getTime()) * 100) / 100
console.log(percent)
if (percent <= 5) {
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE database_name DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL PRIVILEGES on database_name.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
@thecodeholic
thecodeholic / readme.md
Last active September 23, 2018 16:30
JS prototype modification on Natives
Object.prototype.numberKeys = function(){
  // ...
};

Array.prototype.minElement = function(){
  // ...
};
@thecodeholic
thecodeholic / README.md
Created September 4, 2018 06:50
Git commands

Sort branches by creator date

To make virtual hosts running using php-fpm for different users

  • apt-get install libapache2-mod-ruid2
  • a2enmod mpm_prefork
  • service apache2 restart
  • service php7.0-fpm restart
  • cp /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.0/fpm/pool.d/{YOUR_DOMAIN_NAME}.conf
  • vim /etc/php/7.0/fpm/pool.d/{YOUR_DOMAIN_NAME}.conf and change the parameters