Skip to content

Instantly share code, notes, and snippets.

@gilbitron
gilbitron / CaddyController.php
Created June 16, 2021 10:55
Enabling HTTPS (SSL) for Laravel Sail using Caddy
<?php
# app/Http/Controllers/CaddyController.php
namespace App\Http\Controllers;
use App\Store;
use Illuminate\Http\Request;
class CaddyController extends Controller
{
@r0lodex
r0lodex / localssl.md
Last active June 5, 2024 23:16
Setting Up Local SSL

Automatic

Updated 24-05-2020

NAME=$1

mkdir $NAME
cd $NAME

# Generate private key
@npearce
npearce / install-docker.md
Last active November 11, 2024 13:09
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@JohnnyWalkerDigital
JohnnyWalkerDigital / laravel-password-reset.md
Last active August 31, 2021 07:21
Laravel: Fix password reset (User email not sent)

Here's how to overcome this common gotcha: The default password reset system not working out of the box with Laravel 5.x (as you're not sent the user's password), without having to alter altering vendor/core. Here's how to make it work as you'd expect it to without changing any vendor files.

1. Create own notification

Firstly create a new notification for your app:

php artisan make:notification ResetPassword

Then open the newly created file: app\Notifications\ResetPassword.php and make the following changes:

@li0nel
li0nel / codepipeline.yml
Created February 5, 2018 13:49
CodePipeline
---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
RepositoryBranch:
Type: String
Default: master
Cluster:
@gaga5lala
gaga5lala / restore_docker_image_tag.sh
Created November 7, 2017 02:04
Restore docker image tag from text file.
# 1. Backup image tags to text file.
# $ docker images --format "{{.Repository}}:{{.Tag}} {{.ID}}" > img_id.txt
#
# 2. Execute clean-docker-for-mac script
# $ bash clean-docker-for-mac.sh $(docker images --format "{{.ID}}" | xargs)
#
# source: https://gist.github.com/MrTrustor/e690ba75cefe844086f5e7da909b35ce#file-clean-docker-for-mac-sh
#
# 3. Execute this script to restore tags from text file.
@rcanepa
rcanepa / routes.js
Last active March 2, 2023 08:29
Private routes with React Router v4
function PrivateRoute ({component: Component, authenticated, ...rest}) {
return (
<Route
{...rest}
render={(props) => authenticated === true
? <Component {...props} />
: <Redirect to={{pathname: '/login', state: {from: props.location}}} />}
/>
)
}
@aggiedinger
aggiedinger / LeadPages Smooth Scroll
Last active July 6, 2022 08:26
To add a smooth scroll for anchor links
<!-- Smooth Scroll -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
// Add smooth scrolling to all links
$("a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "learn") {
// Prevent default anchor click behavior
@chuckreynolds
chuckreynolds / extend-wordpress-user-session.php
Created July 13, 2016 11:16
This will extend the user login session auth cookie (session_tokens row in wp_usermeta) when the user is an Administrator and checks the Remember Me checkbox on login. Needed this for admins only, and all posts out there I found only did it for all users, and current_user_can didn't work so used user_can with ID.
<?php
/**
* Extend expiration length of the auth cookie for Administrators when hey check Remember Me
*
* @param int $expiration Cookie expiration passed by auth_cookie_expiration() hook
* @return int 90 days in seconds
*/
function chuck_extend_admins_login_session( $expiration, $user_id, $remember ) {
if ( $remember && user_can( $user_id, 'manage_options' ) ) {
@jehaby
jehaby / README.md
Last active October 8, 2024 17:23 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \