This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
action_with_slack_notification = %(banaction)s[name=%(__name__)s, port="%(port)$ | |
slack[name=%(__name__)s] | |
action = %(action_with_slack_notification)s | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <Windows.h> | |
#include <process.h> | |
class IncrementInterface { | |
public: | |
virtual int increment(int amount) = 0; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
======================================================================== |