Skip to content

Instantly share code, notes, and snippets.

View stefanzweifel's full-sized avatar
🎯
Focusing

Stefan Zweifel stefanzweifel

🎯
Focusing
View GitHub Profile
@stefanzweifel
stefanzweifel / format_php.yml
Last active September 29, 2021 08:29
GitHub Actions Workflows to run prettier and php-cs-fixer automatically
name: Format PHP
on:
pull_request:
paths:
- '*.php'
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
@stefanzweifel
stefanzweifel / push.yml
Last active August 27, 2019 19:57
Example Configuration to run phpunit for a Laravel App on GitHub Actions
on: push
name: Run phpunit testsuite
jobs:
phpunit:
runs-on: ubuntu-latest
# container:
# image: lorisleiva/laravel-docker:7.3
steps:
- uses: actions/checkout@v1
@stefanzweifel
stefanzweifel / number-of-routes.php
Created March 4, 2019 08:05
Calculate the number of routes in a Laravel Project
<?php
return collect(Route::getRoutes())
->reject(function ($item) {
return starts_with($item->uri, 'horizon');
})
->reject(function ($item) {
return starts_with($item->uri, 'nova');
})
->reject(function ($item) {
version: 2
jobs:
php71:
docker:
- image: circleci/php:7.1
steps:
- checkout
- composer install
- run: phpunit
php72:
@stefanzweifel
stefanzweifel / assertHasNotNullRecordForColumn.php
Last active July 11, 2018 18:43
Custom Laravel Assertion when you often have to assert against timestamps. Just add it to your `Tests/Testcase.php`
<?php
public function assertHasNotNullRecordForColumn($table, $column, $data = [])
{
$result = \Illuminate\Support\Facades\DB::table($table)
->whereNotNull($column)
->where($data)
->count() > 0;
$message = sprintf(
exiftool -P -d '%Y-%m-%d' \
'-filename<${FileModifyDate;}.%e' \
'-filename<${GPSDateTime;}.%e' \
'-filename<${MediaCreateDate;}.%e' \
'-filename<${ModifyDate;}.%e' \
'-filename<${DateTimeOriginal;}.%e' \
"$1"
@stefanzweifel
stefanzweifel / DisableUpdatedAt.php
Last active July 29, 2017 14:18
A PHP Trait for Laravel Applications to disable the `updated_at` attribute on Models. It should be used if you only have a `created_at` column but not a `updated_at` column. https://stefanzweifel.io/posts/disableupdatedat-trait-for-laravel-5-4
<?php
namespace App\Traits;
/**
* This Trait disabled the updated_at value for a model.
* Laravel doesn't provide an easy way to to this.
* The framework **alyways** tries to append the updated_at column
* when the `$timestamps` property is not set to false.
* See code here: https://github.com/illuminate/database/blob/5.4/Eloquent/Builder.php#L757-L760.
@stefanzweifel
stefanzweifel / Disclosure.js
Created July 2, 2015 19:20
BASSCSS Dropdown script
var Disclosure = function(el, options) {
el.isActive = false;
el.details = el.querySelectorAll('[data-details]');
el.hide = function() {
for (var i = 0; i < el.details.length; i++) {
el.details[i].style.display = 'none';
}
};
el.show = function() {
for (var i = 0; i < el.details.length; i++) {
@stefanzweifel
stefanzweifel / index.php
Last active April 3, 2020 07:07
Screeenly API Example
<?php
$payload = array(
'key' => 'YOUR-API-KEY',
'url' => 'https://www.youtube.com/'
'height' => 800, // Optional
'width' => 500 // Optional
);
$payload = json_encode($payload);
@stefanzweifel
stefanzweifel / keybase.md
Created October 2, 2014 19:39
keybase proof

Keybase proof

I hereby claim:

  • I am stefanzweifel on github.
  • I am stefanzweifel (https://keybase.io/stefanzweifel) on keybase.
  • I have a public key whose fingerprint is EC86 B9C2 9050 F5EE ED2D E436 6938 B063 A922 A13E

To claim this, I am signing this object: