Skip to content

Instantly share code, notes, and snippets.

View ncdulo's full-sized avatar
⚙️
The Factory must grow...

ncdulo ncdulo

⚙️
The Factory must grow...
View GitHub Profile
@ncdulo
ncdulo / reload_nvidia_xorg.sh
Created August 12, 2020 18:37
Automate reloading of nvidia-drivers on Gentoo so that a reboot after updating is not required. Simple convenience script to turn a small handful of commands into a single command.
#!/usr/bin/env bash
# Convenience script for the times when 'nvidia-drivers' updates
# and I don't feel like rebooting. This script is intended to be run
# from a TTY as it will bring down Xorg and reload the nvidia drivers
#
# There is no error checking for now. Just bang out commands so I don't
# have to.
#
# Mar 08, 2020 - ncdulo
@ncdulo
ncdulo / preview-rst.el
Last active November 12, 2021 02:00 — forked from camsaul/preview-markdown.el
rst-mode live previews
;;; preview-rst.el --- description -*- lexical-binding: t; -*-
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Based on the "Intro To Emacs Lisp: Adding Live Preview when Editing Markdown"
;; guide at the link below. This has been followed along, but re-written to use
;; docutils and rst-mode as I do not have pandoc, nor do I feel I want to deal
;; with installing it and it's many Haskell dependencies.
@ncdulo
ncdulo / urban.py
Last active March 15, 2020 22:48
[Python] UrbanDictionary word lookup
from bs4 import BeautifulSoup
import requests
def lookup(word, limit=0):
'''
Return a list of definitions of 'word' from UrbanDictionary,
up to 'limit' results returned. A limit <= 0 will return
all results.
Raises exception through 'requests' upon HTTP-related errors.
@ncdulo
ncdulo / deg_to_cardinal.py
Last active March 13, 2020 22:05 — forked from RobertSudwarts/deg_to_cardinal.py
[Python] Degrees to Cardinal direction
def degrees_to_cardinal(degrees):
'''
Return the cardinal direction representing a given 'degrees'
'''
cardinal = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE',
'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
cardinal_len = len(cardinal)
ix = round(degrees / (360.0 / cardinal_len))
return cardinal[ix % cardinal_len]
@ncdulo
ncdulo / callfactorial.c
Last active February 28, 2020 21:03
Recursive Factorial (x86_64 ASM + C)
/*
* An application that illustrates calling the factorial function defined in 'factorial.asm'
* https://cs.lmu.edu/~ray/notes/nasmtutorial/
*
* To build & run:
* nasm -f elf64 factorial.asm && gcc -std=c99 -o factorial2 factorial.o callfactorial.c
*/
#include <stdio.h>
#include <inttypes.h>
@ncdulo
ncdulo / youtube_title_grabber.py
Last active February 24, 2020 17:02
YouTube "URL -> Title" Scraper
#!/usr/bin/env python
import requests
import urllib.request
from bs4 import BeautifulSoup
'''When given a list of YouTube URLs inside `yt.txt`, this script will
use Requests and BeautifulSoup4 to iterate over that list of URLS and
scrape video titles from each link. The output is then appended on to
the same `yt.txt` input file. Because of this appendage action, note
that running this script multiple times on the same file will result in
@ncdulo
ncdulo / turbo-boost.sh
Created February 11, 2020 21:37
Enable or disable Intel Turbo-Boost via MSR
#!/usr/bin/env bash
# Enable or disable Intel Turbo-Boost
# Requires msr kernel module to be built and loaded
# Will ask for root privileges when the time comes
# Copied, with love, from:
# https://notepad2.blogspot.com/2014/11/a-script-to-turn-off-intel-cpu-turbo.html
if [[ -z $(which rdmsr) ]]; then
echo "msr-tools is not installed. Run 'sudo apt-get install msr-tools' to install it." >&2