Skip to content

Instantly share code, notes, and snippets.


Saeid Mohadjer smohadjer

View GitHub Profile


Run nodejs using Apache's reverseProxy on MacOS:

  1. Uncomment following lines in httpd.conf:
    #LoadModule proxy_module libexec/apache2/
    #LoadModule proxy_http_module libexec/apache2/
  2. Add required proxy settings to your httpd-vhosts.conf's VirtualHost:

Windows and Unix commands


Ctrl + Shift + S -> screenshot Shift + 6 -> ^

Mac Terminal --> Windows Git Bash (MINGW64) --> Purpose open . --> start . --> to open the current location in File Explorer


smohadjer / .htaccess
Last active May 3, 2020 — forked from man-oi/.htaccess
View .htaccess
AuthType Basic
AuthName "only for valid users"
AuthUserFile /full/path/.htpasswd
Require valid-user
// If you don't have ssh access to your site, put the following command in a php file and upload it to your server to find out the full path to .htpasswd:
<?php echo realpath('./') . PHP_EOL; ?>
// You can create a .htpasswd using terminal:
htpasswd -c .htpasswd username
smohadjer /
Last active Feb 18, 2021
PHP tips and tircks


Writng HTML inside a php if. The HTML will only be displayed if the condition is satisfied.

<?php if($condition) : ?>
    <a href="">This will only display if $condition is true</a>
<?php else : ?>
    even more html
<?php endif; ?>
smohadjer /
Last active Apr 22, 2020
Tips on using MariaDB

If after a Mac OS update MariaDB or MySQL stop working and you get this error on login:\

mysql: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted

It's because my.conf.d folder doesn't exist. This will fix it:
mkdir /usr/local/etc/my.cnf.d

smohadjer /
Last active Feb 21, 2020
Setting MariaDB time zone to UTC on macOS

Setting Time Zone of MariaDB to UTC

  1. If you are logged in then exit mariadb and stop it via: brew services stop mariadb
  2. To populate time zone tables: To load the time zone tables from the command line, pass the zoneinfo directory path name to mysql_tzinfo_to_sql and send the output into the mysql program. If your root user has no password drop -p from below command:
    mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
  3. Open my.cnf (/usr/local/etc) and add following lines to it:
smohadjer /
Last active Feb 18, 2021
Saeid's Yii2 Cookbook


To load a css file on a specific page add this to your view:


To display validation errors in a model: