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 September 26, 2024 21:11
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 September 29, 2024 08:31
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 November 14, 2024 18:42
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 September 2024 ~
#
#
# 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 [email protected] with an administrator's email address. This is where logs will be emailed.

    root:     [email protected]
    
  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
    
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active November 17, 2024 20:46
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@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;