Skip to content

Instantly share code, notes, and snippets.

@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 / 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();
@minedun6
minedun6 / enumerate-dates-by-period.js
Created January 23, 2020 09:17 — forked from gvko/enumerate-dates-by-period.js
Enumerate days, weeks, months or years
'use strict';
const moment = require('moment');
/**
* Returns a {key: value} object where the key is a start date and the value is the date + 1 of the type of interval
* to the start date. When for weeks or months, it shows just the first date of the week/month.
*
** For days (start: '2017-12-25', end: '2018-01-02', interval: 'day'):
{ '2017-12-25': '2017-12-26',
@minedun6
minedun6 / EventedDatastore.js
Created July 9, 2019 07:53 — forked from JamesMGreene/EventedDatastore.js
Forcibly adding NeDB events by deriving from the Datastore prototype
// IMPORTANT:
// As of nedb@^1.7.0, Datastore now inherits from EventEmitter in the NeDB core module.
// If you need to support older versions of NeDB, please look at the following previous revision
// of this gist:
// https://gist.github.com/JamesMGreene/0e0b2506c7bd2a2557f7/d8b4b1e97bb0d118c509672e3c7276b6dc4ba13a
/*
This gist provides a module which derives from the NeDB Datastore module and extends it to
emit several important events:
@minedun6
minedun6 / gist:f7f972f4cf43cd30076497c39d03c069
Last active June 17, 2019 15:48 — forked from dosjota/gist:9666a7274b4036588b92987b84267245
Downgrade php 7.2 to 7.1/7.0 in Ubuntu 18.04 LTS
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
sudo apt-get install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-intl php7.1-simplexml
sudo a2dismod php7.2
sudo a2enmod php7.1
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
@minedun6
minedun6 / tinker_helper.php
Created February 7, 2019 10:20 — forked from calebporzio/tinker_helper.php
A quick, memorable way to initiate an "artisan tinker" session and play with variables.
<?php
function tinker(...$args) {
// Because there is no way of knowing what variable names
// the caller of this function used with the php run-time,
// we have to get clever. My solution is to peek at the
// stack trace, open up the file that called "tinker()"
// and parse out any variable names, so I can load
// them in the tinker shell and preserve their names.
@minedun6
minedun6 / string-utils.js
Created November 29, 2018 13:44 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();