Skip to content

Instantly share code, notes, and snippets.

@x-yuri
x-yuri / mongo + docker.md
Last active March 29, 2024 08:47
mongo + docker

mongo + docker

mongo >= 6: init-mongo.js + MONGO_INITDB_DATABASE in .env-mongo
mongo < 6: init-mongo.sh + no MONGO_INITDB_DATABASE in .env-mongo

.env:

MONGO_USER=user
MONGO_PASSWORD=userpasswd
@kentcdodds
kentcdodds / autofill-feedback-email.js
Last active April 19, 2023 04:59
I use this to automatically fill in email addresses in feedback forms throughout workshop material
#!/usr/bin/env node
const path = require('path')
const inquirer = require('inquirer')
const replace = require('replace-in-file')
const isCI = require('is-ci')
const spawn = require('cross-spawn')
const fileGlob = process.argv[2] || 'src/**/*.*'
const files = path.isAbsolute(fileGlob)
@silver-xu
silver-xu / ts-boilerplate.md
Last active May 3, 2024 14:01
Setup a Node.js project with Typescript, ESLint, Prettier, Husky

Setup a Node.js project with Typescript, ESLint, Prettier, Husky

1_D8Wwwce8wS3auLAiM3BQKA

Starting a personal node project could be easy; starting a team node project could be challenging.

I am a developer currently working in SEEK Australia.

In my experience, common mistakes developer make when starting a projects are:

  • No Linting
@ibqn
ibqn / mailserver-howto.md
Last active January 24, 2023 15:00
Email server based on Dovecot, Postfix, MySQL, Rspamd and Debian 9 Stretch

Email server based on Dovecot, Postfix, MySQL, Rspamd and Debian 9 Stretch

MySQL database setup

Install MariaDB as a database management system DBMS

sudo apt install mariadb-server

Create a new database named srvmail for a mail server:

@mrk-han
mrk-han / emulator-install-using-avdmanager.md
Last active May 1, 2024 21:12
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For an emulator that mimics a Pixel 5 Device with Google APIs and ARM architecture (for an M1/M2 Macbook):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-30;google_atd;arm64-v8a"

@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@airyboy
airyboy / keybindings.json
Created November 8, 2018 06:50
entries to use alt+j, alt+k for intellisense in VSCode
{
"key": "alt+k",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "alt+j",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
}
sudo apt install -y autoconf automake build-essential python-dev libtool libssl-dev pkg-config
cd /tmp
git clone https://github.com/facebook/watchman.git -b v4.9.0 --depth 1
cd watchman/
./autogen.sh
./configure --enable-lenient
make
sudo make install
@joepie91
joepie91 / random.md
Last active May 5, 2024 06:33
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@thejmazz
thejmazz / app.js
Created September 20, 2016 17:58
mapbox-gl-js + webpack issues
// thanks sleepycat https://github.com/sleepycat/mapboxgl-webpack-example
import mapboxgl from 'mapbox-gl'
mapboxgl.accessToken = 'pk.eyJ1IjoibWlrZXdpbGxpYW1zb24iLCJhIjoibzRCYUlGSSJ9.QGvlt6Opm5futGhE5i-1kw';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v8', //stylesheet location
center: [-74.50, 40], // starting position
zoom: 9 // starting zoom