Skip to content

Instantly share code, notes, and snippets.

@phukon
phukon / readme
Created October 13, 2025 19:03 — forked from antonlvovych/readme
NVM on fish shell using bass
# Install NVM manually (https://github.com/creationix/nvm)
# Install bass (https://github.com/edc/bass)
# Add code below to your config.fish
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
nvm use default --silent

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Create Free AWS Account

Create free AWS Account at https://aws.amazon.com/

2. Create and Lauch an EC2 instance and SSH into machine

I would be creating a t2.medium ubuntu machine for this demo.

The easiest way to set up absolute paths in your TypeScript Node.js project

Step-by-step guide. Works with Nest.js, Express.js or any other Node.js project. I'm going to show you how to do this quickly and easily, so let's get started.


Configure absolute paths

  1. Initialize the new package in the terminal if you haven't already done so:
@phukon
phukon / nativeJavaScript.js
Created April 28, 2024 08:52 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@phukon
phukon / DOM3D.js
Created March 27, 2024 13:53 — 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; // ¯\\_(ツ)_/¯
@phukon
phukon / gscript.gs
Created March 11, 2024 12:06
Google doc as html content dynamically
function doGet(e){
let id = '1fK1zbSNw7jZuEB14iS8n6t9p7PV4tFQW8fJpnJMpFWA';
if('id' in e.parameter){
id = e.parameter['id']
}
let html = '<h1>Laurence Svekis</h1>';
const url = 'https://docs.google.com/feeds/download/documents/export/Export?id='+id+'&exportFormat=html';
const param = {
method :"get",
headers : {
@phukon
phukon / 2019-https-localhost.md
Created March 2, 2024 11:38 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@phukon
phukon / what-forces-layout.md
Created January 27, 2024 03:59 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@phukon
phukon / useLocalStorage.ts
Created December 17, 2023 14:36
React Hook to use local storage
export const useLocalStorage = (key: string) => {
const setItem = (value: unknown) => {
try {
window.localStorage.setItem(key, JSON.stringify(value))
} catch (error) {
console.log(error)
}
}
const getItem = () => {