Skip to content

Instantly share code, notes, and snippets.

View LunaSquee's full-sized avatar

Evert Prants LunaSquee

View GitHub Profile
@navjotahuja92
navjotahuja92 / setup.ts
Last active February 2, 2024 15:11
Nest.js Test Setup with In Memory Postgres Database (pg-mem)
// Install npm i pg-mem --save-dev
import { DataSource, Repository } from 'typeorm';
import { newDb, DataType } from 'pg-mem';
import { v4 } from 'uuid';
const setupDataSource = async () => {
const db = newDb({
autoCreateForeignKeyIndices: true,
});
@xposedbones
xposedbones / map.js
Last active May 1, 2024 11:15
Javascript Map range of number to another range
Number.prototype.map = function (in_min, in_max, out_min, out_max) {
return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
/**
* Converts YouTube formatted duration to seconds.
*
* Expects input String of the form "PT#M#S", in which the letters PT indicate
* that the value specifies a period of time, and the letters M and S refer to
* length in minutes and seconds, respectively. The # characters preceding the
* M and S letters are both integers that specify the number of minutes (or
* seconds) of the video. For example, a value of PT15M51S indicates that the
* video is 15 minutes and 51 seconds long.
*/
@daniel-j
daniel-j / interface.js
Last active January 2, 2018 19:04
Parasprite Radio files and utilities (for LiquidSoap and MPD)
#!/usr/bin/env node
var net = require('net');
var client = net.connect(1234, "localhost");
client.pipe(process.stdout);
client.on('connect', function () {
console.log("Connected!");
@mbostock
mbostock / .block
Last active March 10, 2019 08:11 — forked from mbostock/.block
The Sun’s View of the Earth
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/the-suns-view-of-the-earth
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 3, 2024 19:09
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: