Skip to content

Instantly share code, notes, and snippets.

View RomainMazB's full-sized avatar

Romain 'Maz' BILLOIR RomainMazB

View GitHub Profile
@RomainMazB
RomainMazB / MyFile.php
Created March 6, 2024 18:04
Nova repeater with file
<?php namespace App\Nova\Fields;
use Closure;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Fields\File;
class MyFile extends File {
protected function fillAttribute(NovaRequest $request, $requestAttribute, $model, $attribute)
{
$hasExistingFile = ! is_null($this->getStoragePath());
use bevy::prelude::*;
use bevy_editor_pls::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(EditorPlugin)
.add_plugin(bevy::diagnostic::FrameTimeDiagnosticsPlugin)
.add_plugin(bevy::diagnostic::EntityCountDiagnosticsPlugin)
.add_startup_system(startup_system)
@RomainMazB
RomainMazB / basic-form.twig
Last active September 12, 2022 11:07
Exemple of implementation for sunlab/wn-forumupload-plugin
<!-- Needed to postpone deferred bindings -->
<input type="hidden" id="session-key" />
<!-- A basic textarea which will listen for drag'n'drop events -->
<textarea id="post-content"></textarea>
<!-- A paragraph to display upload guide -->
<p id="upload-informations"></p>
{% put scripts %}
@RomainMazB
RomainMazB / PrestaShopValetDriver.php
Created September 10, 2020 07:13
A Valet PrestaShop Driver, tested on 1.6.2 but it should work on newer version. Just place it in your ~/.valet/Drivers/ directory and let the magic happen :)
<?php
class PrestaShopValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@RomainMazB
RomainMazB / TheliaValetDriver.php
Created June 30, 2020 23:33
Place this file into your Laravel Valet's Drivers directory to work with Thelia installation without any additionnal project configuration
<?php
class TheliaValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
public function testOldReadMessagesAreDeletedFromDatabase(): void
{
// Register messages from current and another user's city
$this->city2->history->register('11111 Message');
$this->city->history->register('22222 Message');
// Back from the future
DB::update(
"UPDATE histories SET deleted_at = NOW() - CONCAT(?::VARCHAR, ' 1 second')::INTERVAL",
[config('game.delete_read_message_after')]
public function testSacrifyEggsIncreaseFood(): void
{
$expected_food = $this->city->getFood();
$this->city->buildings->nursery->populate(4, 'warrior');
$expected_food += 4 * config('city_default_values.abilities.food_ratio_for_sacrifices_egg');
$this->city->buildings->nursery->sacrifyEggs(4, 'egg');
$this->assertEquals($expected_food, $this->city->getFood());
public function testUserCanGetAllAchievements(): void
{
for($i = 0; $i < 3; $i++) {
$this->city->buildings->nursery->populate(10, 'warrior');
$this->city->buildings->nursery->sacrifyEggs(10, 'egg');
}
$larvae_offset = config('game.total_development_time.end') - config('game.development_times.larvae.end') + 25;
for($i = 0; $i < 3; $i++) {
$this->city->buildings->nursery->populate(10, 'warrior');
{
"data": [
{
"name": "Disease-it",
"url": "http://disease-it.jeuweb.org/",
"image": "https://img.itch.zone/aW1nLzMxMTA5ODQucG5n/original/zO55Li.png",
"description": null,
"email": null,
"id_thread": 12568
},
const max_pending_promises = 3
export default class Queue {
static queue = [];
static nb_pending_promises = 0;
static enqueue (promise) {
return new Promise((resolve, reject) => {
this.queue.push({
promise,