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 / picturewindowscrape
Last active August 29, 2015 14:15
picture-window-scrape
#!/bin/bash
# picturewindowscrape
# Global:
SDIMS=2480x1600
# See if we are provisioned up.
for MYEXE in xvfb-run x11vnc vncviewer pstree pgrep
do if [[ -n $(which "$MYEXE") ]]
then :
@somian
somian / playll
Created December 27, 2014 06:16
playlist to filename listing (media files)
perl -MURI::Encode=uri_decode -MFile::Spec::Functions=:ALL -MFile::stat -wne 'if(/([.][.]\/.+\.\w\S+)[<]/){$y=uri_decode($1);$d=stat($y);next if!$d; printf "%s %s\n",$d->ino(),rel2abs($y); }' < HI-Light.xspf
@somian
somian / collectrix
Created December 8, 2014 05:48
windows netwrk adapters
#!perl
use PerlIO;
use strict;
use warnings;
my $PSF;
my $networkshellcmd = q[netsh];
my @networkshellpar = qw[-c lan show interfaces];
my @startprocess = ($networkshellcmd, @networkshellpar);
@somian
somian / LilMonstaNumber12
Last active August 29, 2015 14:06
LilMonstaNumber12 for GNU/Linux X11 uses X clpbd to find URLs of CPAN pkgdists and saves them in a hierarchical fs loc (creating dirs where needed).
#!/bin/dash
#--+++-- cpan-grabdist.sh
# NODBG=ON # comment out after debugging
#--+++--
export HO_ME=$(echo ~)
TO_SUDO_OR_NOT=""
BEST=$(echo ~Public/Downloads)
TARGET=${BEST:+"$BEST/CPAN-SRC"}
@somian
somian / gist:6c17da88c76ff4e180c2
Created August 9, 2014 00:58
NMC - Google-Chrome Debian .deb inst file snippet causing BIG trouble
#
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# sources.list setting for google-chrome updates.
REPOCONFIG="deb http://dl.google.com/linux/chrome/deb/ stable main"
@somian
somian / std-lib-foo Makefile
Last active August 29, 2015 14:04
A Makefile that compensates for a difficult pkg-config case v2.91
# GNU Makefile
## GMakefile-std-lib-foo
THIS_MAKEFILE := $(firstword $(MAKEFILE_LIST))
PROGRAM = testargv
CODE := $(CURDIR)/code/
PROGRAM_FILES = testinput.cc
_CODEF := $(wildcard $(CODE)*.cc)
_CODEF ||= None
LIB_Called_WHAT =
@somian
somian / PySlode
Last active January 2, 2016 17:19
A simple but usable skeleton example of a (conservative, error-checking) "local python module code file loader" in Vim Script (vimL)
"^-^" vim: set filetype=vim et sw=4
" This file contains free software: you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation, either version 3 of the License, or
" (at your option) any later version.
"
" The code herein is published informally in the hope that it will be useful,
" but WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" GNU General Public License for more details.
@somian
somian / krumblies
Last active December 27, 2015 20:49
#!/bin/bash
declare -x TOPDIR_STORAGE=${HOME:-"/home/retread"}/.config/virt/virtualdisks
declare CLOO=$1 # e.g. "SANDISK"
declare -a DISK_GRP=(\
$(awk --sandbox -F : '/disk/{print $1,$3}' /etc/group)\
)
declare DISK_GID=${DISK_GRP[1]}
@somian
somian / gist:6790687
Created October 2, 2013 08:31
Karl Runge's rx11vnc script
#!/bin/sh
#
# usage: rx11vnc [-s] <host>:<xdisplay>
# rx11vnc [-s] <host> (assumes xdisplay is 0)
#
# -s means use ssh instead of rsh.
# -S tries to tunnel the vnc traffic thru ssh. (experimental...)
#
#set -xv
@somian
somian / mkblklabel
Created September 2, 2013 11:26
A slightly more useful stab at the previous gist.
blkid -s TYPE|egrep vfat | cut -d \: -f 1| xargs /sbin/blkid -c value|
xargs perl -MCarp -MFile::Util="" -e '$it=File::Util->new();' \
-e 'my($lab)= grep{$_} map{/LABEL=([^=]+)(?=[[:space:]][[:upper:]]+[=])*/;' \
-e '($1 ? do{($_=$it->escape_filename($1))=~s{[[:space:]]}{_}g and qq[/media/byLABELISH/$_]}' \
-e ': q[])} grep {LABEL} @ARGV; print qq[We shall try to make $lab if it does not exist.\n];' \
-e 'unless (-d $it){$it->make_dir($lab) || croak qq[Well, that failed somehow.\n]}'