Skip to content

Instantly share code, notes, and snippets.

@nathanjackson
nathanjackson / device_query.c
Last active March 8, 2025 22:32
OpenCL Device Query
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
int main() {
@nathanjackson
nathanjackson / stats.cu
Created April 10, 2015 23:08
Incomplete CUDA Statistics Kernel
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
static const size_t MAX_BLOCK_SIZE = 1024;
double cpu_var(double *input, size_t len)
{
function git_portion {
git status > /dev/null 2> /dev/null
if [[ $? -eq 0 ]]
then
current_branch=$(git rev-parse --abbrev-ref HEAD)
modified='\e[92m'
git diff --exit-code 2>/dev/null >/dev/null
if [[ $? -ne 0 ]]
then
modified='\e[97m*\e[93m'
# A minimal config for samba to share with Windows 2000.
# This is insecure... don't run this config on a production system.
[global]
workgroup = SAMBA
security = user
lanman auth = yes
ntlm auth = yes
[public]
@nathanjackson
nathanjackson / detect_cycle.c
Created December 16, 2018 02:14
Tortise and Hare Algorithm
#include <assert.h>
#include <stddef.h>
#include <limits.h>
#include <stdio.h>
struct node {
int value;
struct node *next;
};
# Install wimlib
dnf install wimlib-utils wimlib
# Mount Windows 10 ISO
mkdir /tmp/winiso
mount <path to windows 10 iso> /tmp/winiso
# Create Split WIM files
wimsplit /tmp/winiso/sources/install.wim install.swm 2048
@nathanjackson
nathanjackson / gist:04ccbd496e4f2a13a9c282c664929a1d
Created April 19, 2020 17:53
Fix corrupt background in gnome shell after sleeping with an nvidia gpu
dbus-send --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval "string:global.reexec_self()"
mkisofs -iso-level 3 -o <ISO Filename> -V <Disc Title> <File 1> .. <File N>
growisofs -speed 16 -Z /dev/sr0=<ISO Filename>
@nathanjackson
nathanjackson / gist:c561813eac6a645882a66965bc1852f1
Created August 23, 2021 18:15
Completely Poweroff NVIDIA on MSI GS65 Stealth
# For some reason, the native power management features of the NVIDIA card in the MSI GS65 Stealth don't seem to completely
# power down the card. This sucks because the GPU still consumes lots of power even when idle, reducing the battery life
# to about an hour.
# My workaround on Fedora 32/34 is this:
# 1. Install RPMFusion NVIDIA drivers.
# 2. Install the bbswitch driver (https://copr.fedorainfracloud.org/coprs/chenxiaolong/bumblebee/)
# 3. Configure bbswitch module to shutdown card on load.
# 4. Blacklist all nvidia drivers in the GRUB boot menu.
@nathanjackson
nathanjackson / interview.py
Created March 18, 2022 17:41
Python Refactoring/Testing Interview Question
# This script requests the RSS feed for phoronix.com and outputs the latest
# news items into a CSV file.
#
# It is not particularly well written, and if it were part of a real project,
# it would be awkward to test in an automated way.
#
# How would you refactor (change) this code to make it more testable for fuzzing or unit testing?
#