Skip to content

Instantly share code, notes, and snippets.

View vomindoraan's full-sized avatar

Konstantin Đorđević vomindoraan

  • Serbia
View GitHub Profile
#!/usr/bin/env bash
# Requires ripgrep to be installed
count_keymaps() {
n_def=$(bash find_default_keymaps.sh $1 | awk 'NF' | wc -l);
n_all=$(bash find_keymaps.sh $1 | awk 'NF' | wc -l);
printf "\nlayout: %s*\n# default keymaps: %d\n# def + user keymaps: %d\n" $1 $n_def $n_all
}
for layout in 60 65 66 68 75 tkl fullsize alice; do
typedef unsigned long REG;
struct IORequest {
REG* buffer;
REG block;
int status;
IORequest* next;
}
IORequest *ioHead = nullptr;
typedef unsigned int REG;
REG* io1Ctrl = ...;
REG* io1Status = ...;
REG* io1
// volatile prevents compiler optimizations
static volatile REG* ioPtr = NULL;
static volatile int ioCount = 0;
static volatile bool ioCompleted = false;
typedef unsigned REG;
struct IORequest {
REG* buffer;
unsigned size;
int status;
IORequest* next;
};
IORequest* head;
struct Node {
Node* leftChild;
Node* rightChild;
Node(Node* left = nullptr, Node* right = nullptr)
: leftChild{left}, rightChild{right}
{}
};
void *(*wrapper)(void *n) {
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define N ...
#define TIMEOUT 5000
int main(int argc, char *argv[]) {
if (argc < 2) {
fputs("Fali argument\n", stderr);
#!/usr/bin/env bash
# Bash
alias diff='diff --color=auto'
alias errcho='>&2 echo'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias ls='ls --color=auto'
alias l='ls -CF'
alias la='ls -A'
/* Bad */
void f1(void) {
if (conditional1) {
action1();
#ifdef COMPILE_OPTION_1
} else if (conditional2) {
action2();
#else
action3();
# Helper functions (lambda world → human-readable world)
to_bool = lambda b: b == true
to_int = lambda i: i(lambda x: x + 1)(0)
bprint = lambda *b: print(*map(to_bool, b))
iprint = lambda *i: print(*map(to_int, i))
# Church booleans
true = lambda x: lambda y: x
from django.core.management import call_command
from django.core.serializers import base, python
from django.db import migrations
def load_fixture(apps, schema_editor):
old_get_model = python._get_model
def _get_model(model_identifier):
try: