Skip to content

Instantly share code, notes, and snippets.

View codeepic's full-sized avatar

codeepic

View GitHub Profile
const sleep = (ms, data, useReject) => {
return new Promise((resolve, reject) =>
setTimeout(() => {
if (useReject) {
reject(data);
}
return resolve(data);
}, ms)
);
};
@codeepic
codeepic / README.MD
Created June 9, 2022 22:14 — forked from JohnDinhDev/Reset Udemy Progress.md
Reset Udemy Progress

Reset Udemy Progress

Last Updated: 02/11/2022

Step 1. Go to Udemy course in browser

Go to the course and have any video up. The following code relies on the right sidebar to be visible to uncheck all your progress.

Step 2. Open browser console

You can do this with ctrl+shift+j and making sure the console tab is selected for chrome/brave

@codeepic
codeepic / machine.js
Created September 6, 2021 22:58
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@codeepic
codeepic / package.json
Created April 26, 2021 23:02 — forked from kentcdodds/package.json
setup script for my workshops
{
"name": "workshop-setup",
"version": "1.0.0",
"description": "This is the common setup script for most of my workshops",
"bin": "./setup.js"
}
@codeepic
codeepic / angular-subsriibe-to-window-resize.ts
Created August 5, 2020 09:52
How to subscribe to window resize event in Angular using RxJS.
subscribeToWindowResize(): void {
// maybe this could be run outside Angular
// https://blog.bitsrc.io/the-principles-for-writing-awesome-angular-components-10e45f9ae77e
fromEvent(window, 'resize')
.pipe(
debounceTime(1000),
tap(() => this.redrawChart()),
takeUntil(this.cmpDestroyed$)
)
.subscribe();
@codeepic
codeepic / publickey-git-error.markdown
Last active July 8, 2020 13:26 — forked from adamjohnson/publickey-git-error.markdown
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@codeepic
codeepic / date-fns-date-adapter.ts
Created August 30, 2019 11:35 — forked from JoniJnm/date-fns-date-adapter.ts
date-fns angular material adapter
import {Injectable} from '@angular/core';
import {DateAdapter} from '@angular/material';
import {addDays, addMonths, addYears, format, getDate, getDaysInMonth, getMonth, getYear, parse, setDay, setMonth, toDate} from 'date-fns';
// CONFIG. Use environment or something for a dynamic locale and settings
import {es as locale} from 'date-fns/locale';
const WEEK_STARTS_ON = 1; // 0 sunday, 1 monday...
export const MAT_DATE_FNS_DATE_FORMATS = {
/*
* this will ensure that the page doesn't jump left and right when
* navigating between the pages with and without the scrollbar
*/
html {
overflow-x: hidden;
width: 100vw;
}
@codeepic
codeepic / memoize.js
Created July 31, 2019 09:45
Memoize - function that memoizes other functions.
/**
* @param fn - a pure (no side effects) function you want to memoize
* if you run a memoized function again with the same arguments,
* it will return the cached result instead of running the computation
*/
const memoize = fn => {
const cache = {};
return (...args) => {
const key = JSON.stringify(args);
@codeepic
codeepic / allow-origins-headers.ts
Last active April 15, 2019 10:58
Angular HTTP Allow Origins
const headers = new HttpHeaders()
.set('Content-Type', 'application/json')
.set('Access-Control-Allow-Origin', '*')
.set('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers');