Skip to content

Instantly share code, notes, and snippets.

Avatar

William Dias wdiasvargas

View GitHub Profile
View hello.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href='https://fonts.googleapis.com/css?family=Lobster+Two:700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Cookie:400' rel='stylesheet' type='text/css'></head>
<body>
<style>
body{
@wdiasvargas
wdiasvargas / arr-stat.js
Created May 13, 2016 — forked from Daniel-Hug/arr-stat.js
JavaScript statistical functions for arrays: max, min, range, midrange, sum, mean / average, median, modes, variance, standard deviation, mean absolute deviation, z scores
View arr-stat.js
var arr = {
max: function(array) {
return Math.max.apply(null, array);
},
min: function(array) {
return Math.min.apply(null, array);
},
range: function(array) {
View moda.js
'use strict'
/**/
function moda (arr) {
return ((arr.sort((a, b) =>
(arr.filter(v => v === a).length) - (arr.filter(v => v === b).length))
).pop())
}
module.exports = moda
console.log(moda([1,2,3,4,5])) //amodal nao tem moda(nao deveria aparecer nada)
View quartis.js
values = [82.1467068058,38.4966734016,32.0008188793,96.9622650244,86.8058759993,79.3362306586,58.0055852798,75.8220414787,67.0149545567,36.4044706595,85.3345320643,20.6287894419,81.7456373986,24.4326880876,19.9944876851,80.2303362813,98.6854373061,4.3960766433,22.1212283642,53.1724684800,50.3620960690,11.3724002897,41.0039978225,64.8333473234,15.5894909570,85.3067494504,84.0015994709,91.3425614815,47.3171987992,16.5602177445,86.5891620670,27.3438542203,72.3398157121,18.5367692487,40.5793436922,70.1641373485,59.9469967755,64.6235988325,35.4129698701,90.1449361797,89.5436831889,20.7605480631,72.2822633062,27.9079298572,67.1159466004,68.6223243990,88.5802505560,13.6363037261,24.7355830273,19.7367890419,63.9377755788,75.6711643900,31.9382648930,45.6193707884,43.8147543419,18.2865472284,39.0358874791,6.6626381087,64.3532950055,57.8284906640,69.1947236148,18.9723704594,28.5984494536,86.5579189727,34.9384562133,26.2378601208,97.9248087536,38.6448350638,77.7968509496,77.5877098686,1.4398382678,87.6189498380,47.837622
@wdiasvargas
wdiasvargas / Usuario.es6
Created Apr 29, 2017
proxy ES6 with babel
View Usuario.es6
/**
* Created by William Dias on 29/04/17.
* www.williamdiasvargas.com.br
*/
'use strict'
class Usuario {
constructor (login, senha) {
this.login = login;
this.senha = senha;
@wdiasvargas
wdiasvargas / Stack.es6
Created May 4, 2017
Nao entendo pq nao esta funcionando
View Stack.es6
/**
* Write by wdiasvargas on 04/05/17.
* www.williamdiasvargas.com.br
*
**/
'use strict'
//STACK com ES6
import push from './stack_methods/push'
import pop from './stack_methods/pop'
import peek from './stack_methods/peek'
@wdiasvargas
wdiasvargas / Stack.es6
Created May 4, 2017
assim tbm funciona ta com arrow functions mas ainda nao ta modular :/
View Stack.es6
/**
* Write by wdiasvargas on 04/05/17.
* www.williamdiasvargas.com.br
*
**/
'use strict'
//STACK com ES6
class Stack {
constructor () {
this.data = [];
View babel-setup
npm install --save-dev babel-preset-env && echo { "presets": ["env"] } > .babelrc
View trial-division
function isPrime(n) {
if (n == 2 || n == 3 || n == 5 || n == 7) {
return true;
} else if ((n < 2) || (n % 2 == 0)) {
return false;
} else {
for (var i = 3; i <= Math.sqrt(n); i += 2) {
if (n % i == 0)
return false;
}
@wdiasvargas
wdiasvargas / fibonacci.js
Last active Jun 20, 2017
fibonacci_memoization_oneliner
View fibonacci.js
/**
* Created by William on 20/06/2017.
*/
import fibonacci from './fibonacci';
export default (n = 0) => (m = {}) => (m[n]) ? (m[n]) : (n <= 1) ? (n) :(m[n]) = ((fibonacci(n-1)(m)) + (fibonacci(n-2)(m)));
console.info(fibonacci(7)())
// function fibonacci(num, memo) {
// memo = memo || {};
//
// if (memo[num]) return memo[num];