Skip to content

Instantly share code, notes, and snippets.

@MrGibus
MrGibus / updiscord.sh
Created February 16, 2024 14:33
Updates discord in Fedora Linux.
#!/bin/bash
# navigate to downloads run `sudo bash ~/path/to/updiscord.sh discord-0.0.xx.tar.gz
if [ $# -ne 1 ]; then
echo "Usage: $0 <discord-file-path>"
exit 1
fi
discord_file_path=$1
install_path="/lib64/Discord"
@MrGibus
MrGibus / check_internet.py
Created May 16, 2022 13:31
Checks when the NBN have got their shit together. Thanks Coalition.
from time import sleep
import requests
url = "https://www.google.com/"
timeout = 5
while True:
try:
request = requests.get(url, timeout=timeout)
print("Connected to Internet!")
@MrGibus
MrGibus / Change "origin" of your GIT repository
Last active August 11, 2021 09:44 — forked from DianaEromosele/Change "origin" of your GIT repository
Change "origin" of your GIT repository
git remote rm origin
git remote add origin <INSERT URL/ DIRECTORY HERE>
git config master.remote origin
git config master.merge refs/heads/master
git remote show origin
@MrGibus
MrGibus / impl_multiple.rs
Created April 4, 2021 16:34
Impl macro for multiple types.
// The following is useful when impl a trait on multiple types such as all the integer types etc.
macro_rules! impl_multiple {
// standard implementation with no internal code
($trait:ident for $($type:ty)*) => {
$(
impl $trait for $type {}
)*
};
struct Shoe {
size: u32,
style: String,
}
fn shoes_in_my_size(shoes: Vec<Shoe>, shoe_size:u32) -> Vec<Shoe> {
shoes.into_iter().filter(|s| s.size == shoe_size).collect()
// explanation:
// shoes is a vector.. into_iter() yields an iterator depending on the context similar to .iter()
@MrGibus
MrGibus / Vector_Print.rs
Created September 13, 2020 14:55
For printing vectors
fn printv<T>(vector: &[T])
where T: std::fmt::Display
{
for i in vector.iter() {
println!("{} ", i)
}
}
fn printvi<T>(vector: &[T])
where T: std::fmt::Display
@MrGibus
MrGibus / PySimpleGUI_template.py
Created September 2, 2020 15:02
Basic form, inputs and an output
import PySimpleGUI as sg
sg.theme("DarkBlue")
def deflection(l, e, i, w):
d = 5 / 384 * w * l**4 / e / i
return f'{d:0.3f}'
def main():
@MrGibus
MrGibus / PySide2_box_and_button_ui.py
Last active May 3, 2020 15:42
PySide2 pushButton and lineEdit interaction with UI file and notes
# The my_ui file is created from running pyside2-uic command on a created .ui file > see below
# CMD: pyside2-uic mainwindow.ui > my_ui.py
# The ui file has a button (pushButton) and text box (lineEdit) created in Qt Designer with names left as default
# This shows how to access the button and textbox
import sys
from PySide2.QtWidgets import QApplication, QMainWindow
from my_ui import Ui_MainWindow