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
// Run this with Compton | |
// compton --backend glx --force-win-blend --glx-fshader-win "$(cat hash-shader.glsl)" | |
uniform float opacity; | |
uniform bool invert_color; | |
uniform sampler2D tex; | |
// HSV conversion taken from http://stackoverflow.com/a/17897228 | |
vec3 rgb2hsv(vec3 c) { | |
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); |
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 | |
class Kartta: | |
def __init__(self, koko, auto): | |
self.koko = koko | |
self.auto = auto | |
def tulosta(self): | |
for rivinumero in reversed(range(1, self.koko + 1)): | |
print(self._rivi(rivinumero)) |
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 | |
rahat = [ | |
(10, "kymppiä"), | |
(5, "vitosta"), | |
(2, "kaksieuroista"), | |
(1, "euroa") | |
] | |
hinta = int(input("Ostosten hinta: ")) |
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 | |
import collections | |
print("Syötä viestin tekstirivejä. Lopeta syöttämällä tyhjä rivi.") | |
teksti = "" | |
while True: | |
syöte = input() |
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 | |
import sys | |
MOVES = { | |
">": ( 1, 0), | |
"<": (-1, 0), | |
"^": ( 0, 1), | |
"v": ( 0, -1), | |
} |
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 | |
import functools | |
import sys | |
OPERATORS = { | |
None: lambda arg: arg(0), | |
"NOT": lambda arg: ~arg(1), | |
"AND": lambda arg: arg(0) & arg(2), | |
"OR": lambda arg: arg(0) | arg(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
#!/usr/bin/env python3 | |
import itertools | |
import sys | |
lines = (x.split(" ")[::2] for x in sys.stdin.readlines()) | |
routes = {frozenset(x[:2]): int(x[2]) for x in lines} | |
places = set.union(*(set(x) for x in routes.keys())) | |
path_len = lambda path: sum(routes[frozenset(x)] for x in zip(path, path[1:])) | |
lengths = [path_len(x) for x in itertools.permutations(places)] |
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
pkt = bytearray(b'\x11\x80\x00\xff\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') | |
device = open('/dev/hidraw7', 'wb') | |
device.write(pkt) | |
device.close() |
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
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
int main(int argc, char **argv) { | |
if (argc != 2) { | |
printf("Usage: %s hidraw_device\n", argv[0]); | |
return 0; |
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 | |
device_path = '/dev/hidraw7' | |
fd = os.open(device_path, os.O_RDWR) | |
report = bytearray(78) | |
report[0] = 0x11 | |
report[1] = 128 |
OlderNewer