Skip to content

Instantly share code, notes, and snippets.

View robobenklein's full-sized avatar
:electron:
translating thoughts to code

Ben Klein robobenklein

:electron:
translating thoughts to code
View GitHub Profile
import time
import psutil
import multiprocessing as mp
from multiprocessing import Process
def f(thread, duty, freq, q):
p = psutil.Process()
p.cpu_affinity([thread])
while True:
@fevangelou
fevangelou / Software RAID 1 setup on Ubuntu Server 20.04.md
Last active June 2, 2024 10:16
Software RAID 1 setup on Ubuntu Server 20.04 (or newer)

Looking to create a Software RAID 1 setup for your 2-disk server on Ubuntu Server 20.04?

Screen Shot 2020-06-05 at 20 55 31

Let's start with the basics: the official guide by Ubuntu (https://ubuntu.com/server/docs/install/storage) is outdated/wrong. And as of March 2021 it's possible that there's a bug as well with how the bios_grub partitions are created when using multiple disks.

Now on to the solution:

  • Select "Custom storage layout" when you reach the storage configuration step of the installer.
  • If the disks have existing partitions, click on each disk under AVAILABLE DEVICES and then select REFORMAT. This will (temporarily) wipe out the partitions.
@psprint
psprint / deploy-message.zsh
Last active April 1, 2023 07:46
Zsh function to display a message under prompt
# The Zshell function will display the given message under-prompt (as a kind of notification).
# It has an optional delay first argument: "@sleep:<secnods with fractions>". If given, then
# the message will wait in background before showing for the specified time.
#
# Usage:
# deploy-message @msg "Hello world"
# deploy-message "Hello world"
# deploy-message @msg 1234 # I.e. the "@msg" is needed for number-only messages, otherwise optional
# deploy-message @sleep:5.5 "Hello world"
@jmclemo6
jmclemo6 / canvas_mail_script.js
Created January 10, 2018 21:35
UTK CS Discord Mass Mail Script
// Your browser must support ES6 async / await, Promises, and Template Strings for this to work.
// Do not remove the sleeps to make it faster. They are there to allow time for the Ajax calls that Canvas makes to process.
// If you are on a slow connection, you might need to increase the length of the sleep calls.
// I've also made it up to you to click the send button. Be sure to check that you pasted your invite url correctly.
// To run this:
// * Go to the page on Canvas where you can see your messages from the class you want to send the invite to.
// * Open your browser's console using F12 or by right clicking and then selecting "Inspect Element".
// * Paste the below code into your console window and hit enter.
// * Then enter add_students("INSERT_INVITE_URL_HERE"); into your console window and hit enter.
// * The script will run and then all you have to do is proofread and hit send!
@HelgeSverre
HelgeSverre / gist:33361e8a283624dfbbd6
Created January 12, 2015 14:47
Tetris Powershell Song
powershell [Console]::Beep(658, 125); [Console]::Beep(1320, 500); [Console]::Beep(990, 250); [Console]::Beep(1056, 250); [Console]::Beep(1188, 250); [Console]::Beep(1320, 125); [Console]::Beep(1188, 125); [Console]::Beep(1056, 250); [Console]::Beep(990, 250); [Console]::Beep(880, 500); [Console]::Beep(880, 250); [Console]::Beep(1056, 250); [Console]::Beep(1320, 500); [Console]::Beep(1188, 250); [Console]::Beep(1056, 250); [Console]::Beep(990, 750); [Console]::Beep(1056, 250); [Console]::Beep(1188, 500); [Console]::Beep(1320, 500); [Console]::Beep(1056, 500); [Console]::Beep(880, 500); [Console]::Beep(880, 500); sleep -m 250; [Console]::Beep(1188, 500); [Console]::Beep(1408, 250); [Console]::Beep(1760, 500); [Console]::Beep(1584, 250); [Console]::Beep(1408, 250); [Console]::Beep(1320, 750); [Console]::Beep(1056, 250); [Console]::Beep(1320, 500); [Console]::Beep(1188, 250); [Console]::Beep(1056, 250); [Console]::Beep(990, 500); [Console]::Beep(990, 250); [Console]::Beep(1056, 250); [Console]::Beep(1188, 500); [
@willurd
willurd / web-servers.md
Last active July 6, 2024 23:56
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@atenni
atenni / README.md
Last active July 5, 2024 12:58
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include <assert.h>
#define tic() do { struct timespec ts_start, ts_end; clock_gettime(CLOCK_MONOTONIC, &ts_start)
#define toc() clock_gettime(CLOCK_MONOTONIC, &ts_end); \
printf("%lfs\n", (ts_end.tv_sec - ts_start.tv_sec) + (double)(ts_end.tv_nsec - ts_start.tv_nsec)/1e9); } \