Skip to content

Instantly share code, notes, and snippets.

View Ravaelles's full-sized avatar
🏠
Working remotely

Ravaelles

🏠
Working remotely
  • Fullstack Laravel developer
  • Poland
View GitHub Profile
@Ravaelles
Ravaelles / pleaseWait.js
Last active September 27, 2022 05:54
Very easy javascript code to display page "Please wait" using bootstrap modal with nice progress bar.
/**
* Displays overlay with "Please wait" text. Based on bootstrap modal. Contains animated progress bar.
*/
function showPleaseWait() {
if (document.querySelector("#pleaseWaitDialog") == null) {
var modalLoading = '<div class="modal" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false" role="dialog">\
<div class="modal-dialog">\
<div class="modal-content">\
<div class="modal-header">\
<h4 class="modal-title">Please wait...</h4>\
server {
listen 80 default_server;
listen [::]:80 default_server;
# Default route for Laravel projects
root /var/www/html/public;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php;
private static Unit getMineralFieldToGather(Unit worker) {
// Get nearest base for this unit
Unit base = Select.ourBases().nearestTo(worker.getPosition());
if (base == null) {
return null;
}
// Get minerals near to our main base and sort them from closest to most distant one
List<Unit> minerals = (List<Unit>) Select.minerals().inRadius(12, base.getPosition()).listUnits();
@Ravaelles
Ravaelles / Ubuntu server setup script (PHP 5.6)
Last active April 6, 2020 12:13
PHP 5.6 + nginx + MongoDB driver for PHP
#!/bin/bash
######################################################
### README ###########################################
######################################################
###
### One-line server install script for Ubuntu.
### Installs Nginx + PHP5.6 + MongoDB for PHP driver.
###
### Removes previous Apache, PHP, nginx installations.
@Ravaelles
Ravaelles / Laravel Homestead + MongoDB PHP 7.1 driver
Last active July 4, 2018 13:51
Laravel Homestead + MongoDB PHP 7.1 driver installer
#!/bin/bash
######################################################
### README ###########################################
######################################################
###
### One-line Laravel Homestead MongoDB driver PHP installer.
###
### What it does:
### - installs some MongoDB PHP driver dependencies
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
@Ravaelles
Ravaelles / Ubuntu server setup script (PHP 7.1)
Last active October 19, 2021 20:03
PHP 7.1 + nginx + MongoDB driver for PHP
#!/bin/bash
######################################################
### README ###########################################
######################################################
###
### One-line server install script for Ubuntu.
### Installs Nginx + PHP7.1 + MongoDB for PHP driver.
###
### Removes previous Apache, PHP, nginx installations.
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
user=ubuntu
numprocs=10
redirect_stderr=true
stdout_logfile=/var/www/html/worker.log
@Ravaelles
Ravaelles / gist:3878d82117d2881c03ee02e036cc67cb
Created March 6, 2018 17:22
Password recovery fix for Laravel 5.5 with Jenssegers MongoDB package
<?php
namespace Jenssegers\Mongodb\Auth;
use DateTime;
use DateTimeZone;
use Illuminate\Auth\Passwords\DatabaseTokenRepository as BaseDatabaseTokenRepository;
use MongoDB\BSON\UTCDateTime;
class DatabaseTokenRepository extends BaseDatabaseTokenRepository {
@Ravaelles
Ravaelles / numberToColor
Created April 16, 2018 09:51
PHP function that converts number from given range into a color from given gradient of multiple colors
// See example: https://image.prntscr.com/image/cTIv8JkLR7yWEQxVev9SyA.jpeg
function numberToColor($value, $min, $max, $gradientColors = null)
{
// Ensure value is in range
if ($value < $min) {
$value = $min;
}
if ($value > $max) {
$value = $max;