Skip to content

Instantly share code, notes, and snippets.

View TechWithTy's full-sized avatar
🎯
Focusing

TechWIthTy TechWithTy

🎯
Focusing
View GitHub Profile
@TechWithTy
TechWithTy / instalike.js
Created May 28, 2019 04:58 — forked from jadeallencook/instalike.js
Scripts that auto likes posts on instagram via tag.
let likesGiven = 0;
setInterval(() => {
let heart = document.getElementsByClassName('glyphsSpriteHeart__outline__24__grey_9'),
arrow = document.querySelector('.coreSpriteRightPaginationArrow');
if (heart[1]) {
heart = heart[1].parentElement;
likesGiven++, heart.click();
}
arrow.click();
console.log(`You've liked ${likesGiven} post(s)!`);
// OnScroll Hide (Mobile)
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos || document.body.scrollTop <= 10) {
document.getElementById('navbar').style.top = '0';
// document.getElementById('navbar').style.opacity = '1';
} else {
document.getElementById('navbar').style.top = '-500px';
}
if (
typeof localStorage !== 'undefined' &&
localStorage.getItem('FreeShippingSiteWide') === null
) {
// Your code here
this.notify();
localStorage.setItem('FreeShippingSiteWide', true);
}
const params = props.location.pathname.toLowerCase();
if (params.includes('womens')) {
setNav('#ed0070c9');
} else if (params.includes('mens')) {
setNav('#e12626c9');
} else if (params.includes('device')) {
setNav('rgba(28, 228, 248, 0.79)');
} else if (params.includes('pipe')) {
setNav('#c7d1d9b0');
} else if (params.includes('smoke')) {
@TechWithTy
TechWithTy / Products Scroll distance
Created August 16, 2019 00:07
Calculate Scroll Distance until the bottom of products
const setScrollDistance = product => {
const productRowLength = Math.ceil(product.length / 4);
switch (productRowLength) {
case 4:
if (counter === 0) {
setItems(productRowLength * 350 + mobile);
} else {
setItems(productRowLength * 530 + mobile);
@TechWithTy
TechWithTy / gist:ad31723fd74a50a08cd103cc210bb48d
Created September 10, 2019 23:22
Sorting Algorithm One Liners
// console.log(
// tempProducts.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)),
// 'Price Lowest to Highest'
// );
// console.log(
// tempProducts.sort((a, b) => parseFloat(b.price) - parseFloat(a.price)),
// 'Price Highest to Lowest'
@TechWithTy
TechWithTy / SortSocks.js
Created September 15, 2019 01:52
HackerRank Sock Pairs Challenge
function sortAndCount( n, arr ) {
let sorted = arr.sort( (a,b) => a - b);
let pairs = 0;
for (let i = 0; i < n -1 ; i++) {
if ( sorted[i] === sorted[i + 1]) {
pairs++;
i += 1;
}
}
@TechWithTy
TechWithTy / Jest-Test
Created September 24, 2019 00:54
Jest-Test
import {productionEnv} from './context'
console.log(productionEnv)
const production = true;
test('Production Test', () => {
expect(production).toBeTruthy();
});
import Button from '@material-ui/core/Button';
import Checkbox from '@material-ui/core/Checkbox';
import ExpansionPanel from '@material-ui/core/ExpansionPanel';
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
import Paper from '@material-ui/core/Paper';
import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
@TechWithTy
TechWithTy / orderFind
Created September 25, 2019 02:23
Order Login Modal
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import React, { useContext, useEffect, useState } from 'react';
import { withRouter } from 'react-router-dom';
import styled from 'styled-components';
import { ProductContext } from '../context';
const LoginModal = props => {
const [transactionID, settransactionID] = useState(1);
const [orderNum, setorderNum] = useState(1);