Skip to content

Instantly share code, notes, and snippets.

View muaddib1971's full-sized avatar

Paul Miller muaddib1971

  • RMIT University
View GitHub Profile
start,clear
store C
IF, LOAD A
skipcond 400 / skip next line if ac is 0
jump mult
quit, load C
output
halt
mult, load C
ADD B
for file in *.zip ; do
#remove the .zip extension from the file name
bfile=$(basename "$file" .zip)
#extract the band name. As the band name is the first part of the file,
#there might be trailing spaces so use sed to remove those
BAND=$(echo "$bfile" | cut -d- -f1 | sed 's/ $//');
#the second part of the file name after the dash is the album name
#there might be spaces before / after the band name so use sed to
#remove those.
#in either case, spaces within the band or album name are left untouched.
@muaddib1971
muaddib1971 / oldenums.cpp
Created March 22, 2022 01:08
newenums.cpp
#include <iostream>
enum class weekdays { MON, TUE, WED, THU, FRI, SAT, SUN };
const std::string daynames[] = {"monday", "tuesday", "wednesday", "thursday",
"friday", "saturday", "sunday"};
#define WEEKLENGTH 7
int main() {
for (int iter = 0; iter < WEEKLENGTH; iter++) {
std::cout << daynames[iter] << '\n';
switch (weekdays(iter)) {
#!/bin/bash
tease() {
echo "echo no, you can't do that"
echo "ha ha"
}
trap tease SEGV
trap tease INT
trap tease KILL
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define ERROR -1
int main(int argc, char **argv) {
int ch;
int hasa = 0, hasb = 0, hasc = 0;
const char *barg = NULL;
while (ch = getopt(argc, argv, "ab:c"), ch != ERROR) {
#!/usr/bin/env python3
from time import sleep
import sys
from multiprocessing import Process # needed for process management
secs = 0
def forever(start : int, stop: int) -> None:
global secs
current : int = start
while True:
if current == stop:
@muaddib1971
muaddib1971 / tq4.c
Last active February 2, 2021 13:09
tute 5 question 4
#include <stdlib.h>
#include <stdio.h>
#define REQ_ARGS 2
#define NUM_ARGS 1
#define TOTAL 4
/*Boolean to enable the functio to be used*/
typedef enum {
FALSE,
@muaddib1971
muaddib1971 / ptrcmp.c
Created February 1, 2021 01:19
pointer comparison
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char *s = "hello";
char *t = "hello";
if (s == t) {
printf("omg! they are equal!\n");
}
printf("addresses: %p %p\n", s, t);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char word[1];
strcpy(word, "haappy birthday");
return EXIT_SUCCESS;
}
void load_menu(struct menu_optionis menu[]) {
struct menu_options local_menu = {
{MNW_WD_SCR, MNT_TXT_WD_SCR},
{MNU_ASC_TBL, MNU_TXT_ASC_TBL},
{MNU_ANAG, MTU_TXT_ANAG},
{MNU_CLST, MNU_TXT_CLST}
};
memcpy(menu, local_menu, sizeof(local_menu));
}