Skip to content

Instantly share code, notes, and snippets.

View lloy0076's full-sized avatar
🏠
Working from home

David Lloyd lloy0076

🏠
Working from home
View GitHub Profile
// Singleton Class
class SumSingleton
{
private static $instance;
private $result;
private function __construct() {}
public static function getInstance()
{
@lloy0076
lloy0076 / MyStringThing.go
Created July 22, 2023 15:49
A New My String Fyne Binding Thing
package main
import (
"fyne.io/fyne/v2/data/binding"
"log"
)
type MySprintfString struct {
binding.String
#!/usr/bin/perl
use strict;
use warnings;
use feature ':5.10';
use local::lib;
use Carp;
@lloy0076
lloy0076 / gist:0fee3b3b99abdd78deea9daf2ea8ab0f
Created April 27, 2017 19:30
Laravel Seeder - Confound It!
c:\laragon\www\backpack\database\seeds (master)
λ cat DatabaseSeeder.php Cities.php
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
@lloy0076
lloy0076 / app_Http_Kernel.php
Created April 25, 2017 18:41
Backpack Permission Problem?
...
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
window._ = require('lodash');
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
// This sticks jquery onto the window object.
@lloy0076
lloy0076 / gist:dce62d9b2eddf9a113bfc6d0ae853260
Last active March 26, 2017 00:43
Customer Controller (Backpack)
```
// There is a field called 'new_password' which is left EMPTY if the password is not meant to be changed.
// WARNING: ONLY do this if you understand the implications of users (probably administrators) knowing
// other users' passwords; a more secure suggestion would be to force a password reset!
public function update(UpdateRequest $request)
{
DB::transaction(function() use ($request, &$redirect_location) {
// your additional operations before save here
```
public function rules()
{
// I've only done the 'email' rule because I'm lazy!
return [
'email' => [
'required', 'email', 'max:255', Rule::unique->ignore($this->id),
],
];
}
```
<?php
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
// VALIDATION: change the requests to match your own file names if you need form validation
use App\Http\Requests\MytestRequest as StoreRequest;