Skip to content

Instantly share code, notes, and snippets.

View roymanigley's full-sized avatar
💭
...still coding

Roy Manigley roymanigley

💭
...still coding
View GitHub Profile
@roymanigley
roymanigley / init-jupyter-notebook.sh
Last active March 13, 2022 00:38
initializes a python3 project with venv and git
#!/bin/bash
# wget https://gist.githubusercontent.com/roymanigley/e703b399acc48e44c8e13c3f18980566/raw/fce917f57ccadc5570de9b1b025ab1d6a988580a/init-jupyter-notebook.sh -O init-jupyter-notebook.sh && source init-jupyter-notebook.sh
if [ ! -d .venv ]
then
python3 -m venv .venv && \
source .venv/bin/activate && \
pip install --upgrade pip && \
pip install notebook matplotlib numpy pandas seaborn folium sklearn requests && \
pip freeze > requirements.txt

To me this is the easiest and most powerful solution, you can even include other templates using the command eval echo "$(<template.txt):

Example with nested template

  1. create the template files, the variables are in regular bash syntax ${VARIABLE_NAME} or $VARIABLE_NAME

you have to escape special characters with \ in your templates otherwhise they will be interpreted by eval.

template.txt

Hello ${name}!
@roymanigley
roymanigley / vim-recording.md
Last active April 24, 2022 14:12
How to record a macro on VIM and reuse it in a function

VIM recording

  1. start the recording
    qq
  2. do your stuff ...
  3. stop the recording
    q
  4. open the vimrc file :e /path/to/vim/c
    :reg q → prints the registers content
  5. paste the macro in a function by moving the cursor to the right position, change to NORMAL mode, enter "qp to paste the content from the register q
@roymanigley
roymanigley / setup openbsd.md
Last active August 11, 2022 07:59
setup openbsd
installation and configuration for
 ▄██████▄     ▄███████▄    ▄████████ ███▄▄▄▄   ▀█████████▄     ▄████████ ████████▄  
███    ███   ███    ███   ███    ███ ███▀▀▀██▄   ███    ███   ███    ███ ███   ▀███ 
███    ███   ███    ███   ███    █▀  ███   ███   ███    ███   ███    █▀  ███    ███ 
███    ███   ███    ███  ▄███▄▄▄     ███   ███  ▄███▄▄▄██▀    ███        ███    ███ 
███    ███ ▀█████████▀  ▀▀███▀▀▀     ███   ███ ▀▀███▀▀▀██▄  ▀███████████ ███    ███ 
███    ███   ███          ███    █▄  ███   ███   ███    ██▄          ███ ███    ███ 
███    ███   ███          ███    ███ ███   ███   ███    ███    ▄█    ███ ███   ▄███ 
 ▀██████▀ ▄████▀ ██████████ ▀█ █▀ ▄█████████▀ ▄████████▀ ████████▀
@roymanigley
roymanigley / init.lua
Last active June 17, 2023 19:50
init.lua for kickstart.nvim
--[[
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
Kickstart.nvim is *not* a distribution.
Kickstart.nvim is a template for your own configuration.
The goal is that you can read every line of code, top-to-bottom, and understand
what your configuration is doing.
@roymanigley
roymanigley / jinja-exmple.md
Last active June 3, 2023 23:19
Jinja2 - Simple Template Engine

Jinja2 - Simple Template Engine

The Template

{% for name in names %}
{% if name | length == 3 %}
Hello {{ name[1:] | upper }}
{% else %}
Hello {{ name }}

{% endif%}

@roymanigley
roymanigley / selenium-python.md
Last active June 17, 2023 19:53
Selenium with Python

Selenium with Python

Setup

python -m venv .env
source .env/bin/activate
pip install selenium
pip freeze > requirements.txt
@roymanigley
roymanigley / setup.sh
Last active October 1, 2023 19:35
Setup after Endever OS installation
#!/bin/bash
echo "[+] SETUP STARTED"
echo "[+] SET VARIABLES"
NVM_VERSION=v0.39.3
JETBRAINS_TOOLBOX_VERSION=1.28.1.15219
JAVA_VERSION=21-open
GIT_USERNAME=royman
GIT_EMAIL='roy.manigley@gmail.com'
@roymanigley
roymanigley / angular-content-projection.md
Last active October 3, 2023 21:27
Angular Content Projection and debounce time

Angular Content Projection and debounce time

dropdown.component.ts

import { Component, ContentChild, Input, OnDestroy, OnInit, TemplateRef } from '@angular/core';
import { EMPTY, Observable, Subject, catchError, debounceTime, map, tap } from 'rxjs';

@Component({
  selector: 'app-dropdown',
  templateUrl: './dropdown.component.html',
@roymanigley
roymanigley / pika_helper.py
Created October 24, 2023 17:57
A helper class to initialize pika consumers and publisher
import logging
from pika import BlockingConnection, ConnectionParameters, PlainCredentials
from concurrent.futures import Executor
LOG = logging.getLogger(__name__)
class RabbitMqConnection(object):