Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View einnar82's full-sized avatar
🎯
Doing nice things.

Rannie Ollit einnar82

🎯
Doing nice things.
View GitHub Profile
@einnar82
einnar82 / ActivityLogController.php
Last active July 7, 2021 02:46
Pipeline Pattern in Laravel (Queries)
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Models\ActivityLog;
use App\QueryFilters\FilterByUser;
use Illuminate\Http\Request;
use Illuminate\Pipeline\Pipeline;
const axios = require('axios').default;
axios.interceptors.request.use(x => {
const headers = {
...x.headers.common,
...x.headers[x.method],
...x.headers
};
@einnar82
einnar82 / startup.sh
Created May 13, 2021 05:58
Get certificate authorities installed in Ubuntu Machine
awk -v cmd='openssl x509 -noout -subject' '
/BEGIN/{close(cmd)};{print | cmd}' < /etc/ssl/certs/ca-certificates.crt
@einnar82
einnar82 / sqlsrv-php7.2.sh
Created May 10, 2021 06:33 — forked from LegitDongo/sqlsrv-php.sh
SQLSRV PHP 7.2 Drivers that work for Laravel Homestead
# Best if added to `after.sh` so that this gets run every time the box is provisioned
# composer won't be able to download updates with an active proxy, and will hang trying to get the newest file
# You may want to comment this out based on your network configuration
sudo bash -c 'echo "export NO_PROXY=*" >> ~/.profile'
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.2-dev php7.2-xml mcrypt php-pear php-mbstring unixodbc unixodbc-dev -y --allow-unauthenticated
@einnar82
einnar82 / startup.sh
Created May 10, 2021 02:39
Install lower version PHP
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
@einnar82
einnar82 / docker-compose.yml
Last active July 21, 2021 05:57
Kong DB Less config
version: "3.7"
services:
kong:
image: kong:latest
volumes:
- ./kong.yml:/usr/local/kong/declarative/kong.yml
environment:
- KONG_DATABASE=off
- KONG_DECLARATIVE_CONFIG=/usr/local/kong/declarative/kong.yml
- KONG_PROXY_ACCESS_LOG=/dev/stdout
@einnar82
einnar82 / .gitlab-ci.yml
Last active April 15, 2021 08:37
Dockerized Stateless Laravel Application in Cloud Run
image: docker:latest
stages:
- deploy
deploy:
stage: deploy
image: google/cloud-sdk
services:
- docker:dind
@einnar82
einnar82 / Cipher.php
Last active March 29, 2021 23:23
AES-256-CBC Encryption and Decryption in PHP
<?php
namespace App\Encryptions;
class Cipher
{
private $cipherKey;
const AES_METHOD = 'AES-256-CBC';
@einnar82
einnar82 / laravel-nginx-config-make-http-exception-url-and-make-all-others-https.md Laravel nginx config to redirect all requests to https and an exception URL that can still be accessible via http

Pre-condition

One day in your Laravel app, you were required to redirect all http requests to https but need to make a certain URL route accessible via http for a certain reason; perhaps a portion of your javascript code needs to redirect to http URL but it can't because redirection to secure URL to insecure is prohibited. Therefore, in cases like this, you need to just allow just one URL to make an http connection.

NOTE: There are obvious security implications here so don't just follow this blindly and understand if this is really the solution you're looking for. The nginx config can somehow be improved, I just don't have the time yet. It sure do look redundant.

Understanding and examples

  • Redirect everything from http to https
@einnar82
einnar82 / package.json
Last active January 3, 2021 23:32
Freecodecamp Microservices Exam
{
"author": "Rannie Ollit",
}