Skip to content

Instantly share code, notes, and snippets.

View ndamulelonemakh's full-sized avatar
🍸
Solution explorer

Ndamulelo Nemakhavhani ndamulelonemakh

🍸
Solution explorer
View GitHub Profile
@ndamulelonemakh
ndamulelonemakh / push-github-docker.sh
Last active October 13, 2024 11:14
Convenience script to push images to Github container registry
#!/bin/bash
set -e
# Pre-requisite:
# Generate your token at: https://github.com/settings/tokens/new?scopes=write:packages
# More info: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
export CR_PAT=<YOUR_TOKEN>
GITHUB_USERNAME=<your-github-account-name>
echo $CR_PAT | docker login ghcr.io -u $GITHUB_USERNAME --password-stdin
@ndamulelonemakh
ndamulelonemakh / Dockerfile.Angular
Created May 23, 2024 21:28
Sample docker file for running angular 17+ with ssr support
FROM node:lts-alpine as build
WORKDIR /app
COPY package*.json ./
# Install dependencies
RUN npm ci --force
COPY . .
# Official reference: https://swagger.io/specification/
openapi: "3.0.0" # The version of the OpenAPI Specification being used
info: # Metadata about the API
version: "1.0.0" # Version of the API
title: "Sample API" # Name of the API
servers: # Base URL and other server information
- url: "http://api.example.com/v1"
@ndamulelonemakh
ndamulelonemakh / app.py
Created May 11, 2024 16:35
Flask server html
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
todos = []
@app.route('/')
def index():
return render_template('index.html', todos=todos)
@app.route('/add', methods=['POST'])
@ndamulelonemakh
ndamulelonemakh / pdf_preview.html
Created November 14, 2023 11:16
HTML Snippets - less JS, less npm install
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Native HTML PDF Preview</title>
</head>
<body>
<div style="display: block; height: 900px; background-color: aqua;">
<object
@ndamulelonemakh
ndamulelonemakh / git-line-endings-config.md
Last active February 7, 2024 08:35
Handle CRLF and LF settings when working on Windows and Linux environments

Handling Line Endings: Windows, WSL2, and Ubuntu

When working on different operating systems, managing line endings is crucial to ensure consistency and avoid issues in a collaborative development environment. Here are the recommendations for configuring Git to handle line endings on Windows, WSL2, and Ubuntu:

1. Windows:

  • Recommended Setting: core.autocrlf true
  • Command:
    git config --global core.autocrlf true
@ndamulelonemakh
ndamulelonemakh / aci_start_stop.py
Last active October 4, 2023 07:27
Azure automation templates
#!/usr/bin/env python3
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
from azure.identity import DefaultAzureCredential
def start_container_instance(resource_group_name,
container_group_name,
subscription_id):
print(f'Attempting to start {container_group_name=} in {resource_group_name=}')
# Authenticate with Azure
@ndamulelonemakh
ndamulelonemakh / pytorch-basic.py
Last active May 5, 2023 13:10
Distribute training samples
import torch
import torch.nn as nn
import torch.optim as optim
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
# Define the sentiment analysis model
class SentimentAnalysisModel(nn.Module):
@ndamulelonemakh
ndamulelonemakh / colab_clone_private_repo.py
Last active August 10, 2022 01:42
Google colab utils
"""A naive imnplementation for interactively cloning private python repositories in google colab"""
from google.colab import drive
def get_config(path: str):
"""deserialised configuration from disk or return an empty dict"""
if not os.path.exists(path):
return {}
with open(path) as cbf:
_colab_cfg = cbf.read()
## Proble:
# Apparently some blobs were not uploaded to the server
# Causeing git lfs to stop working
# I could not even push to other remotes becuase of this
# Solution 1:
# Revert to a commit before running: git lfs install
git checkout <commit-hash>
git switch -n mynewbranch