Skip to content

Instantly share code, notes, and snippets.

View n4zim's full-sized avatar
⌨️
Coding...

'Nazim Lachter n4zim

⌨️
Coding...
View GitHub Profile
@n4zim
n4zim / random_nb_pictures.sql
Last active October 26, 2016 16:17
SQL - Ajouter une valeur du texte avec une valeur aléatoire les colonnes vides correspondantes
# Ajoute un avatar aux utilisateurs sans avatar avec un id entre 1 et 14
UPDATE `users`
SET `picture` = CONCAT('default/', CAST((RAND()*(14-1)+1) AS UNSIGNED), '.jpg')
WHERE `picture` IS NULL;
# Regénère les avatars avec un id entre 1 et 14
UPDATE `users`
SET `picture` = CONCAT('default/', CAST((RAND()*(14-1)+1) AS UNSIGNED), '.jpg')
WHERE `picture` LIKE '%default%';
@n4zim
n4zim / gd_text_center.php
Last active October 26, 2016 16:17
PHP - Crée une image avec PHP GD incluant une image de fond et du texte centré horizontalement
<?php
$image = imagecreatefromjpeg("bg.jpg");
$blackColor = imagecolorallocate($image, 0, 0, 0);
$RobotoLight = 'Roboto-Light-webfont.ttf';
$centerX = imagesx($image);
// Text: 'TEXT', Angle: '0', Y: '100'
$text1 = utf8_decode("TEXT");
$text1_size = 50;
<?php
$img = imagecreatefromjpeg('img.jpg');
$size = 250; // Size to display
$maxSize = (imagesx($img) >= imagesy($img)) ? imagesx($img) : imagesy($img);
if($size > $maxSize) $size = $maxSize;
// Ellipse
$imgEllipse = imagecreatetruecolor($size, $size);
imagefill($imgEllipse, 0, 0, imagecolorallocate($imgEllipse, 255, 255, 255));
<?php
ob_start();
imagejpeg($image);
$output = ob_get_clean();
ob_clean();
return "<img src='data:image/jpeg;base64,".base64_encode($output)."' />";
version: "3"
services:
database:
image: mariadb
container_name: mariadb-database
restart: unless-stopped
ports:
- 3306:3306
volumes:
@n4zim
n4zim / rancher_digitalocean.sh
Last active March 30, 2018 10:51
Rancher Scripts
#!/bin/sh
echo "# Getting scripts..."
wget -O /tmp/script_rancher.sh https://releases.rancher.com/install-docker/1.12.sh
wget -O /tmp/script_digitalocean.sh https://agent.digitalocean.com/install.sh
chmod +x /tmp/script_rancher.sh /tmp/script_digitalocean.sh
echo "# Rancher agent"
/tmp/script_rancher.sh
@n4zim
n4zim / .env
Last active April 17, 2018 17:33
CATTLE_PROMETHEUS_EXPORTER=true
#!/bin/sh
# Run this script with ROOT
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
rancher:
image: rancher/rancher:latest
container_name: rancher
restart: unless-stopped
command: --acme-domain rancher.example.com
ports:
- 80:80
- 443:443
volumes:
- ./data:/var/lib/rancher
@n4zim
n4zim / SLIM.md
Created January 29, 2019 12:15
Cheat Sheet

Update default keyboard layout

sudo nano /etc/default/keyboard

Examples :

  • XKBVARIANT=""
  • XKBVARIANT="bepo"