Skip to content

Instantly share code, notes, and snippets.

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

@roberthamel
roberthamel / docker-swarm-gpu.md
Created November 4, 2022 18:02 — forked from tomlankhorst/docker-swarm-gpu.md
Instructions for Docker swarm with GPUs
@roberthamel
roberthamel / code.sh
Created October 3, 2022 12:28 — forked from tallguyjenks/code.sh
ZettelKasten Sync Code
# To permanently cache the credentials
git config --global credential.helper store
# To ignore files that could cause issues across different workspaces
touch .gitignore
echo ".obsidian/cache
.trash/
.DS_Store" > .gitignore
@roberthamel
roberthamel / dnsmasq OS X.md
Created May 20, 2022 03:48 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@roberthamel
roberthamel / full_upsert.py
Last active May 18, 2022 19:44 — forked from nirizr/full_upsert.py
sqlalchemy upsert
def upsert(session, model, rows):
table = model.__table__
stmt = postgresql.insert(table)
primary_keys = [key.name for key in inspect(table).primary_key]
update_dict = {c.name: c for c in stmt.excluded if not c.primary_key}
if not update_dict:
raise ValueError("insert_or_update resulted in an empty update_dict")
stmt = stmt.on_conflict_do_update(index_elements=primary_keys,
@roberthamel
roberthamel / docker-compose.yml
Created February 4, 2020 05:20 — forked from tobydeh/docker-compose.yml
gitea 1.10, drone 1.6 and drone-runner-docker example using docker-compose
# Instructions
# 1. Update your /etc/hosts file...
# > 127.0.0.1 gitea drone
# 2. Run gitea + gitea-db and generate the oauth application
# > docker-compose -p gitea-drone up gitea gitea-db
# - Navigate to http://gitea:3000 to finish the installation and register a user
# - Create a oauth application as described here: https://docs.drone.io/installation/providers/gitea/
# - Set the Redirect uri to http://drone:8000/login
# 3. Update the docker-compose file with the client_id and client_secret
# 4. Fire up all of the services
@roberthamel
roberthamel / README.md
Created February 3, 2020 04:11 — forked from joffilyfe/README.md
GITEA + Drone (0.7|0.8)

Compose file to setup and host a Gitea and Drone environment

This environment is dependent off a common network for docker/git plugin and gitea-server, so for this work fine in closed networks we have to create a custom network before run this composefile.

First create your network:

docker network create gitea-network
@roberthamel
roberthamel / Menu.java
Created February 14, 2018 03:21 — forked from Superpat/Menu.java
A small java command line api to generate a menu that can return a generic
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
/** Menu api for the command line
* <p>
* Takes a list of options containing a value and a menu title, when called, the menu returns an optional type containing the option.
* </p>
* @author Patrick Marchand <mail@patrickmarchand.com>
* @version 0.2
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@roberthamel
roberthamel / generate-pushid.js
Created January 8, 2018 03:53 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/