Skip to content

Instantly share code, notes, and snippets.

View mugishap's full-sized avatar
🎯
A ship in a harbor is safe, but that's not what they're built for

Mugisha Precieux mugishap

🎯
A ship in a harbor is safe, but that's not what they're built for
View GitHub Profile
#!/bin/bash
rm -rf .git
git init
git add .
git commit -m "[init]: Initialized repo"
git branch main
git switch main
echo "Enter github username: "
read username
extension String {
func removeChar(character: String) -> String {
if(character.count > 1) {
print("Only one character can be removed at a time")
return "Error occured"
}
var newStr: String = ""
for current in self {
if(character == "\(current)"){
@mugishap
mugishap / toPDF.ts
Created October 31, 2022 12:30
Simple function that transforms HTML to PDF.
import html2canvas from "html2canvas";
import jsPDF from "jspdf";
const exportPDF = () => {
const input = document.getElementById("documentID") as HTMLElement;
html2canvas(input, { logging: true, useCORS: true }).then((canvas) => {
const imgWidth = 290;
const imgHeight = 210;
const imgData = canvas.toDataURL("img/png"); transform canvas to an image
const pdf = new jsPDF("l", "mm", "a4"); // L is landscape, you can use whatever you want for example p to make it portrait