Skip to content

Instantly share code, notes, and snippets.

View azimidev's full-sized avatar
:octocat:
Pro

Azimi azimidev

:octocat:
Pro
View GitHub Profile
@azimidev
azimidev / forge.sh
Created August 9, 2018 00:05
Laravel Forge Setup Script
#
# REQUIRES:
# - server (the forge server instance)
# - event (the forge event instance)
# - sudo_password (random password for sudo)
# - db_password (random password for database user)
# - callback (the callback URL)
#
@azimidev
azimidev / .htaccess
Last active August 19, 2023 05:53
The Best .htaccess with browser caching and gzip
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
@azimidev
azimidev / disposable_email_addresses
Last active December 22, 2022 06:51
Notify me of any update
0815.ru
0815.ru0clickemail.com
0815.ry
0815.su
0845.ru
0clickemail.com
0-mail.com
0wnd.net
0wnd.org
10mail.com
@azimidev
azimidev / _Laravel_Queue_Supervisor_Instruction.md
Last active November 15, 2022 14:42 — forked from danharper/a.md
Laravel Queue Supervisor

Install Supervisor with sudo apt-get install supervisor in Unix or brew install supervisor in Mac OSX. Ensure it's started with sudo service supervisor restart in Unix or brew services start supervisor in Mac OSX.

In Unix in /etc/supervisord/conf.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

In Mac OSX first run supervisord -c /usr/local/etc/supervisord.ini and in /usr/local/etc/supervisor.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

This file points at /usr/local/bin/run_queue.sh, so create that file there. Give this execute permissions, too: chmod +x run_queue.sh.

Now update Supervisor with: sudo supervisorctl reread in Unix and with: brew services restart supervisor in MAc OSX . And start using those changes with: sudo supervisorctl update.

$response = Http::attach(
'image',
$imageFileContents,
'photo.jpg'
)->post('http://192.168.0.203:80/v1/vision/detection');
@azimidev
azimidev / calculate_profile_percentage.php
Last active July 11, 2022 01:51
Calculates how much percentage of a profile is completed. It stripes off timestamps like created_at updated_at and primary keys like ids. Usually beneficial when using Laravel
<?php
/**
* Calculate how much a profile is completed
*
* @param $profile
* @return float|int
*/
function calculate_profile($profile)
{
if ( ! $profile) {
@azimidev
azimidev / CleanObject.js
Created October 15, 2021 12:41
CleanObject
/**
* Goes deep recursive through JSON object,
* if the children is only object and has less than 50 children {node},
* adds it to the new result otherwise return the child.
*
* @param obj
* @param node 50
* @returns {{}|*}
*/
function cleanObject(obj, node = 50) {
@azimidev
azimidev / Laravel_Custom_Paginate.php
Last active August 9, 2021 18:22
Laravel Custom Paginate
<?php
/**
* @param $items
* @param $perPage
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
function custom_paginate($items, $perPage)
{
$pageStart = request('page', 1);
$offSet = ($pageStart * $perPage) - $perPage;
@azimidev
azimidev / find_and_replace.md
Last active June 2, 2021 21:16
FInd and replace Unix
  1. Replacing all occurrences of one string with another in all files in the current directory: These are for cases where you know that the directory contains only regular files and that you want to process all non-hidden files. If that is not the case, use the approaches in 2.

All sed solutions in this answer assume GNU sed. If using FreeBSD or OS/X, replace -i with -i ''. Also note that the use of the -i switch with any version of sed has certain filesystem security implications and is inadvisable in any script which you plan to distribute in any way.

Non recursive, files in this directory only:

sed -i -- 's/old/new/g' *
perl -i -pe 's/old/new/g' ./* 
@azimidev
azimidev / NewObjectValueUpdated.js
Created November 17, 2020 15:16
This lodash function will find the key value in any object and it will add/update [title] key/value
_.set(_.find(events, { id: 1 }), 'title', 'New title');