Skip to content

Instantly share code, notes, and snippets.

View daleyjem's full-sized avatar

Jeremy Daley daleyjem

  • Cincinnati, Ohio
View GitHub Profile
@daleyjem
daleyjem / yarn-silent-update.md
Last active February 8, 2023 21:05
How to add a caret to package.json versions without getting latest semver match

It doesn't make sense upon initial description reading, but there is a use case for it... Updating a package.json dependency to use a caret without getting the latest semver match.

I'm currently working on a very large project, in which we would like to enforce exact version matches across all child workspace package.json files.

Understand that when I say child workspace packages, you mustn't assume this project is a monorepo that publishes its packages. It uses yarn workspaces simply for the benefit of doing non-relative-path imports:

import { thing } from 'internal-package-a'
// vs
@daleyjem
daleyjem / deep-imports.md
Last active August 7, 2023 07:07
Explanation of a "deep import"

Deep Imports

Description

A "deep import" is simply an ESM import that goes deeper than the package root:

import thingA from 'my-package-name/src/components/thingA'
import thingB from '@my-namespace/my-package-name/src/components/thingA'
@daleyjem
daleyjem / get-distinct-playlist-artists.js
Last active April 27, 2020 20:23
Get a distinct listing of all artists from a user's playlists using Apple Music API
const axios = require('axios')
const userToken = '<user token>'
const devToken = '<dev token>'
/**
* Gets a distinct array of the artists in a user's playlists
* @param {string} devToken The Apple-issued JWT developer token
* @param {string} userToken The returned Apple `musickit.authorize()` user token
*/
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
@NgModule({
imports: [
ServerModule,
AppModule
],
@daleyjem
daleyjem / LESS-SASS-Guidelines.md
Last active September 21, 2016 22:13
These are my personal preferences for keeping LESS/SASS code organized, modular and with low specificity.

LESS/SASS Guidelines

Structure. Structure. Structure

Make sure structure is organized and created in such a way that accommodates a large project by properly categorizing and modularizing folders and files. It’s better to feel that you’re over-engineering at the beginning, and restructure “down” later, than to assume a minimal set-up up front, simply for the sake of expediency.

Bad:

> less
	*all-of-the-files.less
@daleyjem
daleyjem / ClickStream.js
Last active January 23, 2024 17:30
A Veeva ClickStream helper class for page and event tracking. *Requires veeva-library.js
/**
* Veeva ClickStream tracking class.
*
* Author: Jeremy Daley
* Liscence: MIT
*/
ClickStream.prototype.virtualInterval = -1;
ClickStream.prototype.calls = []; // Queued calls
ClickStream.prototype.debug = false;
@daleyjem
daleyjem / git-commands.md
Last active March 17, 2020 02:13
Typical Git Commands

Git commands

Note: Always make sure you're in the project root when doing git commands, or else it won't see the .gitignore file and try to track files that should be ignored.

To reset your files back to the last commit:

git reset --hard HEAD

To create and checkout a new branch:

@daleyjem
daleyjem / eval.js
Created December 1, 2015 18:58
Handlebars Eval Helper
/**
* Evalutes a given expression by taking in a hash of variables as input values.
* ${variable} denotes a variable assigned in the hash.
*
* Example:
* {{eval "${a} + ${b}" a=1 b=2}}
* = 3
*/
module.exports.register = function(Handlebars, options) {
Handlebars.registerHelper('eval', function(expr, options) {
$(function(){
/** Constants **/
var ATTRIBUTE_PREFIX = 'track';
var ATTRIBUTE_EVENT_TYPE = "event-type"
var RESERVED_ATTRIBUTES = [
'events', // Reserved for Omniture
'eventType', // Reserved for client-side event type
'linkType', // Reserved for Omniture
'vars' // Reserved for Omniture
];
@daleyjem
daleyjem / css-lint-regex-search.md
Last active August 29, 2015 14:11
CSS Lint RegEx Search
ID or Class selectors with capital letter(s):
(\.|#)[^A-Z^\{^\s^/]*[A-Z]+[^\{^\s]*
Hard-coded hex values (3 or more characters):
#[A-Fa-f0-9]{3,}
Hard-coded @media query viewport numbers (i.e. 768px), instead of $variable
@media[^\{]+[0-9]+px[^\{]+\{
No space after colon in "attr:val;"