Skip to content

Instantly share code, notes, and snippets.

View DevEarley's full-sized avatar
🎯
Focusing

Alex Earley DevEarley

🎯
Focusing
View GitHub Profile
@DevEarley
DevEarley / first-class-functions.md
Last active September 11, 2019 18:02
First-Class Functions in JavaScript

First-Class Functions in JavaScript

What is a First-Class Citizen?

An entity that supports being passed as an argument, is mutable, can be assigned to a variable or returned from a function.

Functions as arguments

For example:

function sumOperation(values){
	const total = 0;
	values.forEach(x=> total += x);
@DevEarley
DevEarley / regExMatch_toLowerCase.js
Last active April 20, 2020 01:24
RegEx for matching lower case values
this.filteredItems = this.listOfItems.filter(textToMatch => {
let regExMatch = new RegExp(sourceText.toLowerCase(), "g");
const result = textToMatch.toLowerCase().match(regExMatch)
return result != null && result.length > 0;
});
@DevEarley
DevEarley / image-copy.cmd
Created August 28, 2019 16:17
Recursively get all images in a directory and copy to another folder.
for /R "C:\source\" %%G in (*.png *.jpg *.jpeg *.gif *.svg) do copy "%%G" "C:\target\"
@DevEarley
DevEarley / image-copy.cmd
Created August 28, 2019 16:17
Recursively get all images in a directory and copy to another folder.
for /R "C:\source\" %%G in (*.png *.jpg *.jpeg *.gif *.svg) do copy "%%G" "C:\target\"
@DevEarley
DevEarley / sym-linked-node-modules.md
Last active August 2, 2019 19:41
Setting up a single node_modules folder for all of your angular apps.

Navigate to the folder where you would like to store node_modules. In this example I will use the %userprofile% shortcut.

I am building an Angular app. So in another temp directory I created a dummy app and copied it's package.json and its node_modules folder into my User Profile directory.

Create a cmd file that contains the following.

mklink "./node_modules" "%userprofile%/node_modules"

Now you can run that command anywhere you need those node_modules.

@DevEarley
DevEarley / run-cli-locally.md
Last active July 1, 2019 15:13
Running Specific version of Angular/CLI locally (not globally)

Why would you need this? Perhaps you need to build libraries for an old app. This way you can get all of the correct packages (and their peer dependencies) without installing an old version of the CLI globally.

First delete the global version of Angular CLI (this step sucks, I know...)

npm uninstall -g @angular/cli

Next use NPX to run any version of the CLI that you need. In this case, version 6.0.1 (Angular v6 has an issue with RXJS, you will need to change the rxjs version from "^6.0.0" to "6.0.0" in packages.json and reinstall it with npm.)

npx -p @angular/[email protected] ng new hello-world
@DevEarley
DevEarley / angular-tips-routing.md
Last active April 3, 2019 18:30
Angular Routing Tips

Get values from ActivatedRoute

class MyComponent {
  constructor(route: ActivatedRoute) {
    const id: string = route.snapshot.params.id;
    const user = route.snapshot.data.user;
    const parentId = route.snapshot.parent.paramMap.get("id")
  }
}
@DevEarley
DevEarley / yarn.sh
Created March 4, 2019 17:41
Use Yarn with Angular
ng config -g cli.packageManager yarn
@DevEarley
DevEarley / marquee.scss
Created December 18, 2018 01:45
marquee
$scroll-time:15s;
.marquee {
display: inline-block;
padding-left: 100%;
animation: marquee $scroll-time linear infinite;
}
@keyframes marquee {
0% { transform: translate(0, 0); }
@DevEarley
DevEarley / show-grid.scss
Last active January 14, 2019 00:10
Show Grid!
/*!
Show Grid - Hides stuff depending on your window's width.
DevEarley - 2019
*/
$xs: 0;
$sm: 576px;
$md: 768px;
$lg: 992px;
$xl: 1200px;