Skip to content

Instantly share code, notes, and snippets.

View stevedya's full-sized avatar
🤠

Steve Stein stevedya

🤠
View GitHub Profile
@stevedya
stevedya / input.scss
Created June 23, 2023 21:40
Generated by SassMeister.com.
@use "sass:map";
$color-dark: #1d1d1d;
$color-primary-medium: #f65050;
$color-purple: #4e47c9;
$color-white: #fff;
$colors: (
'primary-medium': ('bg': $color-primary-medium, 'text': $color-dark),
'purple': ('bg': $color-purple, 'text': $color-white),
@stevedya
stevedya / tailwind-aria-hidden-variant-plugin.js
Created May 13, 2022 21:57
tailwind-aria-hidden-variant-plugin.js
// Aria expanded attribute variant for styling when aria-expanded:className or aria-not-expanded:className
plugin(({ addVariant, e }) => {
addVariant('aria-hidden', ({ modifySelectors, separator }) => {
modifySelectors(
({ className }) =>
`.${e(`aria-hidden${separator}${className}`)}[aria-hidden='true']`,
);
});
addVariant('aria-not-hidden', ({ modifySelectors, separator }) => {
modifySelectors(
@stevedya
stevedya / inset-mixin.scss
Created September 23, 2020 17:55
Inset Sass Mixin
/* ============================================
Inset helper for quick top, right, bottom, left properties.
Use until the inset: css property has better browser support
https://caniuse.com/mdn-css_properties_inset
*/
@mixin inset($top: 0, $right: 0, $bottom: 0, $left: 0) {
top: $top;
right: $right;
bottom: $bottom;
@stevedya
stevedya / tidytext.R
Last active May 5, 2020 23:40
Tidy Text Example in R Stripping out numeric, punc, and replace words
library(dplyr)
library(tidytext)
library(ggplot2)
data <- read.csv('/Users/steven/Desktop/JEOPARDY_CSV.csv')
text_set <- iconv(data$Question, to = "utf-8-mac")
clean_text <- text_set %>%
as_tibble() %>%
unnest_tokens(word, value, to_lower = TRUE, strip_punct = TRUE, strip_numeric = TRUE) %>%
function isVisible (ele) {
const { top, bottom } = ele.getBoundingClientRect();
const vHeight = (window.innerHeight || document.documentElement.clientHeight);
return (
(top > 0 || bottom > 0) &&
top < vHeight
);
}
@stevedya
stevedya / smoothscroll.js
Created December 30, 2019 20:52
Smooth Scroll to ID with pure javascript
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
@stevedya
stevedya / select-sort.py
Created July 12, 2019 17:50
select sort example
def selectSort(nums):
for i in range(5):
minpos = i
for j in range(i, 6):
if nums[j] < nums[minpos]:
minpos = j
temp = nums[i] #hold old value
nums[i] = nums[minpos] #put new min value where old one was
nums[minpos] = temp #put old value where min used to be
@stevedya
stevedya / bubble-sort.py
Created July 12, 2019 17:49
bubble sort example
def sort(nums):
for i in range(len(nums) - 1, 0, -1):
for j in range(i):
if nums[j] > nums[j + 1]:
temp = nums[j]
nums[j] = nums[j + 1]
nums[j + 1] = temp
nums = [5, 3, 8, 6, 7, 2]
$(document).ready(function () {
var creditCardField = $('#card-element');
creditCardField.on('keyup', function () {
//Turn card number into string for substring method
var creditCardString = creditCardField.val().toString();
if (creditCardString.length < 2) {
//Hide all cards
@stevedya
stevedya / youtube-vimeo-video-id-regex.py
Created March 15, 2019 15:45
Using regex this gist will return video ID's from strings
import re
# Vimeo
vimeo_url = 'https://vimeo.com/56282283'
# Regex to strip id from video string
match_pattern = r'^(?:https?:)?(?:\/\/)?(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)'
response = re.search(match_pattern, url).group(3)
if response:
print (response)