Skip to content

Instantly share code, notes, and snippets.

View eritislami's full-sized avatar

Erit Islami eritislami

View GitHub Profile
<?
# 1
foreach (glob(resource_path() . '/lang/*/*.php') as $file) {
preg_match('#^.*/([A-z]*)/([A-z]*).php$#', $file, $matches);
$trans[$matches[1]][$matches[2]] = require($file);
}
foreach ($trans as $lang => $translations) {
$fileContents = sprintf('var trans = %s;', json_encode($translations));
file_put_contents(public_path() . '/js/trans.' . $lang . '.js', $fileContents);
@eritislami
eritislami / setperms.sh
Last active January 27, 2023 18:21
Set permissions for laravel application on ubuntu/nginx
# Allow execution
# chmod +x ./setperms.sh
# Usage
# ./setperms.sh /var/www/domain.com
cd $1
sudo chown -R $USER:www-data .
sudo find . -type f -exec chmod 664 {} \;
sudo find . -type d -exec chmod 775 {} \;
@eritislami
eritislami / get_current_git_commit.php
Created July 13, 2021 13:29 — forked from stevegrunwell/get_current_git_commit.php
Get current git HEAD using PHP
<?php
/**
* Get the hash of the current git HEAD
* @param str $branch The git branch to check
* @return mixed Either the hash or a boolean false
*/
function get_current_git_commit( $branch='master' ) {
if ( $hash = file_get_contents( sprintf( '.git/refs/heads/%s', $branch ) ) ) {
return $hash;
} else {