Skip to content

Instantly share code, notes, and snippets.

@stevepop
stevepop / nginx-stat-failed-13-permission-denied.md
Created November 26, 2022 23:01 — forked from windsting/nginx-stat-failed-13-permission-denied.md
fix: Nginx: stat() failed (13: permission denied)

Nginx: stat() failed (13: permission denied)

from https://stackoverflow.com/questions/25774999/nginx-stat-failed-13-permission-denied

Nginx operates within the directory, so if you can't cd to that directory from the nginx user then it will fail (as does the stat command in your log). Make sure the www-user can cd all the way to the /username/test/static. You can confirm that the stat will fail or succeed by running

sudo -u www-data stat /username/test/static
@stevepop
stevepop / MedicationController
Created February 1, 2021 15:36
Endpoint to update the quantity
<?php
Class MedicationController extends Controller {
public function update(MedicationInventoryRequest $request)
{
$validated = $request->validated();
$this->updateInventory($validated);
return redirect()->back(303)
->with('message', 'Medication quantity added successfully');
}
updateQuantity(updateAction) {
this.sending = true
this.form.action = updateAction
this.$inertia.put(this.route('medication-inventories.update', {
'medication_inventory': this.medication.id
}), this.form, {
onSuccess: () => {
this.form.action === 'add' ? this.modalShowing = false: this.destroyModalShowing = false
this.sending = false
},
<?php
namespace App\Providers;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\UrlWindow;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Request;
@stevepop
stevepop / php-pools.md
Created July 13, 2020 17:17 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
// post-index page
<div>
<livewire:post-create>
@foreach($posts as $post)
<livewire:post-single :post="$post" :key="$post->id">
@endforeach
</div>
// PostIndex.php
@stevepop
stevepop / redis_keys_clear_pattern_matching.lua
Created December 17, 2019 23:11 — forked from ddre54/redis_keys_clear_pattern_matching.lua
Remove all the keys from redis matching a pattern
--Starting with redis 2.6.0, you can run lua scripts
EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 prefix:*
--For big number of keys
EVAL "local keys = redis.call('keys', ARGV[1]) \n for i=1,#keys,5000 do \n redis.call('del', unpack(keys, i, math.min(i+4999, #keys))) \n end \n return keys" 0 prefix:*
Error: Could not find the correct Provider<ShoppingListProvider> above this ShoppingList Widget
To fix, please:
* Ensure the Provider<ShoppingListProvider> is an ancestor to this ShoppingList Widget
* Provide types to Provider<ShoppingListProvider>
* Provide types to Consumer<ShoppingListProvider>
* Provide types to Provider.of<ShoppingListProvider>()
* Always use package imports. Ex: `import 'package:my_app/my_code.dart';
* Ensure the correct `context` is being used.
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:shopping_list/models/Product.dart';
import 'package:shopping_list/providers/ProductCollection.dart';
import 'package:shopping_list/providers/ShoppingItemCollection.dart';
class ProductList extends StatelessWidget {
@override
Widget build(BuildContext context) {
@stevepop
stevepop / logslaravel.sh
Created August 20, 2018 16:17 — forked from jakebathman/logslaravel.sh
Tail Laravel logs and filter out the stack traces
tail -f -n 450 storage/logs/laravel*.log \
| grep -i -E \
"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \
--color