Skip to content

Instantly share code, notes, and snippets.

@jaimet
jaimet / scan.awk
Created September 21, 2024 16:13 — forked from elecnix/scan.awk
Parse iw scan output
# iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g' | awk -f scan.awk
$1 == "BSS" {
MAC = $2
print $2
e = wifi[MAC]
e["enc"] = "Open"
}
$1 == "SSID:" {
e = wifi[MAC]
e["SSID"] = $2
@jaimet
jaimet / xinit-precedence.md
Created October 26, 2023 15:54 — forked from deomorxsy/xinit-precedence.md
Xinit's precedence order after invoked with startx

Part I

"If you log in in text mode then start a GUI session with xinit or with the wrapper script startx, then xinit does the following things:

  • Start an X server (typically through the script /etc/X11/xinit/xserverrc).
  • Usually run some scripts in /etc/X11 (typically /etc/X11/xinit/xinitrc), depending on how it's set up.
  • Run ~/.xinitrc, if it exists. If it doesn't exist, run a default client (traditionally xterm).
  • Once ~/.xinitrc terminates, kill the X server.

If you log in in graphical mode on an X display manager (xdm, gdm, kdm, wdm, lightdm, …), traditionally, what is executed after you log in is some scripts in /etc/X11 then ~/.xsession.

@jaimet
jaimet / terminal-control.sh
Created September 29, 2022 18:45 — forked from bcap/terminal-control.sh
Useful terminal control characters
# Terminal output control (http://www.termsys.demon.co.uk/vtansi.htm)
TC='\e['
CLR_LINE_START="${TC}1K"
CLR_LINE_END="${TC}K"
CLR_LINE="${TC}2K"
# Hope no terminal is greater than 1k columns
RESET_LINE="${CLR_LINE}${TC}1000D"
@jaimet
jaimet / libreconverter.py
Created December 14, 2021 17:58 — forked from dylan-lawrence/libreconverter.py
A converter to convert from USA LibreView output to EU LibreView output
#A converter for LibreView exported data, can convert from European or USA output formats
import argparse
#TODO Setup argparse for changing conversion
#2018-13-1
#Currently this script accepts a USA input from argument 1 and converts it to European format.
import sys
@jaimet
jaimet / import.awk
Created December 14, 2021 12:26 — forked from dimalyshev/import.awk
libre
# import.awk - convert LibreView.com csv export to Diabetes:M (Android App) import csv
BEGIN {
FS = "[, ]"
print("name:DIABETES_M","version:2.0.0","export:Entries")
print("DateTimeFormatted","glucose","carbs","proteins","fats","calories","carb_bolus","correction_bolus","extended_bolus","extended_bolus_duration","basal","basal_is_rate","bolus_insulin_type","basal_insulin_type","weight_entry","weight","category","category_name","carb_ratio_factor","insulin_sensitivity_factor","notes","is_sensor","pressure_sys","pressure_dia","pulse","injection_bolus_site","injection_basal_site","finger_test_site","ketones","google_fit_source","timezone","exercise_index","exercise_comment","exercise_duration","medications","food","us_units","hba1c","cholesterol_total","cholesterol_ldl","cholesterol_hdl","triglycerides","microalbumin_test_type","microalbumin","creatinine_clearance","egfr","cystatin_c","albumin","creatinine","calcium","total_protein","sodium","potassium","bicarbonate","chloride","alp","alt","ast","bilirubin",
@jaimet
jaimet / example.svg
Created July 19, 2021 08:39 — forked from hackerb9/example.svg
Extract vector images from funky PDF files
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/* TinyWM is written by Nick Welch <mack@incise.org>, 2005.
* TinyWM-XCB is rewritten by Ping-Hsun Chen <penkia@gmail.com>, 2010
*
* This software is in the public domain
* and is provided AS IS, with NO WARRANTY. */
#include <xcb/xcb.h>
int main (int argc, char **argv)
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main(int argc, char *argv[])
{
unsigned long value;
char *terminatedAt;
@jaimet
jaimet / WinUSBFromLinux.md
Created June 7, 2019 16:49
How to make Windows 7 USB flash install media from Linux?

How to make Windows 7 USB flash install media from Linux?

StackOverflow

  • Install ms-sys - if it is not in your repositories, get it here. Or alternatively, make sure lilo is installed (but do not run the liloconfig step on your local box if e.g. Grub is installed there!)
  • Check what device your USB media is assigned - here we will assume it is /dev/sdb. Delete all partitions, create a new one taking up all the space, set type to NTFS (7), and remember to set it bootable:
# cfdisk /dev/sdb
or fdisk /dev/sdb (partition type 7, and bootable flag)
@jaimet
jaimet / iw_scan.awk
Created February 16, 2019 12:12 — forked from miyl/iw_scan.awk
simplify the output of iw scan
# Based off this answer http://stackoverflow.com/a/17880517/1172409
# Ideally one wouldn't parse the output of iw scan (it may be subject to change),
# but dealing with learning libnl which iw uses seems overly complicated - more so than updating this in case iw does change.
# A few things that could be improved:
# Better padding solution for prettier pretty printing.
# Sort APs based off signal strength from best to worst.
# Usage - iw must be run as root (suggestion: add as an alias in bashrc):
# iw wlp8s0 scan | awk -f scan.awk