Skip to content

Instantly share code, notes, and snippets.

View goldingdamien's full-sized avatar

Damien Golding goldingdamien

View GitHub Profile
@cometkim
cometkim / index.mjs
Created March 25, 2022 16:55
Search all packages that doesn't support ESM from node_modules directory
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
const nodeModules = path.resolve('node_modules');
let moduleNames = await fs.readdir(nodeModules);
moduleNames = (await Promise.all(
moduleNames.map(async name => {
if (name.startsWith('.')) {
return [];
@micalevisk
micalevisk / show_last_modified_dates.sh
Last active July 23, 2023 23:12
Display the last modified date of every package on package.json dependencies list using npm-view (https://docs.npmjs.com/cli/v7/commands/npm-view)
#!/bin/bash
## (c) 2022 Micael Levi L. C.
## This script requires:
## - npm (https://nodejs.org)
## - jq (https://stedolan.github.io/jq)
file="${1:-./package.json}"
[ -r "$file" ] || { echo "The file $file is not readable" ; exit 1 ; }

Cheat sheet: JavaScript Array methods

Deriving a new Array from an existing Array:

['■','●','▲'].slice(1, 3)           ['●','▲']
['■','●','■'].filter(x => x==='■')  ['■','■']
    ['▲','●'].map(x => x+x)         ['▲▲','●●']
    ['▲','●'].flatMap(x => [x,x])   ['▲','▲','●','●']
@ankitsadariya
ankitsadariya / geolocation.js
Created February 2, 2021 07:07
set geolocation for website using puppeteer
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ devtools: true });
const page = await browser.newPage();
// Grants permission for changing geolocation
const context = browser.defaultBrowserContext();
await context.overridePermissions('https://www.google.com/', ['geolocation']);
@Deathspike
Deathspike / Controller.ts
Last active March 28, 2023 08:06
nestjs response validation example (using express)
import * as app from '.';
import * as api from '@nestjs/common';
@api.Controller()
export class TestController {
@api.Get()
@app.ResponseValidator(app.TestDto)
get() {
return new app.TestDto();
}
@jjcodes78
jjcodes78 / nextjs-deploy.md
Last active September 19, 2024 06:16
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw

@theodorosploumis
theodorosploumis / Nework_throttling_profiles.md
Last active November 8, 2024 12:01
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
@rhaglennydd
rhaglennydd / README.md
Last active May 4, 2024 17:47
Custom jQuery Build for a Webpack Flow

Custom jQuery Build for a Webpack Flow

Why?

Sometimes you don't need all of jQuery's modules. Officially, you can use their Grunt script to build a slimmed-down jQuery, but what if Webpack is more your thing? Enter this guide.

The Steps

  1. From your project root, install jQuery as a dev dependency:
@alimozdemir
alimozdemir / fabric-history.js
Last active December 12, 2023 11:55
Fabricjs basic history implementation
fabric.Canvas.prototype.historyInit = function () {
this.historyUndo = [];
this.historyNextState = this.historyNext();
this.on({
"object:added": this.historySaveAction,
"object:removed": this.historySaveAction,
"object:modified": this.historySaveAction
})
}
@Ciantic
Ciantic / example-typeorm-jest.test.ts
Created April 16, 2019 17:50
Example of testing TypeOrm with Jest and Sqlite in-memory database
import { createConnection, getConnection, Entity, getRepository } from "typeorm";
import { PrimaryGeneratedColumn, Column } from "typeorm";
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn()
id?: number;
@Column()
name?: string;