Skip to content

Instantly share code, notes, and snippets.

Keyvan Fatehi kfatehi

View GitHub Profile
View nvidia.js
const { exec } = require('child_process');
const getGPUList = async () => {
return new Promise(function(resolve, reject) {
exec('nvidia-smi -L', (err, stdout, stderr) => {
if (err) return reject(err);
let gpuMap = stdout.trim().split('\n').reduce((acc, line)=>{
let [_, numStr, uuid] = line.match(/GPU (\d+):.+UUID: (.+)\)/)
return {...acc, [uuid]: numStr}
}, {});
View autofan.js
const nvidia = require('./src/nvidia');
const TARGET_TEMP = 69;
let timeouts = [];
let interval = null;
async function autofan(gpus, uuid, tempTarget) {
const tick = async () => {
let gpu_int = gpus[uuid];
View gist:07bdef95c132215598a23caf4ce7c2f5
set -exuo pipefail
LIVESTREAM_URL=$1
if [[ ! $# -eq 1 ]]; then
echo "usage: $0 <URL>"
exit 1
fi
# Referencing FFMpeg to Icecast2 Streaming Sample Gist: https://gist.github.com/keiya/c8a5cbd4fe2594ddbb3390d9cf7dcac9
URL=$(streamlink $LIVESTREAM_URL worst --stream-url)
channels=2
@kfatehi
kfatehi / PKGBUILD
Last active Mar 23, 2018
ripcord PKGBUILD
View PKGBUILD
# Basing this off upwork-appimage.git and gulden-appimage
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=gulden-appimage
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=upwork-appimage
_pkgname=ripcord
_upkgname=Ripcord
pkgname=ripcord-appimage
pkgver=0.2.83
pkgrel=1
pkgdesc="A desktop chat client for Discord (and soon Slack)"
arch=('x86_64')
@kfatehi
kfatehi / tmux_build_from_source_CentOS.sh
Created Mar 14, 2018 — forked from P7h/tmux__CentOS__build_from_source.sh
tmux 2.0 and tmux 2.3 installation steps for Ubuntu. Or build from tmux source v2.5 for Ubuntu and CentOS.
View tmux_build_from_source_CentOS.sh
# Steps to build and install tmux from source.
# Takes < 25 seconds on EC2 env [even on a low-end config instance].
VERSION=2.6
sudo yum -y remove tmux
sudo yum -y install wget tar libevent-devel ncurses-devel
wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz
tar xzf tmux-${VERSION}.tar.gz
rm -f tmux-${VERSION}.tar.gz
cd tmux-${VERSION}
View gist:6b4481054a953cb9af17393b6f4c0ba2
#include <SimpleTimer.h>
SimpleTimer timer;
int outPin = 9; // output pin (relay)
int inPin = 8; // choose the input pin (for a pushbutton)
int outVal = LOW;
int val = 0; // variable for reading the pin status
int prevVal = 0;
@kfatehi
kfatehi / server.js
Created Nov 29, 2017
fireplace server
View server.js
root@fireplace:~# cat server.js
var fs = require('fs');
var http = require('http');
const PORT=80;
function write(file, content) {
try {fs.writeFileSync(file, content)}
catch (err) {console.error(err.message)}
}
@kfatehi
kfatehi / keyport-barcode.sh
Created Sep 13, 2017
Generates a PDF from a barcode string for the Keyport Barcode Insert Raw
View keyport-barcode.sh
#!/bin/bash
# Generates a PDF from a barcode string
# in the dimensions expected for a Keyport Barcode Insert
# https://www.mykeyport.com/barcode-insert
# You may need to set SYMBOLOGY and/or remove -c (checksum)
# depending on which barcode you're creating
SIZE="1.3x0.35"
UNITS="in"
SYMBOLOGY=${SYMBOLOGY:-"39"}
CODE="$1"
@kfatehi
kfatehi / prs.js
Created Mar 14, 2017
list pull requests across entire organization
View prs.js
var Promise = require('bluebird')
var GitHubApi = require("github");
const org = "matrix-hacks";
var github = new GitHubApi({ Promise });
github.repos.getForOrg({ org, type: 'sources' })
.then(res=>res.data.map(i=>i.name))
.then(repos=>{
@kfatehi
kfatehi / gen-docset.sh
Created Mar 12, 2017
generate matrix-js-sdk docset
View gen-docset.sh
#!/bin/bash
set -e
DOCSET_NAME="MatrixJSSDK"
cat <<EOF > docset-config.json
{
"docset" : {
"name": "$DOCSET_NAME",
"icon": "scripts/icon.png"
}
}
You can’t perform that action at this time.