Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Developing Rust projects for Pop!_OS

Michael Murphy mmstick

🦀
Developing Rust projects for Pop!_OS
View GitHub Profile
@mmstick
mmstick / xanmod-install.sh
Last active Jan 23, 2023
Script for installing xanmod on Pop!_OS
View xanmod-install.sh
#!/bin/bash
set -e
for field in $(cat /proc/cmdline); do
if [[ "${field}" = root=* ]]; then
UUID=$(echo $field | awk -F= '{print $3}')
break
fi
done
@mmstick
mmstick / sources.list
Created May 3, 2020
Focal Source List
View sources.list
deb mirror://mirrors.ubuntu.com/mirrors.txt/ focal restricted multiverse universe main
deb-src mirror://mirrors.ubuntu.com/mirrors.txt/ focal restricted multiverse universe main
deb mirror://mirrors.ubuntu.com/mirrors.txt/ focal-updates restricted multiverse universe main
deb-src mirror://mirrors.ubuntu.com/mirrors.txt/ focal-updates restricted multiverse universe main
deb mirror://mirrors.ubuntu.com/mirrors.txt/ focal-security restricted multiverse universe main
deb-src mirror://mirrors.ubuntu.com/mirrors.txt/ focal-security restricted multiverse universe main
deb mirror://mirrors.ubuntu.com/mirrors.txt/ focal-backports restricted multiverse universe main
deb-src mirror://mirrors.ubuntu.com/mirrors.txt/ focal-backports restricted multiverse universe main
deb mirror://mirrors.ubuntu.com/mirrors.txt/ focal-proposed restricted multiverse universe main
deb-src mirror://mirrors.ubuntu.com/mirrors.txt/ focal-proposed restricted multiverse universe main
@mmstick
mmstick / install-fahclient-systemd.sh
Last active Mar 22, 2020
Folding@Home Linux Setup
View install-fahclient-systemd.sh
#!/bin/sh
# Create a systemd service for the FAH client.
echo '[Unit]
Description=Folding@Home Client
After=network.target
[Service]
WorkingDirectory=/var/lib/fahclient
ExecStart=/usr/bin/FAHClient /etc/fahclient/config.xml --run-as fahclient --pid-file=/var/run/fahclient.pid
View gist:ac1e84ed39205926d56c851d7f527168
### Keybase proof
I hereby claim:
* I am mmstick on github.
* I am mmstick (https://keybase.io/mmstick) on keybase.
* I have a public key ASB9fnv3gH4sQQcdnvwt7jGb-dD3HoKQNjSGkLU-MxdR4wo
To claim this, I am signing this object:
View distinst.h
#ifndef distinst_h
#define distinst_h
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
typedef enum {
DISTINST_FILE_SYSTEM_TYPE_NONE = 0,
DISTINST_FILE_SYSTEM_TYPE_BTRFS = 1,
@mmstick
mmstick / 01-main.c
Last active Dec 30, 2017
Advent of Code 2017 (C Edition)
View 01-main.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
/// A fat pointer which points to byte array of text.
typedef struct str {
uint8_t *data;
size_t len;
@mmstick
mmstick / paths.rs
Created Aug 22, 2017
Rusty One-Liners
View paths.rs
/// Takes a pathname and shortens it for readability.
pub fn shorten_path(path: &Path) -> PathBuf {
// Attempt to strip the current working directory from the path.
path.strip_prefix(&env::current_dir().unwrap())
// If the home directory was split, return a new `PathBuf` with "." as the replacement.
.map(|value| PathBuf::from(".").join(value))
// If the current working directory could not be found, attempt to strip the home directory from the path.
.unwrap_or(path.strip_prefix(&env::home_dir().unwrap()).ok()
// Return the input path if the home directory was not found, otherwise prepend "~" to the path.
.map_or_else(|| path.to_path_buf(), |value| PathBuf::from("~").join(value)))
@mmstick
mmstick / bank.rs
Last active Jul 17, 2017
Rust implementation of an ATM-like console
View bank.rs
use std::io::{stdin, stdout, BufRead, Error, Write};
use std::fmt::{self, Display};
fn main() {
// Create the account that we will emulate
let mut account = Account::new();
// Print the first input message to the screen
print!("Enter your account name: ");
let stdout = stdout();
@mmstick
mmstick / split.rs
Last active Jun 4, 2017
Compile with `rustc -C opt-level=3 -C target-cpu=native -C lto -C panic=abort split.rs -o splitrs`
View split.rs
use std::io::{self, BufRead, BufReader, Write};
use std::time::Instant;
fn main() {
// Obtain a buffered handle to standard input
let stdin = io::stdin();
let mut stdin = BufReader::new(stdin.lock());
// Mark the current time for a later duration comparison.
let start = Instant::now();
@mmstick
mmstick / rss.hbs
Last active Jun 1, 2017
RSS Rocket Handlebar Example (Sort of...)
View rss.hbs
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>{{page_title}}</title>
<link>{{page_link}}</link>
<description>{{page_desc}}</description>
<language>en-us</language>
<pubDate>{{page_date}}</pubDate>
<generator>Custom Web Server Written in Rust (RIIR)</generator>
<webMaster>mmstickman@gmail.com</webMaster>