Skip to content

Instantly share code, notes, and snippets.

View radum's full-sized avatar
🚀
I can see what you see not

Radu Micu radum

🚀
I can see what you see not
View GitHub Profile
@radum
radum / myAngular.html
Created November 2, 2024 22:10 — forked from faustinoaq/myAngular.html
Front-end libraries (React, Vue, Angular) and the basic principles of how they work, all in a single file using pure JavaScript (VanillaJS).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Angular from Scratch</title>
<style>
.my-component {
font-family: Arial, sans-serif;
@radum
radum / dom3d.js
Created April 6, 2024 14:35 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@radum
radum / esm-package.md
Created June 18, 2023 20:07 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@radum
radum / shell-best-practices.md
Created November 2, 2022 11:51
Shell Script Best Practices

Use bash. Using zsh or fish or any other, will make it hard for others to understand / collaborate. Among all shells, bash strikes a good balance between portability and DX.

Just make the first line be #!/usr/bin/env bash, even if you don’t give executable permission to the script file.

Use the .sh (or .bash) extension for your file. It may be fancy to not have an extension for your script, but unless your case explicitly depends on it, you’re probably just trying to do clever stuff. Clever stuff are hard to understand.

Use set -o errexit at the start of your script.

So that when a command fails, bash exits instead of continuing with the rest of the script. Prefer to use set -o nounset. You may have a good excuse to not do this, but, my opinion, it’s best to always set it.

@radum
radum / video4web.sh
Created May 13, 2021 08:24 — forked from mfd/ffmpeg.md
video4web
#!/bin/bash
# Generates a cover image along with mute web-ready WebM and MP4 files for each master video in a folder.
# See: https://gist.github.com/jaydenseric/220c785d6289bcfd7366.
# Parameter 1: Input video format (e.g. "mov").
# Parameter 2: Output width in pixels (e.g. "1280").
# Example use: "./video4web.sh mov 1280".
mkdir web
/**
* A bookmarklet for viewing the largest contentful paint in a page.
* Will show each LCP after the bookmarklet is clicked.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
javascript:(function(){
try {
@radum
radum / perf-diagnostics.css
Created January 22, 2021 21:28 — forked from tkadlec/perf-diagnostics.css
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====

What Hiring Should Look Like

This is definitely not the first time I've written about this topic, but I haven't written formally about it in quite awhile. So I want to revisit why I think technical-position interviewing is so poorly designed, and lay out what I think would be a better process.

I'm just one guy, with a bunch of strong opinions and a bunch of flaws. So take these suggestions with a grain of salt. I'm sure there's a lot of talented, passionate folks with other thoughts, and some are probably a lot more interesting and useful than my own.

But at the same time, I hope you'll set aside the assumptions and status quo of how interviewing is always done. Just because you were hired a certain way, and even if you liked it, doesn't mean that it's a good interview process to repeat.

If you're happy with the way technical interviewing currently works at your company, fine. Just stop, don't read any further. I'm not going to spend any effort trying to convince you otherwise.

@radum
radum / git_examples.sh
Last active December 23, 2023 13:58
this script creates repos in a sandbox directory and uses them for demos -
#!/usr/bin/bash
##########
# contents
# https://bitbucket.org/BitPusher16/dotfiles/src/1777024d574c2245193687bd632d056ded41287e/refs/git/git_examples.sh?at=master
##########
# contents
# notes
# script setup
@radum
radum / FALLBACK-IMAGE.js
Last active November 25, 2019 11:49
Request With Intent Caching Strategies in the age of PWAs
// KEEP A FALLBACK IMAGE IN YOUR BACK POCKET
// Assuming you want to use a fallback in more than one networking recipe,
// you can set up a named function that will respond with that resource:
function respondWithFallbackImage() {
return caches.match( "/i/fallbacks/offline.svg" );
}
// Then, within a fetch event handler, you can use that function to provide that fallback image
// when requests for images fail at the network: