Skip to content

Instantly share code, notes, and snippets.

Victor Eliasson viirre

Block or report user

Report or block viirre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Logger.php
<?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:
View test_2_dry_refactor.php
<?php
class DoesAwesomeStuff {
protected $meta = [];
protected $metaExtractor;
public function __construct($metaExtractor)
{
$this->metaExtractor = $metaExtractor;
}
@viirre
viirre / test_1_testable.php
Last active Apr 10, 2018
Test #1 - make SomeService testable without actually making any https calls
View test_1_testable.php
<?php
class SomeService
{
public function callApi()
{
$apiClass = new ApiClass;
$result = $apiClass->call('fetch');
// Handle result
@viirre
viirre / index.html
Last active Apr 13, 2018
Splash index for adaptive shop sites during upgrade
View index.html
<!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 / synd_prod_db_to_stage.sh
Last active Apr 10, 2018
Sync prod Mysql database to stage
View synd_prod_db_to_stage.sh
#!/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")
@viirre
viirre / pre-push
Last active Apr 27, 2017
Pre-push git hook to avoid errors in prod
View pre-push
#!/bin/sh
function allTestsShouldPass(){
echo "Running tests..."
vendor/bin/phpunit
if [ $? -ne 0 ]; then
echo " -> ERROR. Tests did not pass, fix them!"
exit 1
fi
}
@viirre
viirre / CodeigniterValetDriver.php
Created May 26, 2016
Valet driver for the Codeigniter framework
View CodeigniterValetDriver.php
<?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 Sep 29, 2017
Bash scripts for fixing some common conf stuff on newly provisioned Forge servers
View conf_forge_server.sh
# 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
@viirre
viirre / install_sslmate_forge.md
Last active Sep 18, 2015
Install new certificate with SSLmate and Forge
View install_sslmate_forge.md

1. Install SSLmate on the server

sudo wget -P /etc/apt/sources.list.d https://sslmate.com/apt/ubuntu1404/sslmate.list
sudo wget -P /etc/apt/trusted.gpg.d https://sslmate.com/apt/ubuntu1404/sslmate.gpg
sudo apt-get update
sudo apt-get install sslmate

2. Buy the certificate

@viirre
viirre / nginx.conf
Created Sep 17, 2014
Basic nginx.conf for Ubuntu 12.04 64-bit, 2 CPUs, around 2 GB RAM
View nginx.conf
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user www-data www-data;
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
# offers the best performance. Don't set it higher than the number of CPU
# cores if changing this parameter.
You can’t perform that action at this time.