Skip to content

Instantly share code, notes, and snippets.

@phuctm97
phuctm97 / get-webpack-alias-from-tsconfig.js
Last active November 2, 2022 06:32
📎 Get Webpack alias from tsconfig.json, aka. convert tsconfig.json paths to Webpack alias
const path = require('path');
/**
* Helper function infers Webpack aliases from tsconfig.json compilerOptions.baseUrl and
* compilerOptions.paths.
*
* @param {string} tsconfigPath - Path to tsconfig.json (can be either relative or absolute path).
* @return {object} An object representing analogous Webpack alias.
*/
module.exports = (tsconfigPath = './tsconfig.json') => {
@Jackzmc
Jackzmc / start.sh
Last active February 9, 2024 01:52
Minecraft spigot server auto restart watchdog script.
#!/bin/bash
JAR=$(find -type f -name 'paper-*.jar' -printf %f\\n | sort | head -1)
echo Found jar: ${JAR}
while true; do
java -server -Xms1G -Xmx1G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar ${JAR}
echo "";
for i in {5..1}; do
echo "Server has stopped. Auto-restarting in $i seconds. Ctrl+C to cancel." && sleep 1;
done
sleep 1;
@NigelEarle
NigelEarle / Knex-Setup.md
Last active May 4, 2024 13:36
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
@xpcmdshell
xpcmdshell / Hooky.cpp
Created June 3, 2017 04:19
Application Verifier Basics
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "prio.h"
//Convenient define for the fdwReason
#define VERIFIER_LOAD 4
/*
Prototypes for additional event callbacks (dll load, unload, and heap free). If you wanted to, you could respond to these events. We will
@hackedunit
hackedunit / install-redis.md
Last active October 11, 2023 12:37
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
@mikoim
mikoim / README.md
Last active April 27, 2024 00:22
[Updated! Aug 14 2020] YouTube recommended encoding settings on ffmpeg (+ libx264)

Parameters

Container: MP4

Parameter YouTube recommends setting
-movflags faststart moov atom at the front of the file (Fast Start)

Video codec: H.264

@magnetikonline
magnetikonline / README.md
Last active September 21, 2022 05:34
Node.js HTTP receiving request dump server.

Node.js HTTP receiving request dump server

HTTP server which receives requests and dumps them to a flat file.

Usage

Start HTTP server:

$ nodejs ./httprequestdump.js
@dsherret
dsherret / Using.ts
Last active October 26, 2023 13:30
Typescript Disposable (using statement)
// NOTE: This is now rolled up in a package and supports more scenarios: https://github.com/dsherret/using-statement
interface IDisposable {
dispose();
}
function using<T extends IDisposable>(resource: T, func: (resource: T) => void) {
try {
func(resource);
} finally {
@liabru
liabru / json-limit-precision.js
Last active May 3, 2023 07:45
Limit precision of floating point numbers in a JSON string in JavaScript
var testObject = {
pi: Math.PI,
e: Math.E,
one: 1,
x: 1.5,
str: "1.2345"
};
var places = 2,
json = JSON.stringify(testObject, function(key, value) {
@kitek
kitek / gist:1579117
Created January 8, 2012 17:50
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");