Skip to content

Instantly share code, notes, and snippets.

@SuperPaintman
SuperPaintman / npm-f3-install.sh
Last active April 21, 2024 23:41
NPM install for low RAM machins. And "npm install ... killed" problem
#!/bin/bash
#
# Author: SuperPaintman <SuperPaintmanDeveloper@gmail.com>
#
###
# Constants
###
RETVAL=0
@joepie91
joepie91 / .md
Last active February 8, 2024 17:12
Running a Node.js application using nvm as a systemd service

Read this first!

Hi there! Since this post was originally written, nvm has gained some new tools, and some people have suggested alternative (and potentially better) approaches for modern systems. Make sure to have a look at the comments to this article, before following this guide!


The original article

Trickier than it seems.

@DavideMontersino
DavideMontersino / private-fork.md
Last active February 27, 2024 12:56
How to fork to a private gitlab instance

Theory:

your git repository can have more than one remote server; In this case we want to have two:

  1. one for our private repository on gitlab (will be the default one, called origin)
  2. one to be connected to the source repo on github, to be able to pull new changes (will be called upstream)

How to make a private fork from github to gitlab

@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@t-mart
t-mart / netrw quick reference.md
Last active March 25, 2024 07:47
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
@eshacker
eshacker / wrong_vs_right_oo_in_js.js
Last active March 2, 2016 07:24
Wrong versus right way to do OO in JS
/* Reading https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch1.html
* I have a differing opinion. Please help in sorting it out.
*/
// Original code : or I think wrong way to to Object Oriented code.
var Flock = function(n) {
this.seagulls = n;
};
@sedm0784
sedm0784 / _vim_auto_list.markdown
Last active May 29, 2023 15:43
Vim Automatic List Continuation

Vim Auto List Completion

This snippet makes Vim automatically continue/end lists in insert mode, similar to the way word processors do:

  • It automatically adds the bullet/number for the next list item when you press Return at the end of an existing item,
  • When you press Return on an empty list item, it removes the bullet/number, ending the list.

It supports ordered lists with markers like 1. and unordered lists with - markers (because those are the markers I use.)

(It's particularly useful when using an iOS keyboard where punctuation and numerals are slow to access.)

@matt40k
matt40k / Enable_CDC_On_All_Tables.sql
Created September 25, 2015 10:15
Enable CDC on all tables - Author: Rasmus Reinholdt Nielsen
USE [master]
GO
ALTER DATABASE [{{DATABASE-NAME}}]
ADD FILEGROUP CDC;
GO
ALTER DATABASE [{{DATABASE-NAME}}] ADD FILE
( NAME = N'{{DATABASE-NAME}}_CDC'
, FILENAME = N'{{SQL-DATA}}\MSSQL\DATA\{{DATABASE-NAME}}_cdc.MDF'
@acgourley
acgourley / gist:9a11ffedd44c414fb4b8
Last active January 21, 2022 06:37
Knex / MySQL Timeout Issue Postmortem

For several weeks our production deployment (Express, Bookshelf/Knex -> MySQL) was randomly having queries fail resulting in 500 errors and server crashes.

The first issue is that the Knex library was using Pool2 slightly incorrectly, and when a ETIMEDOUT error occurred, it tried to release the pooled connection twice. This would create an exception which would crash express (unless you have a top level error handler defined in your express setup)

In this issue (myndzi/pool2#12 (comment)) filed on pool2 by the author of knex (tgriesser) the author of pool2 (myndzi) points out the error handling issue and created a fork of knex with the fix git+https://github.com/myndzi/knex#double-release

After installing the fix on my server, whenever ETIMEDOUT occured an error would be generated in the expected part of the code so that I could decide to retry the query or fail gracefully. Removing the ETIMEDOUT entirely would be

@joepie91
joepie91 / promises-reading-list.md
Last active June 25, 2023 09:12
Promises (Bluebird) reading list

Promises reading list

This is a list of examples and articles, in roughly the order you should follow them, to show and explain how promises work and why you should use them. I'll probably add more things to this list over time.

This list primarily focuses on Bluebird, but the basic functionality should also work in ES6 Promises, and some examples are included on how to replicate Bluebird functionality with ES6 promises. You should still use Bluebird where possible, though - they are faster, less error-prone, and have more utilities.

I'm available for tutoring and code review :)

You may reuse all gists for any purpose under the WTFPL / CC0 (whichever you prefer).