This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# switches to strongest known wifi connection using nmcli | |
set -euo pipefail | |
# returns "name:signal:in-use" in order of signal strength | |
conn_strength() { | |
conns=() | |
while IFS= read -r line; do | |
conns+=("$line") | |
done < <(nmcli -t -f name connection show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% https://www.json.org/json-en.html | |
:- use_module(library(dcgs)). | |
:- use_module(library(lists)). | |
json --> element. | |
value --> object. | |
value --> array. | |
value --> string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copyright <YEAR> <COPYRIGHT HOLDER> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; To compile: | |
; nasm -f elf32 -o uri-enc.o uri-enc.asm | |
; ld -m elf_i386 -o uri-enc uri-enc.o | |
section .bss | |
LenInp equ 1024 | |
BufInp: resb LenInp | |
LenOut equ 4096 | |
BufOut: resb LenOut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package try // https://github.com/dnmfarrell/try | |
import ( | |
"fmt" | |
"io" | |
"os" | |
) | |
// based on: | |
// https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
grep '^Charging$' /sys/class/power_supply/BAT0/status >/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Linux::Smaps; | |
sub print_memusage { | |
my $smaps = Linux::Smaps->new; | |
printf "% 6s % 9d % 9d KB % 9d KB\n", $_[0], $$, $smaps->rss, $smaps->pss; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* wchar.c - read a wide character with ncurses and print it on the screen | |
* gcc -Wall $(pkg-config --cflags ncursesw) -o wchar wchar.c $(pkg-config --libs ncursesw) | |
* ./wchar | |
*/ | |
#include <curses.h> | |
#include <locale.h> | |
int main(void) | |
{ | |
setlocale(LC_ALL, ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate Sierpiński's triangle | |
// 0********************************************************************2 | |
// ****** ****** ****** ****** ****** ******* ****** ****** | |
// ************ ************ ************ ************ | |
// ********* ********* ******** ********* | |
// ***** ****** ****** ****** | |
// ******************** ******************* | |
// **************** ******** ******** | |
// ***** **** ***** **** | |
// ********** *********** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct List { | |
int n; | |
void *next; | |
} List; | |
List* ListNew (int n) { | |
List *l = malloc(sizeof(List)); |
NewerOlder