Skip to content

Instantly share code, notes, and snippets.

View vivianspencer's full-sized avatar

Vivian Spencer vivianspencer

View GitHub Profile
@waska14
waska14 / FileHelper.php
Last active May 22, 2024 04:04
Laravel: create UploadedFile object from base64 string (autoremove temp file)
<?php
namespace App\Helpers\File;
use Illuminate\Http\File;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
class FileHelper
{

Fix for FOUC :

At the top of your HTML:

<!doctype html>
<html>
<head>
    <style>html{visibility: hidden;opacity:0;}</style>
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active July 14, 2024 19:55
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@mgalang
mgalang / d8_snippets.md
Last active June 17, 2022 13:58
Drupal 8 snippets

Create link from text and url

$url = Url::fromRoute($route_name);
$link = Link::fromTextAndUrl($text, $url);

Create link from route

$link = Link::createFromRoute('Link Text', 'route_name')->getUrl();
@VovanZver
VovanZver / backup_droplet.php
Last active January 5, 2023 01:18
Backup droplet
<?php
class BackupDroplet
{
private $apiUrl = 'https://api.digitalocean.com/v2/';
private $token;
private $dropletId;
public function __construct($token, $dropletId)
{
@fevangelou
fevangelou / my.cnf
Last active July 14, 2024 17:45
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@vivianspencer
vivianspencer / server_hardening.md
Last active February 17, 2022 13:29
Debian 8 Hardening

Debian 8 Hardening

  1. Update root's mail recipient. Open /etc/aliases replacing administrator@example.tld with an administrator's email address. This is where logs will be emailed.

    root:     administrator@example.tld
    
  2. Update the the default umask to 027. Edit the file /etc/init.d/rc and change the following setting:

umask 027

@vivianspencer
vivianspencer / setup.md
Last active August 18, 2016 14:20
Debian 8 (Jessie) LEMP Setup

Debian 8 LEMP

  1. Set the hostname of the server

    hostnamectl set-hostname johnsmith
    
  2. Make the hostname resolvable. Open the file /etc/hosts in your favourite editor and assign the IPv4 & IPv6 records of the server to your chosen hostname & FQDN.

    127.0.0.1       localhost.localdomain   localhost
    
@dancameron
dancameron / functions.php
Last active September 13, 2019 09:03
Adding String Attachments (AddStringAttachment) with wp_mail (part 2)
<?php
add_action( 'phpmailer_init', '_add_string_attachments' );
function _add_string_attachments( $phpmailer ) {
// the previous attachment will fail since it's not an actual file
// we will use the error to attach it as a string
if ( '' !== $phpmailer->ErrorInfo ) {
// error info
$error_info = $phpmailer->ErrorInfo;

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name