Skip to content

Instantly share code, notes, and snippets.

View Dannzzor's full-sized avatar
🌮

Danny Davenport Dannzzor

🌮
View GitHub Profile
/* Find the largest product of factors for a given number.
* ie, if you split a number into segments, then multiply those segments,
* find the largest possible product of all the possible segment sizes
* and return the array of segments
*/
function bestFactors(num) {
const rem = num%3;
return num > 3 ? [
...(rem ? [ ...Array(3-rem) ].map(() => 2) : []),
...[...Array( (num - (rem ? ((3-rem) * 2) : 0)) / 3)].map(() => 3)
@Dannzzor
Dannzzor / .eslintrc
Created February 22, 2019 20:18 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@Dannzzor
Dannzzor / AriakeDarkout.css
Created April 16, 2018 12:12
Stylish - Chrome plugin - Ariake darkout all websites theme
* {
background: #2a2d36!important;
border-color: #b7bdd2!important;
color: #86b2de !important;
}
a {
color: #a374ef!important;
}
@Dannzzor
Dannzzor / javascript.json
Last active December 3, 2017 22:06
VS Code snippet: enhanced import
{
"Enhanced import": {
"prefix": "impp",
"body": [
"import { $2 } from '$1';",
"$3"
],
"description": "Type `impp` then hit tab, then enter the source, hit tab again, then enter what part you wish to import. This way you get autocomplete on the exported methods!"
}
}

Keybase proof

I hereby claim:

  • I am dannzzor on github.
  • I am dannzzor (https://keybase.io/dannzzor) on keybase.
  • I have a public key ASD-HJwJaC1_QyGcQurv8NX7WqKutGv4Km2jUhboSXhMNgo

To claim this, I am signing this object:

function leftPad(str, len, fil) {
return new Array(len - str.length +1).join(fil || 0) + str;
}
@Dannzzor
Dannzzor / regex_tokenizer.js
Last active August 29, 2015 14:26 — forked from raisch/regex_tokenizer.js
Regular Expression Sentence Tokenizer (English)
// tokenize(str)
// extracts semantically useful tokens from a string containing English-language sentences
// @param {String} the string to tokenize
// @returns {Array} contains extracted tokens
function tokenize(str) {
var punct='\\['+ '\\!'+ '\\"'+ '\\#'+ '\\$'+ // since javascript does not
'\\%'+ '\\&'+ '\\\''+ '\\('+ '\\)'+ // support POSIX character
'\\*'+ '\\+'+ '\\,'+ '\\\\'+ '\\-'+ // classes, we'll need our
; // jQuery material easing
jQuery.extend( jQuery.easing,
{
easeInOutMaterial: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t + b;
return c/4*((t-=2)*t*t + 2) + b;
}
});
/*
* ========================================================================================
* DRD.js
* Vx.x.a
* Created: 26 July 2014
* Created by: DRD
* ----------------------------------------------------------------------------------------
* Update log: (please log any changes you make!) Example: Version# - Date - Name - updates
* Vx.x.a - 29 July 2014 - DRD - Converted the former DRD.js to the new structure of DRD.js
*
@Dannzzor
Dannzzor / matchKMP.js
Created September 22, 2014 17:24
Knuth-Morris-Pratt algorithm -- string matching
/* Knuth-Morris-Pratt algorithm
*
* best for limited alphabet, such as DNA matching
*
*
*/
function matchKMP(str, keyword) {
var i = 1,