Skip to content

Instantly share code, notes, and snippets.

View somian's full-sized avatar

Sören Andersen somian

  • toolsmith, independent contractor: python, perl, unix shell; systems admin
  • A city near the eastern Great Lakes, USA
View GitHub Profile
@somian
somian / Console2 Crash report
Created February 10, 2012 00:34
The W*ndows Console ("CMD.exe") replacement crashed when I tried to `less' a file. I hade several tabs open at the time.
Problem signature:
Problem Event Name: APPCRASH
Application Name: conhost.exe
Application Version: 6.1.7601.17641
Application Timestamp: 4e03f6d7
Fault Module Name: conhost.exe
Fault Module Version: 6.1.7601.17641
Fault Module Timestamp: 4e03f6d7
Exception Code: c0000005
Exception Offset: 00002758
@somian
somian / gist:2791953
Created May 26, 2012 03:21
Get User "Desktop" well-known folder pathname in Vim (script)
let g:WinUserProfile = ''
try
let g:WinUserProfile = substitute(system('cygpath -am -C UTF8 -D'), '[[:cntrl:]]', '', 'g')
catch @^Vim\%((\a\+)\)\=:E\d\+@ " catch any error number
" Seeing E484: Can't open file /tmp/vWlY1IE/0 # for line 99 (is it because SHELL been messed w/?)
call confirm(
\ printf(
\ "%s: Could not system() to get WinUserProfile using cygpath under shell \"%s\": %s\n",
\ s:this_vimfile, &shell, v:exception), 'Ok', 'Ok', 'Warning')
endtry
@somian
somian / PerlCodeBeduggin.vim
Created June 5, 2012 14:58
Trace execution of (eval'd) perl code in Vim scripts we write
" First created: 2012-06-05 UTC-04:00
" Last modified: 2012-06-05T10:54:59 UTC-04:00
if str2nr(v:version) < 700 |finish|endi
let s:base_sfile = fnamemodify(expand('<sfile>'), ':t')
let s:ltest = 'g:loaded_' .tolower(fnamemodify(expand('<sfile>'), ':p:t:r'))
if exists(s:ltest)
unlet s:ltest
" finish for ordinary plugins only.
endi
@somian
somian / somian-Ink.js
Created January 25, 2013 02:22
My changes to Perlmonk tobyink's jQuery js code: using CodeMirror to syntax-highlight code posted on Perlmonks. node_id=1007668 This code is part of what is intended to be included by folks (logged-in, registered Monks) in their Free Nodelet Settings HTML. See the writeup for the original author's instructions. {{ req. knowledge level: HIGH }}
$(function() {
$('p.code').each(function (i, c) {
var $code = $(c).find('tt.codetext').text().replace(/\u00a0/g,' ');
var $dclink = $(c).find('span.embed-code-dl');
var $pre = $(
'<textarea class="CodeMirror">'
+ $('<div/>').text($code).html().replace(/\s+$/,'')
+ '</textarea>'
);
@somian
somian / Padded Interrogation Room
Created March 30, 2013 20:10
This is not a complete script; but it illustrates some changes to a Makefile.PL to get around the noise from that uptight, unhappy little nun "ExtUtils::LibList".
use ExtUtils::MakeMaker;
use File::Spec;
use Cwd;
use strict;
# Adapted from a Makefile.PL for Glib.pm, Copyright (C) 2003-2009, 2012 by
# the gtk2-perl team [...]
our %PREREQ_PM = (
'ExtUtils::Depends' => '0.300',
'ExtUtils::PkgConfig' => '1.000',
@somian
somian / EULibList_Annot.pod
Last active December 15, 2015 19:39
External Dependency (lib to compile /link against) Makefile.PL
ARG-1            ARG-2     ARG-3
  [$obj or Class "ExtUtils::Liblist"]->ext($potential_libs, $verbose, $need_names);

So $_[1] (ARG-2 ) and $_[2] (ARG-3) are BOOLEANS.

The POD says:

It returns an array of four or five scalar values: EXTRALIBS,

## A re-spin on http://plasmasturm.org/code/vistafonts-installer/vistafonts-installer, see
## http://community.linuxmint.com/tutorial/view/365
## SHARP-BANG NEXT LINE
#!/bin/sh
# Copyright (c) 2007 Aristotle Pagaltzis
# 2013 Sören Andersen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
@somian
somian / Bash GNU-Linux DiskMountReporter
Last active December 20, 2015 08:19
Bash user function (typically executed from an interactive shell while doing system work or just stuff) on GNU-Linux. Point is see mounted disk devices neatly printed.
## earlier version was fubar
function diskmounts {
cat /proc/mounts | perl -nawl \
-e 'if ($F[0]=~ m{/dev/(loop[[:digit:]]+ | sd[a-z][[:digit:]]? | sr[[:digit:]]+) | UUID= | LABEL=}x) {' \
-e ' push @dp=>[@F[0,1]]' \
-e '} END {print for map { $_->[1] } sort {$a->[0] cmp $b->[0]} map { [$_->[0], join (qq[\t\t],@$_)] }@dp}'
}
# get some metadata about present disk devices.
function disklookup
{
if [[ x"$1 " != x"" ]]
then
PATT="$1"
for LOL in `blkid -o device -t TYPE=ext4`
do blkid -o full -s 'UUID' -s 'LABEL' $LOL
done |
sed -n "/$PATT/{p}"
@somian
somian / blklabel
Last active December 22, 2015 03:39
shell pipeline to get a suffiently safe filename from a disk volume LABEL as a mount point (directory name) to mount a hotplugged device.
blkid -s TYPE|egrep vfat |
cut -d \: -f 1|
xargs /sbin/blkid -c value|
xargs perl -MFile::Util="" \
-e '$it=File::Util->new();' \
-e 'print for map{/LABEL=([^=]+)(?=[[:space:]][[:upper:]]+[=])*/;' \
-e '($1 ? do{($_=$it->escape_filename($1))=~s{[[:space:]]}{_}g and qq[/media/byLABELISH/$_\n]}' \
-e ' : q[])} grep {LABEL} @ARGV'