Skip to content

Instantly share code, notes, and snippets.

@Vinorcola
Vinorcola / AnchorScroller.tsx
Last active March 2, 2022 08:04
React Router Anchor Scroller component
import { ReactNode, useEffect } from "react"
import { useLocation } from "react-router-dom"
interface Props {
children: ReactNode
}
export default function AnchorScroller(props: Props) {
let location = useLocation()
@Vinorcola
Vinorcola / README.md
Last active February 22, 2024 13:46
Auto upgrade Gitlab instance on Docker

Gitlab upgrade script

This script is a Node.js script for upgrading a Gitlab instance run on Docker. (tested with Node.js v14, but should run OK with some lower version - if someone can advise in the comments)

If you followed the Gitlab documentation to launch a Gitlab instance (https://docs.gitlab.com/ce/install/docker.html) by using the following command:

sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
@Vinorcola
Vinorcola / README.md
Created June 27, 2020 12:18
Install PostgreSQL pg_similarity on Ubuntu

Install PostgreSQL pg_similarity extension on Ubuntu

1. Install the package

For PostgreSQL version 12.

sudo apt update
sudo apt install postgresql-12-similarity
@Vinorcola
Vinorcola / Child.jsx
Created December 26, 2015 19:56
React - Change children props recursively
'use strict'
var React = require('react')
var Child = React.createClass({
render: function()
@Vinorcola
Vinorcola / buffer.js
Created September 22, 2015 22:08
Node - buffer with native promises
'use strict'
var config = {
bufferMaxSize: 1,
}
var _pushPromise
@Vinorcola
Vinorcola / README.md
Last active November 2, 2015 21:01
Node - pg with native promises (pattern)

Use Promises with PostgreSQL in Node

This pattern is a pattern I use for all my Node projects that need PostgreSQL. I work a lot with Promises, and ended-up designing this db.js file.

Put this file wherever you want in your app directory. Edit the connectionInfo string and voilà!

Call the execute method passing a callback function. Your callback function will be called with a function as first parameter which will allow you to execute SQL queries retourning Promises. Execute as much queries as you want, but don't forget to return a Promise that must be resolved once all your queries are done. After that, the database connection will be properly closed automatically.