Skip to content

Instantly share code, notes, and snippets.

View arthurvasconcelos's full-sized avatar
🖖
Live long and prosper.

Arthur Vasconcelos arthurvasconcelos

🖖
Live long and prosper.
View GitHub Profile
@arthurvasconcelos
arthurvasconcelos / divideWithLogarithms.js
Created November 16, 2016 12:05 — forked from deadkff01/divideWithLogarithms.js
JavaScript divide function without using "/"
// Multiplication and division rules... ((+)*(+)=+) ((-)*(-)=+) ((+)*(-)=-) ((-)*(+)=-)
const multiply = (x, y) => {
let r = Math.exp(Math.log(Math.abs(x)) + Math.log(Math.abs(y))).toFixed(2)
return Number((x < 0 && y < 0) ? r : (x < 0 || y < 0) ? -r : r)
}
const divide = (x, y) => {
return (x === 0) ? 0 : multiply(((multiply(x, y) < 0) ? -1.0 : 1.0), Math.exp(Math.log(Math.abs(x)) - Math.log(Math.abs(y))))
}
@arthurvasconcelos
arthurvasconcelos / utils.preload-images.js
Created July 26, 2016 00:39 — forked from chrism/utils.preload-images.js
Preloading images using Ember.JS util
import Ember from 'ember';
var Promise = Ember.RSVP.Promise;
export default function preloadImages(...urls) {
let promises = urls.map(url => {
return new Promise((resolve, reject) => {
let image = new Image();
image.onload = resolve;
image.onerror = reject;
image.src = url;
<?php
namespace App\Custom\Pagination\Presenters;
use Illuminate\Pagination\BootstrapThreePresenter;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\UrlWindow;
class MaterializePresenter extends BootstrapThreePresenter
{