Skip to content

Instantly share code, notes, and snippets.

@ptmcg
ptmcg / computer_thinking_spinners.py
Last active March 1, 2022 20:16
Rich spinners for "the computer is thinking"
import rich.progress
import rich.spinner
import time
import random
class RandomChars(rich.progress.ProgressColumn):
"""Simulation of computer 'thinking' by displaying random characters
Args:
chars (str): characters from which to choose for display. Defaults to 0-9A-F.
@okken
okken / mcd.bash
Last active October 10, 2020 05:17
mcd: menu driven cd (intended for .bashrc)
# mcd: menu driven cd (intended for .bashrc)
function mcd {
PS3="Which directory: "
select d in '/some/common/path/i/use/'\
'/another/common/path/'\
'/and/so/forth/'
do
cd $d
break
@okken
okken / goes_in_bashrc_for_venv_use_windows.bash
Last active June 26, 2019 13:40
venv activate/exit (windows version)
# create virtual environment
#
function create {
echo "\ncreating virtual environment"
python -m venv venv --prompt ${PWD##*/}
echo "upgrading pip"
venv/Scripts/python.exe -m pip install -U pip
if [ -f requirements.txt ]
then
echo "installing dependencies from requirements.txt"
@tintoy
tintoy / ssh_jump.py
Created April 27, 2018 02:45
SSH via jump-hosts using Paramiko
#!/usr/bin/env python3
import os
import paramiko
ssh_key_filename = os.getenv('HOME') + '/.ssh/id_rsa'
jumpbox_public_addr = '168.128.52.199'
jumpbox_private_addr = '10.0.5.10'
target_addr = '10.0.5.20'
# problem: when presenting, I want to obscure
# my prompt to act like it's at root of file system
# and be very basic with no git info, etc.
# solution: this theme lets you set a ENV to the path
# of your presentation, which will help remove unneeded prompt
# features while in that path
# oh-my-zsh theme for presenting demos
# based off the default rubbyrussell theme
@duebbert
duebbert / ssh_ubuntu_windows.md
Last active September 3, 2019 15:18
Configuring PyCharm, Bash on Ubuntu on Windows 10 & WinSCP to work with SSH keys in Keepass using the KeeAgent Plugin

Configuring PyCharm, Bash on Ubuntu on Windows 10 & WinSCP to work with SSH keys in Keepass using the KeeAgent Plugin

Description

This is a small guide on how to set up PyCharm, Bash on Ubuntu on Windows & WinSCP on Windows to use SSH keys which are saved in KeePass. This significantly improves the user experience while keeping the keys save. It also alleviates any issues with Cygwin which prompted me to set this all up (see setup with Babun before https://gist.github.com/duebbert/1cd30115cf8ade37aa5b619080154e85)

Installation

@micahgodbolt
micahgodbolt / wsl_install_node.md
Last active December 22, 2022 09:37
WSL install Node

The apt-get version of node is incredibly old, and installing a new copy is a bit of a runaround.

So here's how you can use NVM to quickly get a fresh copy of Node on your new Bash on Windows install

$ touch ~/.bashrc
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
// restart bash
$ nvm install --lts
@jonico
jonico / Jenkinsfile
Last active May 11, 2024 09:58
Example for a full blown Jenkins pipeline script with CodeQL analysis steps, multiple stages, Kubernetes templates, shared volumes, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, Docker containers, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, …
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
spec:
containers:
- name: mvn
image: maven:3.3.9-jdk-8
#!/usr/bin/python
"""
msysGit to Unix socket proxy
============================
This small script is intended to help use msysGit sockets with the new Windows Linux Subsystem (aka Bash for Windows).
It was specifically designed to pass SSH keys from the KeeAgent module of KeePass secret management application to the
ssh utility running in the WSL (it only works with Linux sockets). However, my guess is that it will have uses for other
@danni
danni / fields.py
Created March 8, 2016 08:52
Multi Choice Django Array Field
from django import forms
from django.contrib.postgres.fields import ArrayField
class ChoiceArrayField(ArrayField):
"""
A field that allows us to store an array of choices.
Uses Django 1.9's postgres ArrayField
and a MultipleChoiceField for its formfield.