Skip to content

Instantly share code, notes, and snippets.

View darrik's full-sized avatar

Rikard Glans darrik

  • Sweden
  • 06:22 (UTC +02:00)
View GitHub Profile
@darrik
darrik / winm.ahk
Last active June 14, 2021 16:26
autohotkey script to minimize all* windows on primary monitor
;; Created: 2021-03-14 13:03:11
;; Time-stamp: <2021-03-27 15:35:47>
;; Win+m
#m::
SysGet, monitor, Monitor ; get resolution, etc
WinGet, winlist, List ; get list of windows
Loop % winlist {
me := % "ahk_id " winlist%A_Index%
@darrik
darrik / swansi.ahk
Created October 22, 2019 15:31
Autohotkey script for typing swedish characters on a US/ANSI keyboard
;; Mind your file encoding when saving this.
; right alt + [
>!SC01A::Send, å
; right alt + '
>!SC028::Send, ä
; right alt + ;
>!SC027::Send, ö
@darrik
darrik / amd_plus_asm1062.txt
Created March 10, 2019 14:42
AMD and ASM1062 based raid card
hardware:
cpu: AMD Ryzen 7 1700
mb: Gigabyte AX370-GAMING K3
raid: ST Lab A-590 PCIe SATA 6G 8channel
- lspci: SATA controller: ASMedia Technology Inc. ASM1062 Serial ATA Controller (rev 02)
problem 1:
ata13: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
ata13.00: link online but device misclassified
ata13: link online but 1 devices misclassified, retrying
@darrik
darrik / delete-playing-file.ahk
Created June 2, 2018 18:11
mpc-be doesn't have mpc-hc's delete currently playing file so here's a autohotkey script
; enable options -> player -> title bar -> display full path to use this
#IfWinActive ahk_class MPC-BE
Delete::
WinGetTitle, filePath ; filename
file := RegExReplace(filePath, " - MPC-BE.*", "") ; remove junk
Send, {Space} ; pause
MsgBox, 4388, , Do you want to delete %file%?
IfMsgBox No
{
@darrik
darrik / remove-background-from-font-locks.el
Created June 7, 2016 12:24
Emacs remove-background-from-font-locks
(defun darrik/remove-background-from-font-locks ()
"Remove background from font-lock-*."
(mapc
(lambda (face)
(when (string-prefix-p "font-lock-" (symbol-name face))
(set-face-attribute face nil :background nil)))
(face-list)))
@darrik
darrik / unmark-packages.el
Created March 27, 2016 20:31
Unmark packages matching REGEXP from being upgraded.
(defun darrik/package-install-unmark-regexp (pattern)
"Unmark packages matching REGEXP from being upgraded."
(interactive "sPattern: ")
(let* ((_prefix "^\\(I\\|D\\)\\\s+.*")
(_re (concat _prefix pattern)))
(while (re-search-forward _re nil t)
(beginning-of-line)
;; (message "%s" "I unmarked something!")
(package-menu-mark-unmark)))
(message "%s" "Finished unmarking packages."))
@darrik
darrik / zfs_find_copies_n.sh
Created April 18, 2015 19:42
Finding files on zfs that has copies=2 (or more)
#!/bin/bash
for file in $(/bin/ls *.jpg); do
size=$(/bin/ls -l $file | awk '{printf $5}')
dusize=$(du --block-size=1 $file | awk '{print $1}')
verify=$(echo $size*1.5/1 | bc)
if [ $dusize -gt $verify ]; then
dusize=$(printf "%'d" $dusize)
size=$(printf "%'d" $size)
echo "$file has copies>1 ($dusize > $size)"
@darrik
darrik / darrik-org-copy-field.el
Last active August 29, 2015 14:05
Copy current field to system clipboard
(defun darrik/org-copy-field ()
"Copy current field to system clipboard."
(interactive)
(save-excursion
(call-interactively 'org-table-copy-region)
(let* ((contents (caar org-table-clip))
(trim1 (replace-regexp-in-string " +" "" contents))
(trim2 (replace-regexp-in-string "^ " "" trim1)))
(kill-new trim2))))
(defun darrik/isrunning-p (argv)
"Return `t' if `argv' is running."
(or (listp argv)
(setq argv (list argv)))
(dolist (pid (list-system-processes))
(let* ((pdata (process-attributes pid))
(x (assoc 'comm pdata))
(exe (cdr x)))
(when (member exe argv)
(return t)))))