Skip to content

Instantly share code, notes, and snippets.

View trappedinspacetime's full-sized avatar
🏠
Working from home

Kenn trappedinspacetime

🏠
Working from home
  • For Personal Use
  • Istanbul
View GitHub Profile
watch --difference=cummulative --interval=1 '(echo device read_IOs read_merges read_sectors read_ticks write_IOs write_merges write_sectors write_ticks in_flight io_ticks time_in_queue; for file in /sys/block/*/stat; do echo -n $file; cat $file; done) | column -t'
# OUTPUTS:
#device read_IOs read_merges read_sectors read_ticks write_IOs write_merges write_sectors write_ticks in_flight io_ticks time_in_queue
#/sys/block/dm-0/stat 116962 0 2212746 314096 7705653 0 150218536 609670232 0 644428 610921004
#/sys/block/dm-1/stat 116479 0 2208882 313324 7686986 0 150218536 609676068 0 644616 611418072
#/sys/block/dm-2/stat 302 0 2416 780 0 0 0 0 0 148 780
#/sys/block/sda/stat 91181 26273 2217246 74876 7314854 388030 150261802 16954364
@trappedinspacetime
trappedinspacetime / youtube-search.sh
Last active June 8, 2021 11:52
search youtube in mpv using mpv-gallery-view script
#!/bin/bash
if xdotool search --class "mpv"; then
echo "process exists"
scbc=$(zenity --entry --title="Youtube" --text="searching for:")
[[ "$?" != "0" ]] && exit 1
echo "{ \"command\": [\"loadfile\", \"ytdl://ytsearch100:$scbc\" ] }" | socat - /tmp/mpvsocket
else
echo "process not exists"
coproc mpv
@trappedinspacetime
trappedinspacetime / gist:8eb3c26e1028a1c2fbb6a8d6998710af
Created May 16, 2021 20:06 — forked from kui/gist:2622504
get the active window on X window system.
// -*- coding:utf-8-unix; mode:c; -*-
//
// get the active window on X window system
//
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <X11/Xlib.h> // `apt-get install libx11-dev`
scbc=$(zenity --entry); sqlite3 ~/Downloads/dictionarytr-en.db "SELECT load_extension('/usr/lib/sqlite3/pcre.so'); SELECT translate.id as id,english.word as word_en,turkish.word as word_tr,type.name as type,category.name as category FROM translate INNER JOIN english ON translate.english_id = english.id INNER JOIN category ON translate.category_id = category.id INNER JOIN type ON translate.type_id = type.id INNER JOIN turkish ON translate.turkish_id = turkish.id WHERE translate.turkish_id IN (SELECT id FROM turkish WHERE word LIKE '$scbc')" 2>&1 | cat -n | zenity --text-info --title "search results..." --width 600 --height 300
@trappedinspacetime
trappedinspacetime / libpng_test.c
Created February 11, 2021 18:09 — forked from niw/libpng_test.c
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng16 libpng_test.c
@trappedinspacetime
trappedinspacetime / main.c
Created February 9, 2021 20:45 — forked from bg1bgst333/main.c
png_read_png#png_read_png
/* ヘッダファイルのインクルード */
/* 既定のヘッダファイル */
#include <stdio.h> /* 標準入出力 */
#include <stdlib.h> /* 標準ユーティリティ */
#include <string.h> /* 文字列処理 */
#include <png.h> /* libpng */
/* 独自のヘッダファイル */
#include "bitmap.h" /* ビットマップ */
/* main関数の定義 */
</proc/net/dev grep -oP "wlp6s0"':\s*(\d+\s+){8}\K\d+' | awk '{x=$1; split("B KB MB GB TB PB",type); for(i=5;y < 1;i--) y = x / (2**(10*i)); printf("%.2f %s\n",y,type[i+2])}'
</proc/net/dev grep -oP "wlp6s0"':\s*(\d+\s+){8}\K\d+' | awk '{ byte =$1 /1024/1024; print byte " MB" }'
</proc/net/dev grep -oP "wlp6s0"':\s*\K\d+' | awk '{x=$1; split("B KB MB GB TB PB",type); for(i=5;y < 1;i--) y = x / (2**(10*i)); printf("%.2f %s\n",y,type[i+2])}'
</proc/net/dev grep -oP "wlp6s0"':\s*\K\d+' | awk '{ byte =$1 /1024/1024; print byte " MB" }'
@trappedinspacetime
trappedinspacetime / configure-gmail-as-relay-smtp
Created December 17, 2020 17:41 — forked from zyzo/configure-gmail-as-relay-smtp
configure gmail as relay smtp using postfix
Steps to configure this server to send mail via gmail relay
1. Download postfix and required packages
sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
2. Configure gmail as relay host : in /etc/postfix/main.cf
relayhost = [smtp.gmail.com]:587
smtpd_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
@trappedinspacetime
trappedinspacetime / gist:eeee2d82afe1823e2f89193c6022e4bd
Created December 13, 2020 14:35
debian list installed packages in a given date
read -p "enter a date to list installed pakages 2020-12-12 14:" date ; awk 'FNR==1{nf++} ; nf==1{for (i=1;i<=NF;i++) a[$i]=1} ; nf==2{for (i=1;i<NF;i++) if (a[$i]==0) printf "%s ",$i}' <(cat /var/log/dpkg.log | awk -v d="$date" '/ trigproc / && $0 ~ d {print $4}' | awk '{printf "%s ", gensub(/:.*/,"\\1", "g", $1); }') <(cat /var/log/dpkg.log | awk -v d="$date" '/ installed / && $0 ~ d {print $5}' | awk '{printf "%s ", gensub(/:.*/,"\\1", "g", $1); }')