Skip to content

Instantly share code, notes, and snippets.

View RauliL's full-sized avatar

Rauli Laine RauliL

View GitHub Profile
#include <initializer_list>
#include <string>
std::string JoinPath(const std::initializer_list<std::string>& parts)
{
#if defined(_WIN32)
static const char separator = '\\';
#else
static const char separator = '/';
#endif
@RauliL
RauliL / use-prefer-dark-mode.ts
Created August 22, 2021 12:52
React hook for determining whether user prefers dark mode or not
export const usePreferDarkMode = (): boolean => {
const [darkMode, setDarkMode] = useState<boolean>(
window.matchMedia
? window.matchMedia('(prefers-color-scheme: dark)').matches
: false
);
useEffect(() => {
const mediaQueryList = window.matchMedia
? window.matchMedia('(prefers-color-scheme: dark)')
@RauliL
RauliL / TURN-OFF-CAPSLOCK.c
Created June 24, 2021 06:51
CLI utility for turning off capslock
/* Kompilera med: cc TURN-OFF-CAPSLOCK.c -lX11 -o TURN-OFF-CAPSLOCK */
#include <stdlib.h>
#include <stdio.h>
#include <X11/X.h>
#include <X11/XKBlib.h>
int main()
{
Display* display;
// ==UserScript==
// @name Ask.fm mandatory registration removal
// @description Removes the mandatory registration requirement from Ask.fm
// @version 1.0
// @include https://ask.fm/*
// ==/UserScript==
(() => {
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
@RauliL
RauliL / raattori.js
Created August 5, 2020 10:51
Deobfuscated Turkuraattori
export default class Raattori {
constructor() {
this.sanat = {
minä: "mää",
sinä: "sää",
minäkin: "määki",
sinäkin: "sääki",
tämä: "tää",
tuo: "toi",
nuo: "noi",
@RauliL
RauliL / uuniperunat.md
Created April 5, 2020 07:03
Kreikkalaiset uuniperunat
  • Perunaa
  • Sipulia
  • Sitruunaa
  • Oliiviöljy
  • Oregano
  • Suola
  • Vettä

Lisäksi jos haluaa lisää makua:

  • Valkosipulia
@RauliL
RauliL / install.sh
Created September 5, 2018 16:21
Neatgear A6210 driver installation on Linux 4.15
git clone git@github.com:kaduke/Netgear-A6210.git
cd Netgear-A6210
git fetch origin port-to-4.15
git checkout port-to-4.15
make
sudo make install
# At this point you need to restart network-manager before plugging in
# the device.
sudo service network-manager restart
@RauliL
RauliL / README.md
Created April 5, 2018 22:34
Microsoft Natural Ergonomic Keyboard 4000 settings on Ubuntu

This is just my personal setup of the Microsoft Natural Ergonomic Keyboard 4000 on Ubuntu which does various remappings that I like.

Create new file /etc/udev/hwdb.d/61-keyboard-local.hwdb and insert following there:

# Microsoft Natural Ergonomic Keyboard 4000 - remap zoom in/out to up/down
evdev:input:b0003v045Ep00DB*
 KEYBOARD_KEY_c022d=up
 KEYBOARD_KEY_c022e=down
diff --git a/src/parse-query.js b/src/parse-query.js
index 2033083..1d7e21e 100644
--- a/src/parse-query.js
+++ b/src/parse-query.js
@@ -10,7 +10,7 @@ export const parseQuery = (query) => {
let id = null;
let className = null;
let mode = TAG_NAME;
- let buffer = '';
+ let previousOffset = 0;
@RauliL
RauliL / class.plorth
Created August 27, 2017 16:48
Range implementation in Plorth + Class framework
: class
swap class-create swap tuck "-prototype" + tuck const " new" + compile swap
>symbol swap >word define
;
: class-extends
"prototype" swap @ nip rot "__proto__" swap ! class
;
: class-create