Skip to content

Instantly share code, notes, and snippets.

@d3rp
d3rp / .ideavimrc
Last active January 13, 2022 10:39
CLion idea-vim configuration
"" Source your .vimrc
source ~/.vimrc
" Show a few lines of context around the cursor. Note that this makes the
" text scroll if you mouse-click near the start or end of the window.
set scrolloff=5
" Do incremental searching.
set incsearch
tl;dr: How to fight the formation of spaghetti code, when designing a configuration/settings
class, and make it feel intuitive.
I was toying around with my hobby project and came across a wrapper library for
libcurl. At first I was a little annoyed with its SSL handling and its seemingly
complicated way of setting it up. As I figured out how the configuration parameters
were supposed to be inserted in order to get things going, its ways seemed actually
pretty useful. Also I noticed, that apparently there's such a thing as a variadic
std::forward.

General eli kenraalihuomiot

Olin oudon innostunut toteutuksesta ja UXstä. Mutustelin univelkani aiheuttajaa, Crusader Kings II:sta ja sen orkestraalista taustamusaa excel-mäisellä pelielämyksellä, ja jotenkin löysin itseni tästä maisemasta tutoriaalia tutkaillessa - oikein maistuva. Oli käytetty paljon sellasta kerrontaa, josta ite tykkään. Selostus oli selkeetä ja sopivan kevyttä syventymättä liikaa yksityiskohtiin. Käsiteltäviä kontrolleja oli maltillisesti kerrallaan tutoriaalia kohden. Musta on hyvä, että vaikka ympärillä tapahtuisi kaikenlaista - attack on jossain kohden, moodi voi olla hard, jne. - niin silti keskitytään vain muutamaan asiaan kerrallaan.

Veikkaan, että ton saisi vielä paremmaksi. Monta erittäin hyvää kohtaa löyty, mutta olen tässä alleviivannut lähinnä mieleen juolahtaneet kehityskohteet.

Jaoteltuna kärkeen yleisluontoiset ja ehkä hyödyllisemmät huomiot näistä turinoistani. Sen jälken joitain muita, vähemmän keskeisiä huomioita ja lopuksi tutoriaalikohtainen step-wise analyysi.

@d3rp
d3rp / speak-keys
Created May 2, 2020 05:48
speak written words curses playground
#!/usr/bin/env python3
import curses
import subprocess
import time
import pyttsx3
from functools import partial
KEY_DELAY = 250 #ms
SPEACH_SPEED = 175 # default 175
speak_cmd = ['espeak', '-v', 'fi', '-s', str(SPEACH_SPEED)]
@d3rp
d3rp / gist:a1c3da389f5863d779c90b70e7fe03b9
Created September 9, 2019 13:18
clima usage options
from clima import c
@c
class Foo:
pass
@c
class Bar:
@d3rp
d3rp / class_closure.py
Created August 25, 2019 08:40
Class closure (Kind of a gotcha if done by accident)
"""instance variables gotcha"""
class C:
"""Works like a closure because class body is interpreted at import time"""
data = {}
def __init__(self, input):
self.data.update(input)
c = C({'a':'b'})
@d3rp
d3rp / doc_this.py
Created August 20, 2019 06:16
self reporting class wrapper
import inspect
def dec(f, *args, **kwargs):
def inner(*args, **kwargs):
# TODO: default params from Parameter
# https://docs.python.org/3/library/inspect.html#inspect.Parameter
print(f'{args[0].__class__.__name__}.{f.__name__}(', end='')
if len(args) > 1:
params = list(inspect.signature(f).parameters.keys())[1:]
#!/bin/bash
sudo apt-get -y install g++ \
build-essential \
libcurl4-openssl-dev \
libgtk-3-dev \
pkg-config \
libfreetype6-dev \
libx11-dev \
libxinerama-dev \
libxrandr-dev \