Skip to content

Instantly share code, notes, and snippets.

View NBZ4live's full-sized avatar

Sergey NBZ4live

  • My.com B.V.
  • Amsterdam
View GitHub Profile
@NBZ4live
NBZ4live / build.rs
Created February 16, 2020 01:27
Rust config_struct crate build script with check for the existence of the config file
use config_struct::{Error, StructOptions};
use std::fs;
const CONFIG_FILE_DST: &str = "src/config.rs";
fn main() -> Result<(), Error> {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=config.toml");
let mut config_file_src = "config.toml";
@NBZ4live
NBZ4live / tinker_script.php
Last active June 13, 2018 12:34
Print MySQL Grants for all not working connections configured in Laravel
<?php
$userHost = '%';
foreach(config('database.connections') as $name => $connection) {
if ($connection['driver'] != 'mysql') {
continue;
}
try {
\DB::connection($name)->getPdo();
} catch(\Doctrine\DBAL\Driver\PDOException $exception) {
@NBZ4live
NBZ4live / LumenAdapter.php
Created March 6, 2018 14:30
PHP-PM Lumen adapter
<?php
namespace App\PHPPM;
use Illuminate\Container\BoundMethod;
use Illuminate\Support\ServiceProvider;
use PHPPM\Bootstraps\Laravel;
class LumenAdapter extends Laravel
{
@NBZ4live
NBZ4live / clone.blade.php
Created February 10, 2018 21:27
Laravel backpack clone button. (resources/views/vendor/backpack/crud/buttons/custom/clone.blade.php)
@if ($crud->hasAccess('create'))
@php($parameters = [])
@php($attributes = collect($entry->getAttributes()))
@foreach($crud->getFields('create') as $field)
@if($attributes->has($field['name']))
@php($parameters[$field['name']] = $attributes->get($field['name']))
@endif
@endforeach
@NBZ4live
NBZ4live / 2018_02_07_101510_migrate_to_utf8mb4.php
Created February 7, 2018 11:56
Laravel migration to migrate the database from utf8 to utf8mb4
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MigrateToUtf8mb4 extends Migration
{
/**
* Run the migrations.
@NBZ4live
NBZ4live / WoltlabSuiteValetDriver.php
Created October 2, 2017 12:19
WoltlabSuiteValetDriver
<?php
class WoltlabSuiteValetDriver extends BasicValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@NBZ4live
NBZ4live / CrudController.php
Created March 5, 2017 21:54
Simple Laravel Backpack text filter for a single field
<?php /** app/Http/Controllers/CrudController.php **/
namespace App\Http\Controllers;
use Illuminate\Http\Response;
class CrudController extends \Backpack\CRUD\app\Http\Controllers\CrudController
{
public function setUp()
{
#!/usr/bin/env php
<?php
/*
Copyright 2013 Stuart Carnie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to