Skip to content

Instantly share code, notes, and snippets.

View fikovnik's full-sized avatar

Filip Krikava fikovnik

View GitHub Profile
@fikovnik
fikovnik / getxkblayout.c
Created February 7, 2018 09:43
Get keyboard layout using X11
// compile with `gcc -I/usr/include getxkblayout.c -lX11 -lxkbfile`
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
int main(int argc, char **argv) {
Display *dpy = XOpenDisplay(NULL);
@fikovnik
fikovnik / tracer.c
Created February 5, 2024 14:48
Intercept syscalls of a child process using ptrace
#include <stdio.h>
#include <sys/ptrace.h>
#include <sys/reg.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
int status;
pid_t child_pid = fork();
@fikovnik
fikovnik / install.sh
Last active June 7, 2023 09:01
Install dotfiles
#!/bin/bash -x
BACKUP_DIR="$HOME/.dotfiles-backup"
[ -d $HOME/.dotfiles ] || git clone --bare https://github.com/fikovnik/dot-files.git $HOME/.dotfiles
function config {
git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@
}
@fikovnik
fikovnik / org-insert-clipboard-image.el
Created December 14, 2018 14:25
org-insert-clipboard-image
(defun org-insert-clipboard-image ()
(interactive)
(setq dir (concat (file-name-directory (buffer-file-name)) "resources"))
(unless (file-directory-p dir) (make-directory dir))
(setq filename
(concat dir
"/"
(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))
"-"
(format-time-string "%Y%m%d-%H%M%S")
@fikovnik
fikovnik / build.gradle
Created May 8, 2016 19:58
Building maven plugins by gradle
configurations {
mavenEmbedder
}
dependencies {
compile "org.apache.maven:maven-core:$mavenVersion"
compile "org.apache.maven:maven-plugin-api:$mavenVersion"
compile 'org.apache.maven.plugin-tools:maven-plugin-annotations:3.4'
mavenEmbedder "org.apache.maven:maven-embedder:$mavenVersion"
@fikovnik
fikovnik / configuration.nix
Last active July 12, 2022 06:29
NixOS on DELL XPS 13 9360
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@fikovnik
fikovnik / tg2p.st
Created December 20, 2021 08:42 — forked from jdevoo/tg2p.st
Not so Terse Guide to Pharo
"**************************************************************************
* Allowable characters: *
* - a-z *
* - A-Z *
* - 0-9 *
* - .+/\*~<>@%|&? *
* - blank, tab, cr, ff, lf *
* *
* Variables: *
* - variables must be declared before use *
@fikovnik
fikovnik / r-build.sh
Created October 11, 2021 12:41
Build R
#!/bin/sh
export CXXFLAGS="-O2 -ggdb3"
export CPPFLAGS="-O2 -ggdb3"
export CFLAGS="-O2 -ggdb3"
export R_KEEP_PKG_SOURCE=yes
export CXX="g++"
./configure --with-blas --with-lapack --without-ICU --with-x \
--with-tcltk --without-aqua --with-recommended-packages \
@fikovnik
fikovnik / r-build-gdb.sh
Created October 11, 2021 12:29
Build R for debugging
#!/bin/sh
export CXXFLAGS="-O0 -ggdb3"
export CPPFLAGS="-O0 -ggdb3"
export CFLAGS="-O0 -ggdb3"
export R_KEEP_PKG_SOURCE=yes
export CXX="g++"
./configure --with-blas --with-lapack --without-ICU --with-x \
--with-tcltk --without-aqua --with-recommended-packages \
@fikovnik
fikovnik / build.gradle
Created May 8, 2016 20:45
Synchronize maven repository from gradle module dependencies
task syncMavenRepository(type: JavaExec) {
classpath = configurations.mavenEmbedder
main = 'org.apache.maven.cli.MavenCli'
systemProperties['maven.multiModuleProjectDirectory'] = projectDir
args = [
'--errors',
'--batch-mode',
'--settings', '../config/repo-settings.xml',
'--file', "${buildDir}/pom.xml",
"org.apache.maven.plugins:maven-dependency-plugin:2.10:go-offline"