Skip to content

Instantly share code, notes, and snippets.

View josemarcosrf's full-sized avatar
🏔️
Working from a mountain top

Jose Marcos RF josemarcosrf

🏔️
Working from a mountain top
View GitHub Profile
@josemarcosrf
josemarcosrf / docker-cleanup-resources.md
Last active April 24, 2018 13:30 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

Prune

From docker 1.25+ you can use this commands:

  • prune image: Remove all unused images, not just dangling ones. This will delete all the images without an associated container!
@josemarcosrf
josemarcosrf / git_retag
Created August 13, 2018 20:05 — forked from lucijafrkovic/git_retag
Retagging on git
1. list all remote tags
git ls-remote --tags
2. delete local tag
git tag -d V_1_0_1
3. push tag deletion to remote
git push origin :refs/tags/V_1_0_1
4. tag local branch again
@josemarcosrf
josemarcosrf / testApiKeyAndGoogleAuthLibrary.js
Created October 24, 2018 15:40 — forked from phsultan/testApiKeyAndGoogleAuthLibrary.js
Google Speech Recognition with API key + google-auth-library
const fs = require('fs');
const { auth } = require('google-auth-library');
const API_KEY = 'ADD YOUR API KEY HERE';
const fileName = './audio.raw';
// Reads a local audio file and converts it to base64
const file = fs.readFileSync(fileName);
const audioBytes = file.toString('base64');
@josemarcosrf
josemarcosrf / EnvDefault.py
Created October 25, 2018 14:34 — forked from orls/EnvDefault.py
Using env vars in argparse
"""Provides a utility to inject environment variables into argparse definitions.
Currently requires explicit naming of env vars to check for"""
import argparse
import os
# Courtesy of http://stackoverflow.com/a/10551190 with env-var retrieval fixed
class EnvDefault(argparse.Action):
"""An argparse action class that auto-sets missing default values from env
vars. Defaults to requiring the argument."""
@josemarcosrf
josemarcosrf / switch-local-git-repo-to-fork.md
Created November 19, 2018 20:58 — forked from jpierson/switch-local-git-repo-to-fork.md
How to move to a fork after cloning

If you are like me you find yourself cloning a repo, making some proposed changes and then deciding to later contributing back using the GitHub Flow convention. Below is a set of instructions I've developed for myself on how to deal with this scenario and an explanation of why it matters based on jagregory's gist.

To follow GitHub flow you should really have created a fork initially as a public representation of the forked repository and the clone that instead. My understanding is that the typical setup would have your local repository pointing to your fork as origin and the original forked repository as upstream so that you can use these keywords in other git commands.

  1. Clone some repo (you've probably already done this step)

    git clone git@github...some-repo.git
@josemarcosrf
josemarcosrf / docker-install-rpi3.md
Created November 21, 2018 13:05 — forked from tyrell/docker-install-rpi3.md
Installing latest Docker on a Raspberry Pi 3

Introduction

I wrote this gist to record the steps I followed to get docker running in my Raspberry Pi 3. The ARM ported debian version (Jessie) comes with an old version of docker. It is so old that the docker hub it tries to interact with doesn't work anymore :)

Hopefully this gist will help someone else to get docker running in their Raspberry Pi 3.

Installation

From original instructions at http://blog.hypriot.com/post/run-docker-rpi3-with-wifi/

@josemarcosrf
josemarcosrf / wraps.py
Created November 26, 2018 18:22
python @wraps example of use
from functools import wraps
def decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
print("I am the wrapper, wrapping '{}'".format(f.__name__))
return f(*args, **kwargs)
return wrapper
@josemarcosrf
josemarcosrf / branch_rename.sh
Created November 28, 2018 10:30
Rename git branch
# from the branch to rename
git branch -m new-name
# delete the old name-branch and push the new one
git push origin :old-name new-name
# reset the upstream with the new local name one
git push origin -u new-name
@josemarcosrf
josemarcosrf / wav-mp3
Created December 28, 2018 21:07 — forked from championofblocks/wav-mp3
Command line bash to convert all wav to mp3
for i in *.wav; do lame -b 320 -h "${i}" "${i%.wav}.mp3"; done
@josemarcosrf
josemarcosrf / install_cuda_ubuntu-1604.sh
Last active May 21, 2020 12:03 — forked from 8enmann/reinstall.sh
Reinstall NVIDIA drivers without opengl Ubuntu 16.04 GTX 1080ti
# Download installers
mkdir ~/Downloads/nvidia
cd ~/Downloads/nvidia
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/384.59/NVIDIA-Linux-x86_64-384.59.run
sudo chmod +x NVIDIA-Linux-x86_64-384.59.run
sudo chmod +x cuda_8.0.61_375.26_linux-run
./cuda_8.0.61_375.26_linux-run -extract=~/Downloads/nvidia/
# Uninstall old stuff
sudo apt-get --purge remove nvidia-*