Skip to content

Instantly share code, notes, and snippets.

View Tinitto's full-sized avatar

Martin Ahindura Tinitto

View GitHub Profile
@Tinitto
Tinitto / amqp_listener.go
Created May 11, 2021 17:25
How to Connect to an AMQP 1.0 Topic not Queue in Golang
/*
* In an attempt to use the https://github.com/Azure/go-amqp/ to connect to an AMQP topic, I was using the sample code
* on the README but kept getting an error like:
* "Failed creating receiver link *Error{Condition: amqp:unauthorized-access, Description: User qbtzf4r2sqkimdl is not authorized to read from: queue://topic..."
* To connect to an AMQP 1.0 topic, the LinkSourceAddress or the LinkTargetAddres has to be of the form "topic://..."
*/
package main
import (
@Tinitto
Tinitto / sample_snapshot_test_in_data_science.py
Created January 18, 2020 20:54
Sample code showing how to do snapshot testing in Data Science Pipelines and Systems
import os
import pickle
# ...... more code
# ......
results = some_calculation()
expected_result_file_path = 'path_to_the_snapshot_file_of_choice'
# the snapshot file should not exist at the beginning
#!/bin/sh
## Script adapted from https://www.rabbitmq.com/install-debian.html
##
## If sudo is not available on the system,
## uncomment the line below to install it
# apt-get install -y sudo
sudo apt-get update -y
@Tinitto
Tinitto / generateGravatar.js
Last active September 16, 2023 00:23
Generate Gravatar or default to Initials Avatar
/**
This is in a Nodejs environment
*/
const crypto = require('crypto');
module.exports = (
email = '',
name = 'Anonymous',
initialsAvatarBackground = '000000',
@Tinitto
Tinitto / authentication.js
Created August 8, 2019 01:09
Custom Google OauthStrategy for Feathersjs 4 with email as primary key
const {
AuthenticationService,
JWTStrategy
} = require('@feathersjs/authentication');
const {
expressOauth,
OAuthStrategy
} = require('@feathersjs/authentication-oauth');
class AdvancedGoogleStrategy extends OAuthStrategy {
@Tinitto
Tinitto / VScode_python_settings.json
Created March 30, 2018 08:36
Settings to ease python development in Visual Studio Code using pylint for linting and autopep8 for formatting on save
{
"html.format.enable": false,
"python.pythonPath": "${workspaceRoot}/env/bin/python3",
"python.linting.lintOnSave": true,
"python.formatting.autopep8Path": "${workspaceRoot}/env/lib/python3.5/site-packages/autopep8.py",
"python.autoComplete.extraPaths": [
"${workspaceRoot}/env/lib/python3.5",
"${workspaceRoot}/env/lib/python3.5/site-packages"
],
"editor.formatOnSave": true
@Tinitto
Tinitto / README.md
Last active March 26, 2018 10:33
Creating a Remote Repo
  1. Create a new folder say new_folder. Use the command line command.
mkdir new_folder
  1. Transfer all the folders and files you want to keep in remote repository into new folder

for linux

@Tinitto
Tinitto / utils_for_django_sqlalchemy.py
Created March 9, 2018 06:43
Utility functions to help integrate Sqlalchemy with django
"""Common utility functions sqlalchemy in django"""
def dj_pg_db_url_to_sqlachemy(dj_pg_db_url):
"""
transforms a dj_database_url postgres url to
an sqlalchemy onereplacing 'postgres://...' with 'posgresql://...'
"""
try:
return 'postgresql%s' % (dj_pg_db_url[dj_pg_db_url.find('://'):])
@Tinitto
Tinitto / cloudSettings
Created November 5, 2017 01:19 — forked from spencercarli/bd3d4befe38185704bf0fc875e9deed6|configuration.json
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-10-30T18:14:52.690Z","extensionVersion":"v2.8.3"}
@Tinitto
Tinitto / right_string_modify.py
Last active September 25, 2017 15:49
The binary search way of implementing the challenge at https://www.hackerearth.com/problem/golf/modify-string/
import string
from random import randint
def modify_string(word):
"""The main function for manipulating the string"""
uppercase_letters = list(string.ascii_uppercase)
lowercase_letters = list(string.ascii_lowercase)
numbers_0_to_9 = [ str(x) for x in range(0, 10) ]
output = ''