This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| service cloud.firestore{ | |
| match /databases/{database}/documents{ | |
| match /{document=**}{ | |
| allow read, write: if request.auth.uid != null; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| A simple python script that uses the psutil package to show processes running on a host machine. | |
| """ | |
| __version__ = '1.0.0' | |
| __author__ = 'Ndamulelo N [email protected]' | |
| import psutil | |
| import argparse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!bin/bash | |
| # REFERENCE: https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver15 | |
| # 1. First add the Microsoft SQL Server repository | |
| wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | |
| sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)" | |
| # 2. Then Install sql server using apt-install | |
| sudo apt-get update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import smtplib | |
| import ssl | |
| from smtplib import SMTPAuthenticationError | |
| # Simple Python snippet to automatically send emails using gmail | |
| # Docs: https://docs.python.org/3.10/library/smtplib.html | |
| DEFAULT_SSL_PORT = 465 | |
| GMAIL_SERVER_ADDRESS = "smtp.gmail.com" | |
| DEFAULT_SENDER_EMAIL_ADDRESS = "<sender-address>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import uuid | |
| import webbrowser | |
| import urllib.parse as urllib | |
| # You need to install these modules using pip | |
| import flask | |
| import requests | |
| __author__ = '@NdamuleloNemakh' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SimpleSingleton{ | |
| private int count = 1; | |
| // Use lazy<T> to delay initialisation until the field is accessed | |
| private static readonly Lazy<SimpleSingleton> _instance = new Lazy<SimpleSingleton>( ()=> new SimpleSingleton()); | |
| private SimpleSingleton(){ | |
| Console.WriteLine($"{nameof(SimpleSingleton)} constructor called at {DateTime.Now}"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Example implementation of the conjugate gradient descent algorithm using a hard coded objective function | |
| F(X1, X2) = 5X1**2 + X2**2 + 4X1X2 - 14X1 - 6X2 + 20 | |
| - At each step the value of X will be updated using | |
| X_k+1 = X_k + alpha * Pk | |
| Where pk is the conjugate direction and alpha is the step length | |
| """ | |
| import math |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| Simple method to dynamically create the google service account file in Azure App service | |
| Steps | |
| ---------------------- | |
| i. Add the service account file contents to Azure App Service configuration | |
| ii. The json contents will be available to your app at runtime as an environment variable, e.g. GOOGLE_CREDENTIALS | |
| iii. When you app starts, save the contents of the environment variable to a file that you specified as your GOOGLE_APPLICATION_CREDENTIALS | |
| ''' | |
| import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Method 1: Easiest and does not require any library | |
| data(mtcars) | |
| ## 75% of the sample size | |
| smp_size <- floor(0.75 * nrow(mtcars)) | |
| ## set the seed to make your partition reproducible | |
| set.seed(123) | |
| train_ind <- sample(seq_len(nrow(mtcars)), size = smp_size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Summary: Install R in Ubuntu and make it available in jupyter lab | |
| # Install R on ubuntu (Tested on Ubuntu 18.04) | |
| sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/' | |
| sudo apt update -y | |
| sudo apt-get install r-base r-base-core r-recommended | |
| # Extra requirements for compiling packages locally |
OlderNewer