This file contains 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
#!/bin/sh | |
GPU_query="\033[34mGPU\033[0m » $(nvidia-smi --query-gpu=gpu_name,pstate,utilization.gpu,utilization.memory,temperature.gpu --format=csv,noheader|sed 's/,/ |/g') °C" | |
i3status | while : | |
do | |
read line | |
echo -e "$GPU_query | \033[34mCPU\033[0m » $line" || exit 1 | |
done |
This file contains 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# ref: https://github.com/i3/i3status/blob/master/contrib/wrapper.py | |
# | |
# To use it, ensure your ~/.i3status.conf contains this line: | |
# output_format = "i3bar" | |
# in the 'general' section. | |
# Then, in your ~/.i3/config, use: | |
# status_command i3status | ~/i3status/contrib/wrapper.py |
This file contains 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 os, re, sys, itertools, linecache, json | |
parse = lambda pattern, array, ctor: map(ctor, filter(bool, map(re.compile(pattern).match, array))) | |
scan = lambda fname: itertools.takewhile(lambda l:len(l), (linecache.getline(fname, i) for i in itertools.count(1))) | |
print json.dumps(dict(parse(r'^\./.*(V[^/]+)/(\d+)/log\.K=(\d+),P=(\d+)$', | |
(os.path.join(root,file) for root, dirs, files in itertools.chain.from_iterable(os.walk(path) for path in sys.argv[1:]) for file in files), | |
lambda m: ('/'.join(m.groups()), (lambda (f,a):{ | |
'parse_s': f('File parsed in (.*)s'), | |
'partition_ms': f('Partitioned in (.*)ms'), 'merge_ms': f('Merged in (.*)ms'), | |
'total_ms': f('Total time finding the vector (.*)ms'), | |
'user_s': f(r'\s*User time.*: (.*)'), 'sys_s': f(r'\s*System time.*: (.*)'), |
This file contains 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
ME=aleozlx | |
useradd ${ME} | |
echo "${ME} All=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/${ME}" | |
mkdir -pv "/home/${ME}/.ssh" | |
echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIxMOh1s9+bMx+BrsZ9gnvUeMXfTYP2pYM96weaZ+GUl [email protected]' >> "/home/${ME}/.ssh/authorized_keys" | |
echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH28Ycjjv1L+BVsycPK/gTittc3Xv9ENpAOPfkfM20dy alex@latitude-5289' >> "/home/${ME}/.ssh/authorized_keys" | |
chown -R ${ME}:${ME} "/home/${ME}" | |
chmod 700 "/home/${ME}/.ssh" | |
chmod 600 "/home/${ME}/.ssh/authorized_keys" |
This file contains 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
mkdir -p /root/.ssh | |
echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIxMOh1s9+bMx+BrsZ9gnvUeMXfTYP2pYM96weaZ+GUl [email protected]' >> /root/.ssh/authorized_keys | |
echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH28Ycjjv1L+BVsycPK/gTittc3Xv9ENpAOPfkfM20dy alex@latitude-5289' >> /root/.ssh/authorized_keys | |
chmod 700 /root/.ssh | |
chmod 600 /root/.ssh/authorized_keys | |
sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config | |
systemctl restart sshd |
This file contains 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
# yum -y install sudo | |
ME=ansible | |
useradd ${ME} | |
mkdir -p "/home/${ME}" | |
echo "${ME} All=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/${ME}" | |
mkdir -pv "/home/${ME}/.ssh" | |
echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIxMOh1s9+bMx+BrsZ9gnvUeMXfTYP2pYM96weaZ+GUl [email protected]' >> "/home/${ME}/.ssh/authorized_keys" | |
chown -R ${ME}:${ME} "/home/${ME}" | |
chmod 700 "/home/${ME}/.ssh" | |
chmod 600 "/home/${ME}/.ssh/authorized_keys" |
This file contains 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 os; os.system('mkdir -p /tmp/rabbithole && cd /tmp/rabbithole && ln -sf . 0 && ln -sf . 1'); [print(i[0]) for i in os.walk('.', followlinks=True)] |
This file contains 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
// Played with vector fields at https://anvaka.github.io/fieldplay | |
float phi(float x) { | |
return 1./(1.+exp(-x)); | |
} | |
vec2 get_velocity(vec2 p) { | |
vec2 v = vec2(0., 0.); | |
float pi = 3.14159; | |
float alpha = pi/2.*phi(length(p)-2.*pi)+pi/2.; |
This file contains 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
#!/bin/bash | |
CONTAINER_NAME="vscode" | |
PORT=8000 | |
if ! $(docker ps | grep -q $CONTAINER_NAME); then | |
docker run -it -d --rm --name $CONTAINER_NAME -u $(id -u) -p "$PORT:8080" -v "$(pwd):/home/coder/project" codercom/code-server | |
sleep 3 | |
fi |
This file contains 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
__device__ char * | |
get_pixel_uv(char *pDevPtr, int pitch, int row, int col) { | |
return pDevPtr + row * pitch + col * 2; | |
} | |
__device__ char * | |
get_pixel_y(char *pDevPtr, const int pitch, const int row, const int col, const int width, const int height) { | |
if (col >= 0 && row >= 0 && col < width && row < height) { | |
return pDevPtr + row * pitch + col; | |
} else { |