Skip to content

Instantly share code, notes, and snippets.

View oprypin's full-sized avatar

Oleh Prypin oprypin

View GitHub Profile
@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',
@oprypin
oprypin / _license.md
Last active April 18, 2026 07:56
Open links in the host OS when clicking them in the guest OS (VirtualBox)

The MIT License (MIT)

Copyright (C) 2015 Oleh Prypin blaxpirit@gmail.com

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:

module Indexable(T)
def threadpool_map(workers : Int = 8, chunk_size : Int? = nil, &func : T -> R) forall T, R
mutex = Thread::Mutex.new
cs = chunk_size || (self.size**0.5).ceil.to_i
Array(R).build(self.size) do |result|
index = 0
threads = Array.new(workers) {
Thread.new do
a = b = 0
loop do
@oprypin
oprypin / benchmark.md
Last active August 29, 2015 14:27
Benchmark

crystal run --release bm.cr

class unshift pop unshift push shift push push pop unshift shift each insert length/8 insert length*3/5
array 1.405377 0.685335 0.015142 7.018896 0.000162 0.222118 0.101504
deque 0.000901 0.000897 0.021794 0.019965 0.000303 0.151282 0.301467
@oprypin
oprypin / main.cpp
Last active August 29, 2015 14:27
SFML 2.3: gradual drawing of line shapes + erasing
#include <vector>
#include <cmath>
#include <SFML/Graphics.hpp>
#include "roundendedline.hpp"
int main() {
sf::Vector2f cross[][2] = {