Skip to content

Instantly share code, notes, and snippets.

View toddpress's full-sized avatar

Todd Pressley toddpress

  • ATI
  • Summerville
View GitHub Profile
let obj = {}
obj[Symbol.for('unique_prop')] = 10;
console.log(obj[Symbol.for('unique_prop')]); //This will print 10!
@toddpress
toddpress / index.pug
Last active December 27, 2020 19:02
Take a Number And Sum Its Digits Raised To The Consecutive Powers And ....¡Eureka!!
p The number 89 is the first integer with more than one digit that fulfills the property partially introduced in the title of this kata. What's the use of saying "Eureka"? Because this sum gives the same number.
p In effect:
code 89 = 8^1 + 9^2
p The next number in having this property is 135.
p See this property again:
code 135 = 1^1 + 3^2 + 5^3
@toddpress
toddpress / index.pug
Created December 24, 2020 05:46
Tribonacci Sequence - CodeWars
p Well met with Fibonacci bigger brother, AKA Tribonacci.
p As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next. And, worse part of it, regrettably I won't get to hear non-native Italian speakers trying to pronounce it :(
p So, if we are to start our Tribonacci sequence with [1, 1, 1] as a starting input (AKA signature), we have this sequence:
code [1, 1 ,1, 3, 5, 9, 17, 31, ...]
p But what if we started with [0, 0, 1] as a signature? As starting with [0, 1] instead of [1, 1] basically shifts the common Fibonacci sequence by once place, you may be tempted to think that we would get the same sequence shifted by 2 places, but that is not the case and we would get:
code [0, 0, 1, 1, 2, 4, 7, 13, 24, ...]
@toddpress
toddpress / web.config
Created April 10, 2020 14:01
IIS-Node web.config boilerplate
?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!--
All appSettings are made available to your Node.js app via environment variables
You can access them in your app through the process.env object.
process.env.<key>
-->
@toddpress
toddpress / gist:650762215aae7f54ddb2fb74f4e1e9d6
Created April 12, 2017 09:09
Sass function to calc guitar fret widths
@function calculate-fret-distance($scaleLength, $nthFret)
@return $scaleLength - $scaleLength / pow(2, ($nthFret/12))
@toddpress
toddpress / 0_reuse_code.js
Created January 16, 2016 17:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@toddpress
toddpress / CSS_Knob
Created June 26, 2014 19:30
CSS only knob
/*
Note:
1) THERE MUST BE A BETTER WAY TO DO THIS
2) The colored portion of the gradients must be the same as their parent's background
3) The hover state was only added for demonstration
*/
* {margin: 0; padding: 0;}
@toddpress
toddpress / aspect_ratio
Last active August 29, 2015 13:59
Maintain element's aspect ratio like a baller
.aspectRatio(@widthAspect, @heightAspect) {
@aspect: @heightAspect/@widthAspect * 100;
max-width: 100%;
&:before {
content: '';
display: block;
width: 100%;
padding-bottom: ~"@{aspect}%";
}
@toddpress
toddpress / no_overscroll
Last active December 28, 2015 11:49
You may have noticed in mobile safari that when you scroll past the document top, the content continues dragging until you release it. This reveals an ugly grey background, and diminishes the native feel of a site; moreover, this native feel is becoming especially important to webapps and whatnot. Short and sweet.
<!-- great for the heinous bounce factor on mobile safari -->
<script>
document.addEventListener( "DOMContentLoaded", function() {
// allow scrolling on appropriate elements lower in the DOM
[].map.call(document.querySelectorAll('.scrollable'), function(el) {
el.addEventListener('touchmove', function(e) {
e.scrollable = true;
});