Skip to content

Instantly share code, notes, and snippets.

@just-den
just-den / umd-script-boilerplate.js
Created November 24, 2019 20:14 — forked from cferdinandi/umd-script-boilerplate.js
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@just-den
just-den / rotating.css
Created January 15, 2020 22:50 — forked from krizpoon/rotating.css
Infinite rotation by CSS. Useful for loading spinners.
@keyframes rotating
{
from
{
transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
}
@just-den
just-den / rAF.js
Created January 31, 2020 14:03 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@just-den
just-den / easing.js
Created January 31, 2020 22:40 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: t => t,
// accelerating from zero velocity
easeInQuad: t => t*t,
// decelerating to zero velocity
@just-den
just-den / smashingmagazine.js
Created February 1, 2020 21:27 — forked from luruke/smashingmagazine.js
Source code of the demo "Improving User Flow Through Page Transitions" on Smashing Magazine.
/*
https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/
You can copy paste this code in your console on smashingmagazine.com
in order to have cross-fade transition when change page.
*/
var cache = {};
function loadPage(url) {
if (cache[url]) {
@just-den
just-den / detectAnimationEnd.js
Created February 26, 2020 20:59 — forked from foolyoghurt/detectAnimationEnd.js
polyfill for detecting AnimationEnd and TransitionEnd event - from ReactTransitionEvents.js
/**
* EVENT_NAME_MAP is used to determine which event fired when a
* transition/animation ends, based on the style property used to
* define that event.
*/
var EVENT_NAME_MAP = {
transitionend: {
'transition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'mozTransitionEnd',
@just-den
just-den / user.js
Created February 26, 2020 20:59 — forked from EtienneR/user.js
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@just-den
just-den / eloquent-cheatsheet.php
Created December 21, 2020 22:33 — forked from hassansin/eloquent-cheatsheet.php
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@just-den
just-den / getCookie.php
Created March 23, 2021 15:38 — forked from scrubmx/getCookie.php
Get the cookie value inside a laravel test.
<?php
protected function getCookie($cookieName, $isEncrypted = true)
{
$cookie = array_first(
$this->response->headers->getCookies(),
function($index, $cookie) use ($cookieName) {
return $cookie->getName() === $cookieName;
}
);
@just-den
just-den / computable.ts
Created April 1, 2021 10:31 — forked from bingo347/computable.ts
Typescript arithmetic example
type Computable
= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
| 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
| 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29
| 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39
| 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49
| 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59
| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69
| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79
| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89