Skip to content

Instantly share code, notes, and snippets.

Jason Gresalfi jgresalfi

Block or report user

Report or block jgresalfi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jgresalfi
jgresalfi / hs-boilerplate.css
Created May 3, 2016
Hubspot Boilerplate CSS
View hs-boilerplate.css
/* @import url('http://example.com/example_style.css'); */
/**
* CSS @imports must be at the top of the file.
* Add them above this section.
*/
/* ==========================================================================
View Sticky bar shadow snippets
/* If you have a sticky bar at the top of a webpage that's the same color as the page background, this will fade in a drop shadow below the bar to create a boundary on scroll */
// jQuery
$(document).ready(function(){
var a=$(".sticky-top-bar");
$(window).scroll(function(){
if($(document).scrollTop()>50){a.addClass("top-bar-shadow")
}else{a.removeClass("top-bar-shadow")}})});
@jgresalfi
jgresalfi / profile.js
Created Sep 4, 2016
Profile lookup/edit
View profile.js
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
@jgresalfi
jgresalfi / randNum.js
Last active Sep 4, 2016
Random number guessing game.
View randNum.js
"use strict";
var upper = 10000,
numToGuess = getRandomNumber(upper),
compGuess = getRandomNumber(upper),
numOfGuesses = 0,
correctGuess = false;
function getRandomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
@jgresalfi
jgresalfi / randNum_v2.js
Created Sep 4, 2016
Random number guessing game - refactor
View randNum_v2.js
"use strict";
var upper = 10000,
numToGuess = getRandomNumber(upper),
compGuess,
numOfGuesses = 0;
function getRandomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
}
@jgresalfi
jgresalfi / eyePalindrome.js
Created Sep 4, 2016
Palindromes and regexp...hooray!
View eyePalindrome.js
function palindrome(str) {
// Good luck!
var re = /[\s\!\@\#\$\%\^\&\*\(\)\+\=\-/\\\\:\_]/g,
cleanStr,
revStr;
cleanStr = str.toLowerCase().replace(re, "");
revStr = cleanStr.split("").reverse().join("");
if (cleanStr === revStr) {
return true;
} else { console.log(cleanStr); }
View factorializer.js
function factorialize(num) {
var facArray = [];
if (num === 0) {
return 1;
} else {
for (var i = 1; i <= num; i++) {
facArray.push(i);
@jgresalfi
jgresalfi / recordCol.js
Created Sep 4, 2016
Modifying objects/checking properties - record collection example
View recordCol.js
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
View reverseStr.js
function reverseString(str) {
var strArray = str.split("");
strArray.reverse("");
return strArray.join("");
}
reverseString("hello");
@jgresalfi
jgresalfi / phoneBuyerz.js
Created Sep 4, 2016
Silly phone buying app...
View phoneBuyerz.js
"use strict";
const SALESTAX = .0975,
PHONE_PRICE = 200.00,
ACCESS_PRICE = 40.00;
var ba = prompt("How much money you got?"),
ac = prompt("When to stop buying accessories?"),
bankAccount = parseInt(ba),
accessoryLimit = parseInt(ac),
You can’t perform that action at this time.