Skip to content

Instantly share code, notes, and snippets.

@mass6
mass6 / validation.php
Created March 21, 2023 20:21
danish validation file
<?php
return [
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
@mass6
mass6 / DTO.php
Last active March 24, 2021 09:05
Self validation DTO
<?php
use Illuminate\Support\Str;
use Illuminate\Validation\Validator;
use Illuminate\Validation\ValidationException;
use Illuminate\Support\Facades\Validator as ValidatorFactory;
/**
* Class CoreCTO
*/
@mass6
mass6 / laranew.sh
Created November 17, 2020 13:35 — forked from WyattCast44/laranew.sh
#!/bin/bash
laravel new $1
# Change Dir
cd $1
# Update .env
sed -i "s/APP_NAME=Laravel/APP_NAME=$1/g" .env
sed -i "s/DB_DATABASE=laravel/DB_DATABASE=$1/g" .env
@mass6
mass6 / ChallengeService.php
Created January 4, 2020 10:27
Get start time rounded up to next 5 minutes
$currentMinute = Carbon::parse($userStartTime)->startOfMinute();
$diff = (int) $this->roundUpToAny($currentMinute->minute, 5) - $currentMinute->minute; // 50
$additionalMinutes = (integer) $this->roundUpToAny(mt_rand(120, 360), 5);
$start_time = $currentMinute->addMinutes($diff + $additionalMinutes);
dd($start_time);
# add Sublime Text 3 stable to your sources
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
#update sources
sudo apt update -y && sudo apt dist-upgrade -y
#install
sudo apt install sublime-text
@mass6
mass6 / server-setup.sh
Created August 30, 2018 14:05
App Server Setup Script
#
# REQUIRES:
# - server (the forge server instance)
# - event (the forge event instance)
# - sudo_password (random password for sudo)
# - db_password (random password for database user)
# - callback (the callback URL)
# - recipe_id (recipe id to run at the end)
#
@mass6
mass6 / post_install.sh
Created April 15, 2018 22:58 — forked from derrekbertrand/post_install.sh
PHP development machine post install setup for Ubuntu 16.04 LTS and Mint 18 LTS.
#!/bin/bash
# Post install script for Ubuntu 16.04LTS and Mint 18LTS
# add the PHP PPA https://deb.sury.org/
sudo add-apt-repository -y ppa:ondrej/php
# I believe even releases are LTS, so when 8 comes out should update
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
# add Sublime Text 3 stable to your sources
@mass6
mass6 / Randomizer.php
Last active November 29, 2017 14:23
Creates a repeatable randomizer/shuffle of an array based on a given seed.
<?php
namespace Tattoodo\Helpers;
use Carbon\Carbon;
/**
* Creates a repeatable randomizer/shuffle of an array based on a given seed.
*/
class Randomizer
@mass6
mass6 / model.php
Last active October 17, 2017 08:52
public function getModelRepresentation()
{
switch ($this) {
case instance of Mention:
if ($this->mentionable instanceof Comment) {
return $this->mentionable->commentable;
}
return $this->mentionable;
break;
case instance of Comment:
@mass6
mass6 / sortable.html
Created January 18, 2017 08:11
jQuery-UI Sortable list
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Sortable - Default functionality</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style>
body {