Skip to content

Instantly share code, notes, and snippets.

@necojackarc
necojackarc / JavaScript DateOnly and TimeOnly classes.md
Last active July 27, 2018 09:45
JavaScript DateOnly and TimeOnly classes
'use strict';

const moment = require('moment');

class DateOnly {
  /**
   * @param {moment|Date|string} input an object or a string moment.js can parse
   */
  constructor(input) {

To use AWS Lambda (Serverless) with RDS in production, you should

  • warm up functions
  • preserve DRS connections

configure_handlers.js configures Serverless handler functions to achieve them.

Usage

Easy to check which branches will be deleted by removing at the bottom of | sh :)

git branch -r --merged master | sed -e 's#origin/#:#g' | egrep -v 'master|release|ADD BRANCH NAMES YOU WANT TO LEAVE' | sed 's/^/git push origin'/g | sh
@necojackarc
necojackarc / format_url.js
Last active September 25, 2019 16:29
Format URL function that can be partially applied made for fun!
'use strict';
const qs = require('qs');
function format_url(base) {
const remove_trailing_slash = (element) => {
return element.endsWith('/') ? element.slice(1, -1) : element;
};
const remove_leading_slash = (element) => {

Describes what I always do when installed PostgreSQL.

  1. Create new user who has the same power as postgres
  2. Change login method when connecting it via host names

1. Create new user who has the same power as postgres

Connect postgres DB as postgres user:

@necojackarc
necojackarc / .eslintrc.js
Last active December 23, 2020 19:34
My ESLint configuration
module.exports = {
parserOptions: {
ecmaVersion: 2020,
},
env: {
es6: true,
},
root: true,
extends: 'eslint:recommended',
rules: {

This instruction will store the source in /usr/local/src following the linux convention.

$ sudo apt update
$ sudo apt install libssl-dev autoconf automake libtool python-setuptools python-dev
$ cd /usr/local/src
$ sudo git clone https://github.com/facebook/watchman.git
$ cd watchman
$ sudo git checkout v4.9.0  # the latest stable release
$ sudo ./autogen.sh

Following the official guide, you'll bump into the following error:

$ sudo zypper ref
Repository 'Google-Chrome' is up to date.
Retrieving repository 'Yarn' metadata --------------------------------------------------------------------------------------------------------------------------------------------------------------------------[\]
Warning: File 'repomd.xml' from repository 'Yarn' is signed with an unknown key '9CBBB5586963F07F'.

    Note: Signing data enables the recipient to verify that no modifications occurred after the data
    were signed. Accepting data with no, wrong or unknown signature can lead to a corrupted system
@necojackarc
necojackarc / active_job_retry_controlable.rb
Last active June 30, 2021 13:20
To enable ActiveJob to control retry
module ActiveJobRetryControlable
extend ActiveSupport::Concern
DEFAULT_RETRY_LIMIT = 5
attr_reader :attempt_number
module ClassMethods
def retry_limit(retry_limit)
@retry_limit = retry_limit
@necojackarc
necojackarc / GitHub Cli One-liner to Add Collaborators to All Repos.md
Last active January 26, 2023 16:02
GitHub CLI one-liner to add all repos in the organisation to a specific user or team

Conditions

# 50 is the number of repositories to be listed
gh repo list -L 50 <organisation> | \
 awk '{print $1}' | \