Skip to content

Instantly share code, notes, and snippets.

@AlexKordic
AlexKordic / gpu_fan.py
Created March 22, 2024 17:36
Script to control nvidia GPU fan speed.
import pynvml, time
from pynvml import *
TEMP_MIN_VALUE = 30.0 # fan is around 30%
TEMP_MAX_VALUE = 65.0 # fan is at 100% onwards
TEMP_RANGE = TEMP_MAX_VALUE - TEMP_MIN_VALUE
def fanspeed_from_t(t):
if t <= TEMP_MIN_VALUE: return 0.0
if t >= TEMP_MAX_VALUE: return 1.0
return (t - TEMP_MIN_VALUE) / TEMP_RANGE
@AlexKordic
AlexKordic / .bashrc
Created March 26, 2020 12:06 — forked from hyfen/.bashrc
Save unlimited bash history in OSX
# save history to ~/.bash_history as soon as command is run
export PROMPT_COMMAND='history -a'
# save unlimited history
# osx doesn't seem to respect =-1 or = options
export HISTSIZE=9999999999
export HISTFILESIZE=999999999
# osx doesn't actually respect this and it'll fall back to unix timestamp (which we want)
export HISTTIMEFORMAT="%d/%m/%y %T "
@AlexKordic
AlexKordic / jail.local
Created January 26, 2017 19:53 — forked from Nihisil/jail.local
Send notifications to the Slack from fail2ban
...
action_with_slack_notification = %(banaction)s[name=%(__name__)s, port="%(port)$
slack[name=%(__name__)s]
action = %(action_with_slack_notification)s
...
@AlexKordic
AlexKordic / matrix_bench_ffi.lua
Last active August 29, 2015 14:05
300,000 4x4 matrix multiply inversions
local ffi = require("ffi")
local new = ffi.new
--[[
All numeric calculations are performed with doubles. Using
floats for storage saves memory (for big arrays). But arithmetic
is usually slower due to the required float<->double conversions.
]]
ffi.cdef([[
struct Matrix {
@AlexKordic
AlexKordic / gist:7674932
Created November 27, 2013 12:33
Event dispatch in C++ (Observer) for Sima. Kole asked for Threading bits.
#include <stdio.h>
#include <Windows.h>
#include <process.h>
class IncrementInterface {
public:
virtual int increment(int amount) = 0;
};
@AlexKordic
AlexKordic / gist:7560855
Created November 20, 2013 10:18
insert code in java source as string.
def to_java_multiline_string(txt, indent=1):
formated = ['"' + line.replace('\\', '\\\\').replace('"', '\\"').replace('\t', '\\t') + '\\n"' for line in txt.splitlines()]
separator = "\n{0}+ ".format("".join(["\t"] * indent))
return separator.join(formated)
@AlexKordic
AlexKordic / gist:5821888
Last active December 18, 2015 17:58 — forked from cmer/gist:1566734
apt-get install -y build-essential libx11-dev libgl1-mesa-dev libxext-dev perl perl-modules make
cd /tmp
wget http://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz
tar xzvf UnixBench5.1.3.tgz
cd UnixBench
./Run
========================================================================