Skip to content

Instantly share code, notes, and snippets.

@rindeal
rindeal / find_outdated_desktop_files.sh
Last active March 4, 2016 14:15
Find outdated .desktop files
#!/bin/bash -
grep -a -r -P -o '(?:(?<=Exec=)([^"]\S+)|(?<=Exec=")(\S+)(?="))' \
-- /{usr,home/*/.local}/share/applications | sort -u | \
while read m; do
desktop_file="${m%:*}"
exec_name="${m##*:}"
if ! command -v "$exec_name" 2>&1 >/dev/null; then
echo "$desktop_file|$exec_name"
@rindeal
rindeal / interrupts_stats.sh
Last active July 26, 2018 13:49
Pretty print /proc/interrupts
#!/bin/sh
sed -r -e 's/^ *//' -e 's/ {2,}/|/g' < /proc/interrupts | \
awk -F'|' '
BEGIN { cpu_n = 0; }
NR == 1 {
for(i = 1; i <= NF; i++)
if($i ~ CPU)
cpu_n++;
}
@rindeal
rindeal / LinDiophantineEqSolver.c
Last active April 19, 2024 11:36
Linear Diophantine Equation Solver, includes calculations of coefficients of Bézout's identity and extended Euclidean algorithm for greatest common divisor.
int64_t
GCD(int64_t const a, int64_t const b)
{
register int64_t rt, r0 = a, r1 = b; // remainder
while (r1 != 0){
// classic Euclidean algorithm
rt = r1;
r1 = r0 % r1;
r0 = rt;
@rindeal
rindeal / matrixish.sh
Created November 6, 2015 13:11
Matrixish
#!/bin/bash
#
# matrix: matrix-ish display for Bash terminal
# Author: Brett Terpstra 2012 <http://brettterpstra.com>
# Contributors: Lauri Ranta and Carl <http://blog.carlsensei.com/>
#
# A morning project. Could have been better, but I'm learning when to stop.
### Customization:
blue="\033[0;34m"
@rindeal
rindeal / wrapper.sh
Last active March 13, 2016 19:09
ar/nm/ranlib wrapper for LTO
#!/bin/sh
DEBUG=0
[ "${DEBUG}" -eq 1 ] && set -x
CC=${CC:-"/usr/bin/gcc"}
lto_wrapper="$( $CC -v 2>&1 | /bin/awk -F= '/COLLECT_LTO_WRAPPER/{print $2}' )"
plugin_dir="${lto_wrapper%/*}"
util="${0##*/}"
@rindeal
rindeal / leap.c
Last active July 2, 2020 16:57
IsLeapYear()
#include <stdbool.h>
#include <assert.h>
/**
* Modified version of https://stackoverflow.com/a/11595914/2566213
* with 4000th check added.
*/
bool
IsLeapYear(const int y)
{
@rindeal
rindeal / screenfetch_all.sh
Created May 22, 2015 01:10
Runs screenfetch utility for all known distros
#!/bin/bash
DISTROS=()
DISTROS+=('Antergos')
DISTROS+=('Arch Linux')
DISTROS+=('Arch Linux - Old')
DISTROS+=('BLAG')
DISTROS+=('CentOS')
DISTROS+=('Chakra')
@rindeal
rindeal / opcode.sh
Last active December 28, 2016 11:21
opcode.sh - Searches disassembled code for specific instructions.
#!/bin/bash
#
# Last update on Nov 05, 2014.
#
# Searches disassembled code for specific instructions.
#
# Opcodes obtained from: https://github.com/Shirk/vim-gas/blob/master/syntax/gas.vim
#
# List of opcodes has been obtained using the following commands and making a few modifications:
# echo '#!/bin/bash' > Opcode_list
@rindeal
rindeal / uncrustify-c-cpp.cfg
Last active August 17, 2025 05:25
Uncrustify C/C++ config
# -------------------------------------------------------------------------------------------------#
# #
# _ _ _ _ __ ___ _____ _ _ __ _ #
# | | | |_ _ __ _ _ _ _ __| |_(_)/ _|_ _ / __| / / __|| |_ _| |_ __ ___ _ _ / _(_)__ _ #
# | |_| | ' \/ _| '_| || (_-< _| | _| || | | (__ / / (_|_ _|_ _| / _/ _ \ ' \| _| / _` | #
# \___/|_||_\__|_| \_,_/__/\__|_|_| \_, | \___/_/ \___||_| |_| \__\___/_||_|_| |_\__, | #
# |__/ |___/ #
# #
# -------------------------------------------------------------------------------------------------#
# #
@rindeal
rindeal / cpuid-dump.c
Last active December 26, 2024 16:58
CPUID dumper
#if !defined(__GNUC__) || ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800)
# error "This program requires GNU C compiler v4.8+!"
#endif
#include <stdio.h>
#include <stdbool.h>
#define PRINT_TEST_CPU_SUPPORT_RESULT(inst) printf("\t%-7s: %d\n", inst, __builtin_cpu_supports(inst)?1:0)
#define PRINT_TEST_CPU_TYPE_RESULT(inst) printf("\t%-12s: %d\n", inst, __builtin_cpu_is(inst)?1:0)