Skip to content

Instantly share code, notes, and snippets.

View thehelvetian's full-sized avatar

The Helvetian thehelvetian

View GitHub Profile
@thehelvetian
thehelvetian / embedded-file-viewer.md
Created November 1, 2017 03:45 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@thehelvetian
thehelvetian / massInsertOrUpdate.php
Created June 22, 2018 02:38 — forked from RuGa/massInsertOrUpdate.php
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@thehelvetian
thehelvetian / CreatesWithLock.php
Created June 22, 2018 02:38 — forked from troatie/CreatesWithLock.php
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@thehelvetian
thehelvetian / CreateProductJob.php
Created June 22, 2018 02:39 — forked from mattdfloyd/CreateProductJob.php
Laravel's firstOrCreate race conditions
<?php
namespace App\Jobs;
use App\Product;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Redis;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
@thehelvetian
thehelvetian / .gitlab-ci.yml
Created July 9, 2018 03:54 — forked from chalcedonyt/.gitlab-ci.yml
Sample gitlab-ci for laravel
# This file is a template, and might need editing before it works on your project.
# Select image from https://hub.docker.com/_/php/
stages:
- build_npm
- build_and_test
# Select what we should cache between builds
cache:
paths:
- vendor/
@thehelvetian
thehelvetian / Dockerfile
Created January 1, 2019 05:56 — forked from li0nel/Dockerfile
Laravel reference Dockerfile
FROM php:7.1-fpm
# Update packages and install composer and PHP dependencies.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
postgresql-client \
libpq-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
@thehelvetian
thehelvetian / Dockerfile-nginx
Created January 1, 2019 05:56 — forked from li0nel/Dockerfile-nginx
Dockerfile for Nginx
FROM nginx
ADD deploy/nginx/nginx.conf /etc/nginx/
ADD deploy/nginx/default.conf /etc/nginx/conf.d/
ADD public /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
@thehelvetian
thehelvetian / dockerbuild.sh
Created January 1, 2019 05:56 — forked from li0nel/dockerbuild.sh
Build and push your Laravel images
# Building our Nginx Docker image and tagging it with the ECR URL
docker build -f Dockerfile-nginx -t YOUR_ECR_REGISTRY_URL_HERE:nginx .
docker push YOUR_ECR_REGISTRY_URL_HERE:nginx
# Building our Laravel Docker image and tagging it with the ECR URL
docker build -t YOUR_ECR_REGISTRY_URL_HERE:laravel .
docker push YOUR_ECR_REGISTRY_URL_HERE:laravel
@thehelvetian
thehelvetian / bastion.sh
Created January 1, 2019 05:57 — forked from li0nel/bastion.sh
Create a bastion to access your instances in private subnets
aws ec2 run-instances
--image-id ami-c1a6bda2
--key-name laravelaws # the SSH key pair we created earlier
--security-group-ids sg-xxxxxxxx # our previous SG allowing access to the DB
--subnet-id subnet-xxxxxxxx # one of our public subnets
--count 1
--instance-type t2.micro # the smallest instance type allowed
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=bastion}]'
@thehelvetian
thehelvetian / bastion.sh
Created January 1, 2019 06:00 — forked from li0nel/bastion.sh
Connect to ECS instances in private subnets through a bastion
# Add your key to your SSH agent
ssh-add -K laravelaws.pem
# Verify that your private key is successfully loaded in your local SSH agent
ssh-add –L
# Use the -A option to enable forwarding of the authentication agent connection
ssh –A ec2-user@<bastion-public-IP-address>
# Once you are connected to the bastion, you can SSH into a private subnet instance