Skip to content

Instantly share code, notes, and snippets.

@minedun6
minedun6 / opendb.sh
Created September 21, 2020 09:11 — forked from AlexVanderbist/opendb.sh
`opendb` command - opens the database for a Laravel app in your GUI
opendb () {
[ ! -f .env ] && { echo "No .env file found."; exit 1; }
DB_CONNECTION=$(grep DB_CONNECTION .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_HOST=$(grep DB_HOST .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_PORT=$(grep DB_PORT .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_DATABASE=$(grep DB_DATABASE .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_USERNAME=$(grep DB_USERNAME .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_PASSWORD=$(grep DB_PASSWORD .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@minedun6
minedun6 / promise-take-at-least.js
Created September 21, 2020 09:11 — forked from adamwathan/promise-take-at-least.js
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@minedun6
minedun6 / Env.js
Created August 7, 2020 11:02
Seems like a cool trick that not too many people know about...Using PHP magic methods in JS, thanks to weird constructor semantics and Proxy. @assertchris
class Env {
constructor() {
this.secrets = {};
return new Proxy(this, {
set: this.__set,
get: this.__get,
});
}
@minedun6
minedun6 / AppServiceProvider.php
Created August 5, 2020 13:44
Something I struggled with is that `to()` adds the $parameters to the path by default `success/verify_email` instead of `success?type=verify_email`. So I've slightly adjusted your example to match my needs. @devgummibeer
<?php
namespace App\Providers;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Support\ServiceProvider;
use Arr;
class AppServiceProvider extends ServiceProvider
{
@minedun6
minedun6 / helpers.php
Created August 5, 2020 13:30
Here's how you can temporally force a different host on the #laravelphp URL generator. Useful when you're generating URLs for your frontend SPA! @m1guelpf
<?php
if (! function_exists('frontend_url')) {
function frontendUrl($path = null, $parameters = [], $secure = null) : string {
$builder = url();
$builder->forceRootUrl(
app()->isProduction() ? 'https://xxxx.xxxx' : 'http://localhost:3000/';
@minedun6
minedun6 / README.md
Created June 7, 2020 23:09 — forked from yckart/README.md
Checks if an element is inside another or if it collides with another. - http://stackoverflow.com/a/19614185/1250044

Usage:

var player = new Rect(0, 0, 100, 100);
var target = new Rect(50, 50, 100, 100);
player.is = new AABB(player);

player.is.inside(target);
player.is.colliding(target);
player.is.containing(target);
@minedun6
minedun6 / tailwind.config.js
Created March 6, 2020 09:47 — forked from hacknug/tailwind.config.js
TailwindCSS default config
/*
Tailwind - The Utility-First CSS Framework
A project by Adam Wathan (@adamwathan), Jonathan Reinink (@reinink),
David Hemphill (@davidhemphill) and Steve Schoger (@steveschoger).
Welcome to the Tailwind config file. This is where you can customize
Tailwind specifically for your project. Don't be intimidated by the
length of this file. It's really just a big JavaScript object and
@minedun6
minedun6 / bootstrap_modal_in_tailwind.html
Created March 6, 2020 09:46 — forked from andreaseriksson/bootstrap_modal_in_tailwind.html
Create a Bootstrap modal with Tailwind CSS
<!-- Button trigger modal -->
<button type="button" class="inline-block font-normal text-center px-3 py-2 leading-normal text-base rounded cursor-pointer text-white bg-blue-600" data-toggle="modal" data-target="#exampleModalTwo">
Launch modal two
</button>
<!-- Modal -->
<div class="modal hidden fixed top-0 left-0 w-full h-full outline-none fade" id="exampleModalTwo" tabindex="-1" role="dialog">
<div class="modal-dialog relative w-auto pointer-events-none max-w-lg my-8 mx-auto px-4 sm:px-0" role="document">
<div class="relative flex flex-col w-full pointer-events-auto bg-white border border-gray-300 rounded-lg">
<div class="flex items-start justify-between p-4 border-b border-gray-300 rounded-t">
@minedun6
minedun6 / ec2.js
Created January 29, 2020 08:26
AWS Node.js SDK; EC2 instance creation and termination example
var aws = require('aws-sdk');
aws.config.update({
accessKeyId: 'YOUR_ACCESS_KEY',
secretAccessKey: 'YOUR_SECRET_KEY',
region: 'us-west-2'
});
var ec2 = new aws.EC2();