Skip to content

Instantly share code, notes, and snippets.

View elkebirmed's full-sized avatar
🙂

Mohamed Elkebir elkebirmed

🙂
View GitHub Profile
sAVqdNCosKdBrydeSvmsyRjdIh4wePxqNFiF7IUVCm8htJAnnrf17EQNqBDA6u1+YAQv/YK1Sk2
dNAESDBzmXGSE+7Ea7IWvvBNVZguivN7l3lsPC9684SRzBSSNlzg/SLPf0kE2ZSu1Rw5kkgOzra
mKk4O7aASh4XJB4kB7oKEfjHFCBJ5S0T0cI9yqCMGAzWpxl5jHp4zVeX4rUCkfBh43sdlQlghyy
sE4uT15OXVMkBpv4wZLyTIGOjAvjUiOKgmTLsglMQ7fg2Lgf90tbMGWw2KKBXiGg25aoVHhU6R6
Gdk9CeqiLgp1WWEBzBb9qrkHKIbBJJBfpulRSV1fHQ==
@elkebirmed
elkebirmed / Laravel-Container.md
Created August 17, 2020 15:41
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

<?php
Localizater::group(function () {
Route::view('/', 'welcome');
Route::get('/foo', 'Controller@action');
});
Route::delete('foo', 'Controller@action');
Route::post('login', 'Controller@action');
// Result of locales are (en, fr)
example.com
example.com/fr
example.com/ar
<?php
Route::group(['prefix' => '{lang}'], function () {
// ...
});
server {
listen 80;
listen [::]:80;
server_name server.douaoui.com;
root /var/www/roundcube/;
index index.php index.html index.htm;
error_log /var/log/nginx/roundcube.error;
access_log /var/log/nginx/roundcube.access;
@elkebirmed
elkebirmed / A Nuxt.js VPS production deployment.md
Created October 11, 2019 13:37 — forked from DreaMinder/A Nuxt.js VPS production deployment.md
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger than a landing page.

UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.site.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
@elkebirmed
elkebirmed / longPolling.js
Created March 18, 2017 13:22 — forked from jasdeepkhalsa/longPolling.js
Simple Long Polling Example with JavaScript and jQuery by Tian Davis (@tiandavis) from Techoctave.com (http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery)
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast)
(function poll(){
$.ajax({ url: "server", success: function(data){
//Update your dashboard gauge
salesGauge.setValue(data.value);
}, dataType: "json", complete: poll, timeout: 30000 });
})();
<!-- In normal page -->
<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html">
<link rel="canonical" href="https://www.example.com/url/to/full/document.html">
<!-- In AMP page -->
<link rel="canonical" href="https://www.example.com/url/to/full/document.html">