Skip to content

Instantly share code, notes, and snippets.

View sroehrl's full-sized avatar

neoan sroehrl

View GitHub Profile
@sroehrl
sroehrl / cli
Created February 12, 2023 00:19
LENKRAD scripts when starting from scratch
#!/usr/bin/env php
<?php
use Neoan\Cli\Application;
use Neoan\Helper\Setup;
use Neoan\NeoanApp;
require_once __DIR__ . '/vendor/autoload.php';
$setup = new Setup();
<?php
namespace App\Transformers;
use Josantonius\Session\Facades\Session;
use Neoan\Enums\Direction;
use Neoan\Model\Interfaces\Transformation;
class AttachUser implements Transformation
@sroehrl
sroehrl / simple-api-benchmark.js
Created August 6, 2022 19:28
Quick & dirty performance benchmarking for APIs
/*
* Simple API performance test for comparative benchmarking of GET-calls
*
* Usage: adjust variables below and then run `node benchmarkIt.js`
*
*
* Concurrency is not refilled during a cycle, as some benchmarking scripts do.
* This results in longer overall runtime and yield slower results than most benchmark metrics use.
* A good request-time is therefore ~< 20ms
@sroehrl
sroehrl / index.php
Created November 6, 2021 17:50
PHP: Most primitive blog - using less than a total of 75 lines of code (uses blua.blue as headless CMS)
<?php
$current = $_GET['entry'] ?? null;
$all = [];
$menu = '';
foreach (glob('archieve/*.json') as $i => $entry) {
$all[] = json_decode(file_get_contents($entry), true);
if (!$current) {
$current = $all[0]['slug'];
}
// menu
@sroehrl
sroehrl / AuthController.php
Created October 18, 2021 19:51
example of neoan3 implementation when using https://github.com/neoan3/email-password-auth
<?php
namespace Neoan3\Component\Auth;
use Neoan3\Core\RouteException;
use Neoan3\Frame\Demo;
use Neoan3\Model\User\UserModel;
use Neoan3\Provider\Auth\Authorization;
use Neoan3\Provider\Model\InitModel;
let config = {
baseURL: process.env.apiRoute, //http://localhost:3000
timeout: 8000,
headers: {'X-Custom-Header': 'wb-app'}
};
const API = axios.create(config);
API.interceptors.request.use(exitingConfig => {
if(sessionStorage.token){
exitingConfig.headers.Authorization = `Bearer ${localStorage.token.replace('"','')}`;
}
let planetIndex = 1;
// the following line does only work on a local system and not online (so only if you check out the repo)
spaceStation.cheat();
/*
Practice scenario: Retrieve cargo
Click on "execute" to start!
YOUR TASK: use a second ship to retrieve cargo from a rouge drone!
@sroehrl
sroehrl / Vagrantfile
Last active February 26, 2021 22:53
Vagrant setup for neoan3 v3
# -*- mode: ruby -*-
# vi: set ft=ruby :
# neoan3 vagrant box
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.network "private_network", ip: "192.168.33.10"
@sroehrl
sroehrl / UserModel.php
Last active January 31, 2021 02:19
Basic user model for neoan3 v3.1
<?php
/* Generated by neoan3-cli */
namespace Neoan3\Model\User;
use Exception;
use Neoan3\Provider\MySql\Database;
use Neoan3\Provider\Model\Model;
use Neoan3\Provider\MySql\Transform;
@sroehrl
sroehrl / index.php
Created April 21, 2020 14:59
smucka
<?php
define('varovalka', true);
ini_set('error_reporting',E_ALL);
ini_set('display_errors',1);
include_once 'shared.php';
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>