Skip to content

Instantly share code, notes, and snippets.

View oprypin's full-sized avatar

Oleh Prypin oprypin

View GitHub Profile
@oprypin
oprypin / xonshrc.py
Last active March 17, 2022 22:14
Display execution time of last command
last_duration = 0
_orig = __xonsh_history__.append
def _append(cmd):
nonlocal last_duration
last_duration = cmd['ts'][1] - cmd['ts'][0]
_orig(cmd)
__xonsh_history__.append = _append
def succ(s):
a = list(s)
for i in reversed(range(len(a))):
a[i] = chr(ord(a[i]) + 1)
if a[i] <= 'z':
break
a[i] = 'a'
else:
a.insert(0, 'a')
return ''.join(a)
@oprypin
oprypin / eval.cr
Last active April 5, 2016 10:53
Print last expression in a Crystal program
require "compiler/crystal/syntax"
def transform_eval(source)
ast = Crystal::Parser.parse(source)
unless ast.is_a?(Crystal::Expressions)
ast = Crystal::Expressions.new([ast])
end
exprs = (ast as Crystal::Expressions).expressions
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 355.11 (buildmeister@swio-display-x86-rhel47-07) Wed Aug 26 17:14:39 PDT 2015
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 355.11 (buildmeister@swio-display-x86-rhel47-07) Wed Aug 26 17:15:49 PDT 2015
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
@oprypin
oprypin / _.md
Last active February 6, 2016 16:27
Games confirmed working on Linux without a SteamOS icon on Steam
@oprypin
oprypin / video-driver.service
Last active January 15, 2016 14:56
Choose an appropriate video driver for Arch Linux that can be booted directly or from a virtual machine
[Unit]
Description=Choose an appropriate driver
Before=display-manager.service
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'systemd-detect-virt && d=mesa || d=nvidia; d="$d-libgl lib32-$d-libgl"; pacman -Q $d || yes | pacman -S --needed $d'
RemainAfterExit=yes
[Install]
@oprypin
oprypin / pixel.py
Last active January 13, 2016 15:10
#!/usr/bin/env python2
# Requirements: Python, PyGTK, seems like it wants NumPy as well
# Arch Linux: pygtk, python2-numpy
# Use `xdotool getmouselocation` to find coordinates
coords = (1864, 185)
@oprypin
oprypin / store.py
Last active December 3, 2015 11:13
File-based integer key-value store
import struct
store_fn = 'store'
#key_bits = 16
#value_bits = 16
#struct_format = 'H'
key_bits = 32
value_bits = 32
struct_format = 'I'
@oprypin
oprypin / 1.sh
Last active October 31, 2015 20:38
alias rm false
parted /dev/?da
mklabel msdos
mkpart primary ext4 1MiB 100%
set 1 boot on
quit
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
import functools
from flask import Flask, g
app = Flask(__name__)
languages = ['en', 'hr']
def translate_to(lang, text):
return {
'/about': {
'hr': '/onama',