Skip to content

Instantly share code, notes, and snippets.

View thehelvetian's full-sized avatar

The Helvetian thehelvetian

View GitHub Profile
@thehelvetian
thehelvetian / addRowToSpreadsheet.php
Last active October 31, 2021 20:04
Add a new row to a spreadsheet using Google Sheets API v4
<?php
/**
* This is a proof of concept. In real life you would split up the various parts and allow for different cell value
* types. Also read Leviscowles1986's comment below:
* https://gist.github.com/thehelvetian/2e94d60b796735b167dfb1c7560049ae#gistcomment-1822986
*
* @param array $ary_values An array containing the cell values
* @return bool Request status
*/
function addRowToSpreadsheet($ary_values = array()) {
@thehelvetian
thehelvetian / export-cron.php
Last active October 2, 2023 07:02
WP Export
<?php
/**
* [$outPath description]
* @var string
*/
$outPath = 'xml/';
/**
* [$fileName description]
* @var string
@thehelvetian
thehelvetian / post-commit.sh
Created October 6, 2016 07:13
Envoyer-style Git post-commit deployment
#!/usr/bin/env bash
# Set up the PATH var
PATH="/home/[user]/bin":$PATH
export PATH
# Git directories
GIT_WORK_DIR="/home/[user]/public_html"
GIT_REPO_DIR="/home/[user]/repos/[laravel_app].git"
@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 / UserFileHelper.php
Created July 5, 2018 09:54
Calculates the user assets path based on the user ID
<?php
namespace TheHelvetian\Helpers;
use Carbon\Carbon;
/**
* Class UserFileHelper
* @package TheHelvetian\Helpers
*/
@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 \