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 / 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;
@Ravaelles
Ravaelles / export-all-mongodbs.sh
Last active March 10, 2023 14:00
Export all MongoDB databases to directories in "Y-m-d" date format using mongodump
#!/bin/bash
# Set the base directory where the new directory will be created
base_dir="/home/BACKUPS"
# Create a variable for the current date in Y-m-d format
current_date=$(date +%Y-%m-%d)
# Define an array to store the messages
declare -a messages
@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>\
@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.
@Ravaelles
Ravaelles / .generic
Last active September 20, 2020 10:59
Script dependency file used to create new nginx site config files based on the file name and project path
server {
listen 80;
listen 443 ssl http2;
server_name .PROJECT.local;
root "DIRPATH";
index index.html index.htm index.php;
charset utf-8;
@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 / newdomain.sh
Last active October 18, 2019 15:02
Script used to create new nginx site config files based on the file name and project path
# Ensure to get this file: https://tinyurl.com/genericlocal
# And that it's placed in: /etc/nginx/sites-enabled/generic.local
# Also make sure to have the certificate files! See generic.local at the end.
#
# Example usage: ./newdomain.sh cool /projects/MyProject
#
# After that you should be able to visit https://cool.local
cp /etc/nginx/sites-enabled/generic.local /etc/nginx/sites-enabled/$1.local
sed -i "s/PROJECT/$1/g" /etc/nginx/sites-enabled/$1.local

Keybase proof

I hereby claim:

  • I am ravaelles on github.
  • I am ravaelles (https://keybase.io/ravaelles) on keybase.
  • I have a public key ASAoe_F65zu8GJCNYbJC6xsw04OmYkFhhR4_Nt6xzAzIWwo

To claim this, I am signing this object:

@Ravaelles
Ravaelles / gist:1aa9275d6a38a00d9eef4b34efe280bd
Created August 8, 2018 16:40
Vue.js checkbox controlling div visibility
<html>
<head>
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
@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