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 / 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 / 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.
exiftool -P -d '%Y-%m-%d' \
'-filename<${FileModifyDate;}.%e' \
'-filename<${GPSDateTime;}.%e' \
'-filename<${MediaCreateDate;}.%e' \
'-filename<${ModifyDate;}.%e' \
'-filename<${DateTimeOriginal;}.%e' \
"$1"
@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(
version: 2
jobs:
php71:
docker:
- image: circleci/php:7.1
steps:
- checkout
- composer install
- run: phpunit
php72:
@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) {
@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 / 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 / list-of-domains-hosted-on-forge.js
Last active March 3, 2020 14:49
Quick and dirty hack to get a list of all domains hosted on Forge. Run it in your browser console. You still have to manually remove the server name strings.
let domains = Array.from($('.nav-item')[1].children[1].children);
let domainList = domains.map(function (item) {
return item.textContent.replace(/(\r\n|\n|\r)/gm, "").trim();
});
console.table(domainList);
@stefanzweifel
stefanzweifel / gist:67ee7d1d8942cc181b5019308910de38
Last active December 10, 2020 22:29
Paddle Ciphers for Laravel Forge
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';