Skip to content

Instantly share code, notes, and snippets.

View viirre's full-sized avatar

Victor Eliasson viirre

View GitHub Profile
@viirre
viirre / upgrade.php
Last active September 9, 2020 13:44
Upgrade Script Medialibrary v6 to v7
<?php
// Blogpost: XXX
// Assumes you have created a new column on your `media` table called `converted` (boolean default false)
// app/Console/Commands/UpgradeMediaCommand.php
namespace App\Console\Commands;
use App\Jobs\UpgradeS3MediaJob;
@viirre
viirre / webpack.mix.js
Last active April 20, 2020 22:24
Using different Tailwind config files (eg. one for admin and one for front) with Laravel Mix (TailwindCSS < 1.0)
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
require('laravel-mix-purgecss');
mix
.js('resources/js/admin/admin.js', 'public/js')
.js('resources/js/front/front.js', 'public/js')
// Admin
.sass(
@viirre
viirre / tests.yml
Created December 17, 2019 20:48
Workflow for CI/CD for a Laravel app with Mysql 5.7 (Adaptive media Atlantis default)
name: CI
on: [push]
jobs:
tests:
name: Run PHP tests
runs-on: ubuntu-latest
steps:
@viirre
viirre / index.html
Last active April 13, 2018 08:11
Splash index for adaptive shop sites during upgrade
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-language" content="sv">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Webbshop från Adaptive Shop</title>
<meta http-equiv="refresh" content="30">
<meta name="robots" content="noindex">
<style>
body {
@viirre
viirre / test_1_testable.php
Last active April 10, 2018 18:39
Test #1 - make SomeService testable without actually making any https calls
<?php
class SomeService
{
public function callApi()
{
$apiClass = new ApiClass;
$result = $apiClass->call('fetch');
// Handle result
@viirre
viirre / synd_prod_db_to_stage.sh
Last active April 10, 2018 18:33
Sync prod Mysql database to stage
#!/bin/bash
#1. Add ssh key (stage key) to PROD machine
# 1.1 On stage:
# cat ~/.ssh/id_rsa.pub
# 1.2 On prod
# nano ~/.ssh/authorized_keys
# * paste key*
DATE=$(date +"%Y-%m-%d")
<?php
/*
* We want to implement a logger
*
* We can have several loggers: 'bugsnag', 'sentry', 'file', 'database', 'redis'
*
* We want to be able to store which logger we use in our .env file
*
* Your job:
<?php
class DoesAwesomeStuff {
protected $meta = [];
protected $metaExtractor;
public function __construct($metaExtractor)
{
$this->metaExtractor = $metaExtractor;
}
@viirre
viirre / CodeigniterValetDriver.php
Created May 26, 2016 09:53
Valet driver for the Codeigniter framework
<?php
class CodeigniterValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@viirre
viirre / conf_forge_server.sh
Last active September 29, 2017 14:56
Bash scripts for fixing some common conf stuff on newly provisioned Forge servers
# Usage:
# wget -O forge_scripts.sh https://gist.githubusercontent.com/viirre/f857dc6482e40214fa573f85bbaf9b58/raw
# [Change script to your servers liking]
# sudo bash forge_scripts.sh
if [ "$EUID" -ne 0 ] ;
then echo "Please run as root" ;
exit 1;
fi