Skip to content

Instantly share code, notes, and snippets.

@jimimaher
jimimaher / settings.json
Created September 23, 2021 13:37
vscode user settings
{
"workbench.colorTheme": "Night Owl (No Italics)",
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.alwaysShowStatus": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.updateImportsOnFileMove.enabled": "always",
"editor.tabSize": 2,
"editor.formatOnSave": true,
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export YVM_DIR=/usr/local/opt/yvm
[ -r $YVM_DIR/yvm.sh ] && . $YVM_DIR/yvm.sh
#test
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/james.maher/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
@jimimaher
jimimaher / floatToString
Created March 14, 2021 11:48
Convert a number to a string without using a one line cast (e.g. number + "")
function floatToString(number) {
function getDecimals(number) {
if (!isFinite(number)) return 0;
let exponent = 1;
let p = 0;
while (Math.round(number * exponent) / exponent !== number) {
exponent *= 10;
p++;
}
return p;
@jimimaher
jimimaher / batchRemoveCharFilename.js
Last active December 1, 2017 16:35
Gulp batch remove character in filename
//Below example is to replace `_` in non-vendor `.scss` files.
var gulp = require('gulp');
var del = require('del');
var rename = require('gulp-rename');
gulp.task('cloneFilesWithoutChar', function(){
return gulp.src([
'/**/*.scss', //example
'!/**/vendor/**'
])
@jimimaher
jimimaher / scrollByDrag.js
Created October 9, 2017 15:20
Scroll by dragging plugin
/*
scrollByDrag
Purpose:
Detect how many pixels a user "drags an element" - more specifically, how many pixels a user moves their mouse between mousing down on an element and mousing up.
Parameters:
Container:
parent element containing .drag-element and .drag-content
Type:
@jimimaher
jimimaher / HomeController.js
Created March 23, 2017 03:49
Sniff for user scroll position, fire things once section enters screen
var HomeController = (function(){
var
sections,
sectionsArray,
scrollTicking = false,
scrollAnimationClass = "pre_animate",
latestKnownScrollY
;
@jimimaher
jimimaher / VideoLoop.js
Last active March 23, 2017 03:47
Video Loop with Logo Titles
// Idea here is to have a background video looping different clips
// Each clip has a logo/title element that needs to be positioned separately from the video,
// and each logo/title must only show while its clip is on screen.
var intro = document.getElementById('_intro');
//begin loading video to be able to listen for 'canplaythrough' event
intro.querySelector('video').load();
//canplaythrough chosen to prevent (as much as possible) video buffering
@jimimaher
jimimaher / gist:d8b0c901f111474c69f6
Last active August 29, 2015 14:24
Image Swapper
// example HTML:
// <img class="background-image" src="images/mobile/everydaycare.jpg">
// Description: Serve mobile image first, and swap directory if page is desktop
function setImagesThenPostImageLoad() {
var $bgImages = $('.background-image');
var loadCount = 0;
$('img.background-image').each(function(){
var str = $(this).attr('src');