Skip to content

Instantly share code, notes, and snippets.

@Ape
Ape / vaihtoraha.py
Last active September 23, 2015 14:39
vaihtoraha
#!/usr/bin/env python3
rahat = [
(10, "kymppiä"),
(5, "vitosta"),
(2, "kaksieuroista"),
(1, "euroa")
]
hinta = int(input("Ostosten hinta: "))
@Ape
Ape / cvimrc
Last active March 22, 2016 11:57
cvimrc
set numerichints
set typelinkhints
set noautofocus
set manualcompletion
let barposition = "bottom"
unmap x
map d closeTab
map u :restore<Space>
map <C-u> scrollPageUp
map <C-d> scrollPageDown
@Ape
Ape / hash-shader.glsl
Last active August 29, 2015 14:17
Kuku Kube Compositing Shader
// 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);
@Ape
Ape / hidraw_test.py
Created January 26, 2014 10:29
DualShock 4 driver test using python
import os
device_path = '/dev/hidraw7'
fd = os.open(device_path, os.O_RDWR)
report = bytearray(78)
report[0] = 0x11
report[1] = 128
@Ape
Ape / hidraw_test.c
Last active January 4, 2016 13:49
DualShock 4 driver test using C
#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;
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()