Skip to content

Instantly share code, notes, and snippets.

View Tinitto's full-sized avatar

Martin Ahindura Tinitto

View GitHub Profile
##Have a band, hire musicians and fire them using OOP
import random
class Musician:
"""docstring for ClassName"""
def __init__(self, name, specialization, sound):
self.name = name
self.specialization = specialization
self.sound = sound
class Guitarist(Musician):
import string
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 = ''
all_lists = [uppercase_letters, lowercase_letters, numbers_0_to_9]
@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 = ''
@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 / 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 / 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 / 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 / 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 / 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',
#!/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