Setting Up an SMTP Server That Passes Anti-Spam Filters

Today, email providers all have anti-spam filters. Some simply move the email to a “spam” folder, but others delete the email entirely. To counter this problem, sending servers must prove their legitimacy. Prerequisites: A Linux VPS with internet access A domain name Here, we will use a Debian 7 VPS and an OVH domain. Installing Postfix and mailutils Postfix will be our mail sending server. Installing Postfix sudo apt-get install postfix During installation, you are asked which type of configuration you want. Choose “Internet Site”, which is a basic configuration without redirecting to other servers. Then you are asked for the server’s domain name. ...

March 19, 2018 · 5 min · Flavien Jourdren

Translating a Laravel Website

This system allows changing the site language from a menu. It uses sessions to store the language when changed. Then a middleware modifies the language to the one stored in the session using Laravel’s “setLocale” feature and Blade’s translation system. Creating the Menu Display CSS: .flag { width: 21px; height: 14px; } HTML: <!-- locale translation --> <li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#"><img class="flag" src="{{ url('images/lang/'.Session::get('locale').'.png') }}" alt="{{ Session::get('locale') }}"/><b class="caret"></b></a> <ul class="dropdown-menu flagMenu"> <li><a href="{{ url('lang/en') }}"><img class="flag" src="{{ url('images/lang/en.png') }}" alt="en"/></a></li> <li><a href="{{ url('lang/fr') }}"><img class="flag" src="{{ url('images/lang/fr.png') }}" alt="fr"/></a></li> </ul> </li> Creating the Route That Stores the New Language in Session Route::get('/lang/{locale}', function ($locale) { Session::set('locale', $locale); if($_SERVER['HTTP_REFERER']) return redirect($_SERVER['HTTP_REFERER']); else return redirect('/'); }); Creating the Middleware Add this middleware to all routes from the Kernel.php file. ...

March 18, 2018 · 1 min · Flavien Jourdren

Git Commands Cheat Sheet

Git is a free versioning software; each project is a repository. This tool enables collaborative work on the same codebase. It is notably used by the open source platform GitHub. Vocabulary Repository A place where code versions are stored. Repositories can be compared to projects. Commit A version of the project at a given point in time. Push Sends one or more commits to a repository. Pull Downloads commits from a repository. Fork A fork allows anyone with access to a repository to clone it and make their own modifications. Tree Contains a commit, describes the source tree structure; a tree object points to multiple parent commits. Branch Since each commit knows its parents, it is possible to have two teams working on two different branches (the main branch is master). This allows creating two parallel versions of the project. The two branches can then be merged to combine everyone’s work. Example: a dev branch and a production branch (master). Once a commit on the dev branch is validated, the branches are merged and the main branch gets the new features. Merge The fusion of two branches. Stash A local storage space containing modifications that have not yet been committed. Useful for example when switching branches with pending changes. Rebase Allows rewriting part of the commit history. Cherry-pick Allows adding a commit to another branch without merging the entire branch. Essential Commands Initialize a git project git init List configuration globals git config --list Configure username git config --global user.name "your_name" Configure email git config --global user.email "[email protected]" Status of modified files git status First commit git add . git commit -m "initial commit" Subsequent commits git add path_to_my_file git commit -m "commit message" Amend the previous commit git commit --amend View commit history git log View commit history (one line) git log --oneline View branches as a graph git lg View differences from the last commit git diff Restore a file to a previous commit git checkout <commit> <file> Revert to a previous commit (adding modified files to staging) git reset <commit> Revert to a previous commit (removing files from staging) git reset <commit> --hard Create a reverse commit git revert <commit> Rebase a branch git checkout <commit> git rebase master Interactive rebase git rebase -i <commit> Interactive rebase works with a scripting system. When running the command, a new window opens where you can perform these actions on each commit: ...

March 17, 2018 · 4 min · Flavien Jourdren