Skip to content

Instantly share code, notes, and snippets.

View oprypin's full-sized avatar

Oleh Prypin oprypin

View GitHub Profile
@oprypin
oprypin / _license.md
Last active March 24, 2020 14:32
Open links in the host OS when clicking them in the guest OS (VirtualBox)

The MIT License (MIT)

Copyright (C) 2015 Oleh Prypin [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

import functools
from flask import Flask, g
app = Flask(__name__)
languages = ['en', 'hr']
def translate_to(lang, text):
return {
'/about': {
'hr': '/onama',
@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
@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 / 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 / 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 / _.md
Last active February 6, 2016 16:27
Games confirmed working on Linux without a SteamOS icon on Steam
# 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 / 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
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)