Skip to content

Instantly share code, notes, and snippets.

@robertolos
robertolos / docker-compose.yml
Created January 3, 2024 17:23
docker-compose mongodb
version: "3"
services:
db:
image: mongo
restart: always
ports:
- 27017:27017
environment: #env variables to pass into the container
MONGODB_DATABASE: nest-course
@robertolos
robertolos / gist:236c9edd603c716f35d9e4cfe2bb37fb
Created December 21, 2023 14:46
Headless setup raspberry using Raspberry PI Manager from Mac
1. Write Raspberry PI OS to an SD card using Raspberry PI Manager.
2. Create a file named user userconf (or userconf.txt) containing the following:
Code:
`pi:$6$c70VpvPsVNCG0YR5$l5vWWLsLko9Kj65gcQ8qvMkuOoRkEagI90qi3F/Y7rm8eNYZHW8CY6BOIKwMH7a3YYzZYL90zf304cAHLFaZE0`
3. Place userconf (or userconf.txt) plus an empty file named ssh (or ssh.txt) in the BOOT (FAT32) partition of the SD card.
4. Insert the SD card in the Raspberry Pi and it should boot with access to user 'pi' (password : raspberry) via SSH.
@robertolos
robertolos / postgres-cheatsheet.md
Created November 10, 2023 16:49 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@robertolos
robertolos / initTypescriptProject.sh
Created June 29, 2023 22:08
Initialise a new node project with typescript
# Initialise a new node project with typescript
# usage:
# > ./initTypescriptProject.sh my-app-name
PROJECT_NAME=$1
mkdir $PROJECT_NAME
cd $PROJECT_NAME
npm init -y
yarn add --dev typescript ts-node nodemon rimraf @types/node jest
@robertolos
robertolos / moduleMock.ts
Last active December 19, 2022 23:15
Module mocking in ESM
// # https://jestjs.io/docs/ecmascript-modules#module-mocking-in-esm
// #### module.ts ####
import { getData } from "./submodule";
export const myModule = () => {
return getData();
};
// #### submodule.ts ####
@robertolos
robertolos / psportkill.sh
Last active April 30, 2022 08:22
Kills process running on port
# Add to .bashrc or .zshrc
psportkill() {
if [ $# -eq 0 ]
then
echo "Missing port number. Usage: psportkill 5000"
exit 1
fi
echo "Killing process on port $1"
lsof -i 4tcp:$1 -sTCP:LISTEN | awk '{if(NR>1)print $2}' | xargs kill
if [ $? -eq 0 ]
@robertolos
robertolos / gist:acbb1f9692a3e598a67117b6048f7034
Created April 14, 2022 07:05
Kill process running on port 3000
lsof -i 4tcp:3000 -sTCP:LISTEN | awk '{if(NR>1)print $2}' | xargs kill
@robertolos
robertolos / spinDownHd
Created September 6, 2018 08:20
Spin down usb hard drive
# activate the script via crontab as root user
# */5 * * * * /home/roberto/script/spinDownHd2 > /home/roberto/logspindown
DISK=sda
echo "start"
SGSTART=/usr/bin/sg_start
if [ ! -x $SGSTART ]
then
echo "$SGSTART missing. aborting."
exit 1
@robertolos
robertolos / GoogleResource.java
Created May 19, 2018 09:12
Serve Google assetlinks.json using spring boot
package com.adaptyou.wama.server.web.rest;
import com.codahale.metrics.annotation.Timed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@robertolos
robertolos / git-bulk-branches-remove
Last active January 17, 2018 10:41
Bulk remove of git branches from local and remote
#removes all the branch starting with HP-14
git branch -a | awk -F/ '/\/HP-14/{print $3}' | xargs -I {} git push origin :{}