Skip to content

Instantly share code, notes, and snippets.

View mshafae's full-sized avatar

Michael Shafae mshafae

View GitHub Profile
@mshafae
mshafae / mysqluseradd
Last active August 6, 2022 18:48
A simple script to create a MySQL user on a Debian style system.
#!/bin/bash
usage () {
echo "Usage:"
echo " ${1} mysql-key db-name new-login new-login-password"
echo
echo "The mysql-key is typically in /etc/mysql/debian.cnf"
echo "The db-name is the database name that you would like the"
echo "new-login to have access to. The database will be created."
echo "new-login is the new login to create."
@mshafae
mshafae / vbox-install
Last active August 6, 2022 18:49
Script to install Virtualbox on Ubuntu
#!/bin/bash
# In case you want to install from a the Oracle package repository.
oracle_install ( ){
CODENAME=`lsb_release -c | cut -f 2`
eval sudo sh -c 'echo "deb https://download.virtualbox.org/virtualbox/debian ${CODENAME} contrib" >> /etc/apt/sources.list'
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
sudo apt-get update && sudo apt-get install virtualbox-6.0
}
@mshafae
mshafae / pointers.cpp
Created April 22, 2020 23:09
Simple program to demonstrate pointers in C++
#include <iostream>
using namespace std;
// Passing by value
void print(int a){
cout << "a is " << a << " and it's address is " << &a << endl;
}
// Passing by reference
@mshafae
mshafae / lateximgurl
Last active April 7, 2021 20:03
LaTeX Math to GitHub Image URL
#!/usr/bin/env python3
"""
Converts LaTeX math code to a URL that will render an image
via GitHub's math renderer URL.
Inspired by the discussion found at
https://gist.github.com/a-rodin/fef3f543412d6e1ec5b6cf55bf197d7b
"""
#
# Copyright 2020 Michael Shafae
#
#include <iostream>
using namespace std;
int main(void){
int x = 42;
cout << "int x is " << x << " and it is located at " << &x << endl;
cout << endl;
#include <iostream>
using namespace std;
struct Foo{
int a;
char b;
};
int main(void){
@mshafae
mshafae / mdsee
Created April 7, 2021 20:31
Preview Markdown files via GitHub's Markdown Renderer.
#!/bin/bash
#
# Copyright 2021 Michael Shafae
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@mshafae
mshafae / setup.py
Created May 13, 2021 22:22
example Pygame setup.py py2app setup.py demo.
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
import py2app.recipes
import py2app.build_app
@mshafae
mshafae / pylint-env.py
Created August 8, 2022 18:47
Working with GitHub Actions and different python environments for pylint.
init-hook='import os, sys; sys.path.append("/opt/actions-runner/env/lib/python3.8/site-packages") if os.path.exists("/opt/actions-runner/env/lib/python3.8/site-packages") else sys.path.append("env/lib/python3.8/site-packages")'
@mshafae
mshafae / cpsc120_even_or_odd.cc
Last active December 13, 2023 23:15
Even or odd C++ program.
// Gist https://gist.github.com/59c6e8a6a446fa7c32b16203493d14be
#include <iostream>
#include <string>
int main(int argc, char const *argv[]) {
if (argc < 2) {
std::cout << "Please provide an argument.\n";
return 1;