Skip to content

Instantly share code, notes, and snippets.

@jdesilvio
jdesilvio / worker.go
Created October 19, 2021 15:11
Go worker pattern
package main
import (
"fmt"
"sync"
"time"
)
func worker(wg *sync.WaitGroup, requestChannel <-chan string, responseChannel chan<- int, id int) {
defer wg.Done()
# If you come from bash you might have to change your $PATH.
export PATH=/opt/local/bin:$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/jdesilvio/.oh-my-zsh"
# Theme
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="spaceship"
SPACESHIP_CHAR_SYMBOL="λ "
@jdesilvio
jdesilvio / gist:1b74a60470011b172e36f92310e0d429
Last active January 7, 2020 19:35
Find/Replace all Python
find ./src/**/*.py -type f -exec sed -i -e 's/<FIND>/<REPLACE>/g' {} \;
rm ./**/*-e
@jdesilvio
jdesilvio / gist:5b4fc264fff1d6ad9905003c1bcc80e8
Last active April 16, 2024 18:13
pycurl openssl conflict
# Intel
export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
export PYCURL_SSL_LIBRARY=openssl
pip uninstall pycurl
pip install pycurl==7.43.0.2 --global-option="--with-openssl"
# M1
brew update && brew install openssl
@jdesilvio
jdesilvio / get_perms.py
Created December 17, 2019 17:03
Get all permissions
groups = Group.objects.all()
for group in groups:
for perm in group.permissions.all():
self.logger.info("%s|%s|%s", group.name, perm.name, perm.codename)
export ORACLE_HOME=/opt/instantclient_12_2/
export LD_RUN_PATH=/opt/instantclient_12_2:$LD_RUN_PATH
@jdesilvio
jdesilvio / logger_patch.py
Last active August 15, 2019 20:36
Python logger patch
from logging import Logger
import unittest
from mock import Mock, patch
class MyClassTest(unittest.TestCase):
def setUp(self):
self._logger = Mock(spec=Logger)
self.logging_patch = patch(
set -g default-terminal "screen-256color"
set-option -sa terminal-overrides ',*256col*:RGB'
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# force a reload of the config file
unbind r
# Added by Anaconda2 2.4.0 installer
#export PATH="$HOME/anaconda/bin:$PATH"
# Alias
alias activate="source ./env/bin/activate"
alias tree1="tree -L 1"
alias tree2="tree -L 2"
alias tree3="tree -L 3"
export PYTHONPATH="${PYTHONPATH}:/usr/local/bin/python"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
export NVM_DIR="/Users/JohnsMacBook/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm