├── 1984 ├── .github └── FUNDING.yml ├── .gitignore ├── 256colors2.pl ├── List::MoreUtils ├── README.md ├── _ls ├── _v ├── absname ├── abstract ├── add_md_indent ├── add_userchrome_to_all_profiles.zsh ├── afa ├── al ├── al_jazeera ├── album ├── albumlist ├── albums_by_artist ├── alias ├── all_unicode ├── all_uptime ├── amigaremix_dump ├── amigaremix_dump_noprereq ├── amigaremix_dump_selenium ├── anagrams ├── ansi_pacman ├── ansic ├── artists-by-letter ├── audiobookrename ├── aur ├── aur3c ├── aur_json ├── author ├── authors ├── autorepeat_some ├── badmouth ├── bake ├── basenamep ├── battery_prompt ├── batwarn ├── bdf2otb ├── beep ├── beep_mech ├── beet-accumulate-artist-variations-in-single-dir ├── beet-cleanup-cover-only-directories ├── beet-cleanup-duplicate-imports ├── beet-dupes-in-fs ├── beet-import-single-live-tracks ├── beet-import-singles ├── beet-import-singles-place-in-album-dir ├── beet-import-singles-to-label ├── beet-ls-albums ├── beet-ls-albums-by-label ├── beet-missing ├── beet-move-tracks-from-music1-to-music2.sh ├── beet-np-info ├── beet-selfripped ├── beet-symlink-query ├── beet-update ├── beets-split-first-artist.py ├── bigrand ├── binary ├── bob ├── bolaget ├── bold ├── bookmark-open ├── bookmarks ├── build ├── by_extension ├── c256-grey-colorscheme ├── calc ├── camera_fetch ├── caps2esc ├── cateverything ├── catimg ├── cconvert ├── cdp ├── cfdg ├── chr ├── clarify ├── classname ├── clean ├── clftail ├── clipboard-to-primary ├── clipboard-to-primary-sync ├── clipedit ├── clone_trapd00r_gh ├── colorclock ├── colorls ├── colorscheme ├── colorscheme-256 ├── colorx ├── cols ├── concerts ├── core ├── corona ├── cpan-api ├── cpan-most_used_filenames_in_root_dir ├── cpan-multi ├── cpan-regulars ├── cpan-what_depends_on_x ├── cpan_author_search ├── cpan_authors_github ├── cpan_authors_swedish ├── cpan_dep ├── cpan_get_test_db ├── cpan_recent ├── cpan_upload ├── cpanm-github ├── cpanupgrade ├── cpmpd ├── cpnewfavs ├── crossmake ├── cs_preview.vim ├── cups_fix ├── cv ├── dahbug ├── ddg ├── ddmpc ├── ddp ├── define ├── delete_directories_less_than_2MB_in_size ├── deparse ├── deploy_japh ├── diffurl ├── digits ├── dircolors2vim ├── dirnamep ├── div_rule ├── dltrack ├── dmenushit ├── dmesg-a ├── docupdate ├── domain_gen ├── domain_snatch ├── dump ├── dumper ├── dumppager ├── dupe_movie ├── dupe_music ├── dupe_tv_by_episode ├── dusch ├── duschiamej ├── e ├── ebookextract ├── epoch2localtime ├── everywhere ├── exifdel ├── exifrename ├── facebook_url_count ├── facebook_user_info ├── fehctrl ├── ff ├── filebytype ├── fileinfo ├── filetypes ├── fillmp3 ├── filter_ext_lscolor ├── fimpc ├── find_dupe_mp3_when_there_is_flac.pl ├── findls ├── findmovie ├── findmvid ├── findrec ├── findsrc ├── findtv ├── firefox_gtk ├── fix-EHCI_TT_NEWSCHED ├── font-10-anonymous ├── font-10-anonymous-it ├── font-10-dejavu ├── font-10-fixed ├── font-10-profont ├── font-11-dejavu ├── font-11-neepalt ├── font-11-profont ├── font-12-anonymous ├── font-12-anonymous-test ├── font-12-dejavu ├── font-12-droid ├── font-12-nerdfonts ├── font-12-terminus ├── font-13-dejavu ├── font-14-dejavu ├── font-14-terminus ├── font-14-unifont ├── font-15-proggytiny ├── font-16-c64 ├── font-16-c64-user-mono ├── font-16-daewoo ├── font-16-dejavu ├── font-16-dejavu64 ├── font-16-droid ├── font-16-monofur ├── font-16-terminus ├── font-18-terminus ├── font-20-dejavu ├── font-20-terminus ├── font-2013 ├── font-2022 ├── font-24-droid ├── font-32-droid ├── font-32-monofur ├── font-32-terminus ├── font-5x7 ├── font-5x8 ├── font-6x10 ├── font-6x13 ├── font-6x9 ├── font-7x13 ├── font-7x14 ├── font-8-fixed ├── font-9-fixed ├── font-argv ├── font-atari ├── font-clean ├── font-cleanproggy ├── font-fixed ├── font-monte ├── font-nerdanonymous ├── font-nerdfonts ├── font-tamsyn ├── font-tamsyn-12 ├── font-tamsyn-20 ├── font-terminus ├── font-test ├── font-ubuntu ├── font-yoshi ├── font_preview ├── ft ├── fuckingscreenbugshit ├── fx_ramdisk_sync ├── fx_screen_profiles ├── fx_vscreen_profiles ├── fxshot ├── fzf-perlsub-githistory ├── gb ├── generate-perl-package-completion-for-vim.pl ├── generate-tags.sh ├── generate_swedish_names ├── generate_xresources ├── generate_zsh_completion ├── geo ├── get_ls_colors ├── get_tests ├── getjob ├── getphotos ├── getstash ├── gh_clone_all_gists ├── gh_clone_all_user_repos.sh ├── git-awesome-status ├── git-changed-files ├── git-changed-files-to-vim ├── git-cpan-release ├── git-diff-syntaxhl ├── git-effort ├── git-rec ├── git-top ├── gitcheck ├── gitdo ├── github-referrers ├── gitsnap ├── gl ├── gl1 ├── gll ├── glll ├── glob ├── gnext ├── goimg ├── google_dmenu ├── google_tlds ├── gotoalbum ├── gprev ├── graynbow.pl ├── grmpd ├── grub_error ├── gs ├── hardcopy ├── hextermcolors ├── hits ├── hotswap ├── config.conf └── hotswap.pl ├── html2txt ├── httpdhits ├── httrack_with_linked_images ├── hue-toggle ├── identi_ca_home ├── iex ├── imv ├── inanonenin ├── inc ├── inc_search ├── initial_letter ├── inverse ├── invert_screen ├── iptrans ├── irc_stats ├── irssi-ignore_join_blob.pl ├── issues ├── italic ├── iterate ├── japh.pl ├── json_check ├── json_deparse ├── kbdrate-fix-repeat-keys ├── kitty_dump_colors ├── kitty_feh_handler ├── knnp-sh ├── knradioold ├── kwalitee ├── laleh-check ├── lapd ├── lastfmnp ├── lc ├── len ├── lessfilter ├── lib ├── Deparse │ ├── Makefile.PL │ └── Syntax.pm └── Net::Google::TLD │ ├── Makefile.PL │ ├── blib │ ├── arch │ │ ├── .exists │ │ └── auto │ │ │ └── Net │ │ │ └── Google │ │ │ └── TLD │ │ │ └── .exists │ ├── bin │ │ └── .exists │ ├── lib │ │ ├── Net │ │ │ └── Google │ │ │ │ ├── .exists │ │ │ │ └── TLD.pm │ │ └── auto │ │ │ └── Net │ │ │ └── Google │ │ │ └── TLD │ │ │ └── .exists │ ├── man1 │ │ └── .exists │ ├── man3 │ │ ├── .exists │ │ └── Net::Google::TLD.3pm │ └── script │ │ └── .exists │ ├── lib │ └── Net │ │ └── Google │ │ └── TLD.pm │ └── pm_to_blib ├── limpdeg ├── linenr ├── lmame ├── lnes ├── load ├── localtime ├── lookup ├── love ├── loved ├── ls2 ├── ls3 ├── ls_color_beets ├── lscolorpicker ├── lscolorpicker.sh ├── lsp ├── lsrel ├── lyrics ├── lyrics_update ├── m ├── maemo-scratchbox-install_5.0.sh ├── mag2tor ├── magento_rebuild_broken.sh ├── mailme ├── make_flac ├── makedist_old ├── makejaph ├── makevimcommentheader ├── map ├── markdown_preview ├── md2html ├── md5rename ├── meet ├── melodikryss ├── melodikrysset ├── mem ├── merlyn-columns ├── mkdir_extension_and_categorize ├── mkdr ├── mls ├── monitor-toggle ├── mount-camera ├── mount-n900 ├── mount-nas ├── mount-remote ├── mount-shiva ├── mountlast ├── mpd-copy-coverart ├── mpd-copy-path-to-clipboard ├── mpd-goto-album-dir ├── mpd-goto-artist-dir ├── mpd-lastfm-pick-an-artist ├── mpd-show-coverart ├── mpd_add_musicdir ├── mpd_cp_native ├── mpd_del ├── mpd_del_album ├── mpd_edit ├── mpd_fill_mp3player ├── mpd_ftp ├── mpd_keep ├── mpd_mv ├── mpd_playlist_fix ├── mpd_random_hiphop ├── mpd_random_playlist ├── mpd_relevancy ├── mpd_replace_missing_files_in_loved_db ├── mpd_sock ├── mpd_stats ├── mpd_stumpwm_status ├── mpd_symlink_all_by_artist ├── mpd_trans ├── mpd_twmn ├── mpd_update_status ├── mpdbar_urxvt ├── mpdcp.rc ├── mpdfzf ├── mplayer_exec ├── mplayer_podcast ├── mplayerd ├── mpm ├── mpnp ├── msg_me ├── mtree ├── music ├── music_dupe ├── music_query ├── music_session ├── mutt_pager ├── mvdir ├── mvid_mkdir ├── mvmusic ├── n900_flash ├── n900_mount ├── n950_bruteforce_flash ├── n950_screencast ├── name_generator ├── net_on_på_sid ├── newpost ├── newrel ├── ngrep ├── nicefind ├── nod ├── noita ├── noitapl ├── non ├── nowrap ├── np ├── np-info ├── np-lyrics ├── npbeets ├── ocr ├── offensive ├── ord ├── oreilly_books ├── ot ├── pac+x ├── pack ├── packer ├── pacstat ├── parselscolors ├── passwd_gen ├── paste ├── path_update ├── pc ├── pcp ├── pdf ├── peak ├── pentadactyl-plugins-update ├── periodic ├── perl-multi ├── picam ├── pilsner ├── pimpla ├── pkgfont ├── playlist_cleanup ├── playlists_update ├── plex_artist_image_downloader ├── plex_get_album_summaries.pl ├── plex_get_artist_summaries.pl ├── plexampnext ├── plexampprev ├── pmdesc ├── pmv ├── podcheck ├── poormansls++ ├── post ├── prename ├── prep_mplayer ├── prove-multi ├── pshot ├── punpack ├── pushall ├── pwc ├── pwc_old ├── radio ├── rainbow ├── randalbum2go ├── randwall ├── ratpoison-interactive-window-list.pl ├── ratrepl ├── reddit ├── reddit-dl ├── rel_old ├── release ├── release_dupe ├── reload_chrome ├── remount ├── rename-tv ├── rename2dirname.sh ├── rename_youtube ├── renamefromid3v2 ├── rensafilm ├── rensamusik ├── rescue_chmod ├── retrieve ├── revdnsinternet ├── rfc ├── rgb_by_index ├── rgbtohex ├── rgbxterm ├── rmc_old ├── rmfile ├── rmtpy ├── rotate ├── rp-4split ├── rp-groups-menu ├── rp-mplayer-np ├── rp-runorraise ├── rp-showall ├── rp-window-menu ├── rpws ├── rsync_archlinux ├── rt ├── rt_magnet_handler ├── rt_notify ├── rt_query ├── rt_remove_torrents_by_tracker ├── rtorrent_search ├── rupl ├── sanitize ├── sanitize_input ├── sascii ├── scandeps ├── scat ├── scpan ├── screen-start-or-attach ├── screen_status ├── scrot2debbie ├── sdorfehs-define-escapekey ├── sdorfehs-definekey-tops ├── sdorfehs-undefine-escapekey ├── sdorfehs-undefinekey-tops ├── sdorfehsrepl ├── search-cpan-wikifier ├── seen ├── sendsrc ├── separate ├── set_album_title_for_losa_latar_to_various ├── setallfonts ├── setbg ├── setbg_sshhosts ├── share ├── foobar.css └── share.pl ├── shift-insert ├── shivastream ├── shortdate ├── shot ├── shoutcast_parser ├── showcolors ├── shrug ├── sidtop ├── sightly ├── simart ├── skrot ├── sl ├── smw_hacks_download.sh ├── sort_aliases ├── sort_music_by_genre ├── sort_video ├── space_invaders ├── spark ├── sr-rename ├── srinfo ├── srnp ├── sshc ├── stash ├── stderr ├── strip_esc ├── strip_html ├── stumpdump ├── stumpish ├── sub ├── subscript ├── svtplay ├── swedbank-cli ├── sync_music ├── term_attr ├── term_colors ├── testy ├── thinkpad-brighter ├── title ├── to_phone ├── today ├── toflac ├── tohtml ├── tomp3 ├── top25 ├── topip ├── topref ├── topsi ├── torrent ├── tpb ├── traffic ├── traffic_cpan ├── translate ├── tv ├── tw-servers.sh ├── tweet_compress ├── twitter_grep ├── typo ├── u-arrows ├── u-blocks ├── u-boxdrawing ├── u-brackets ├── u-fullwidth ├── u-music ├── u-punctation ├── u-whitespace ├── uc ├── ucfirst ├── umount-remote ├── uncode ├── uncolor-ruby ├── underline ├── ungzip ├── unichar ├── uninames ├── uniprops ├── uniquote ├── uniuni ├── unlove ├── unpack ├── unpack_all ├── unrarec ├── update_email ├── updatesite ├── upsidedown ├── upstream ├── uri ├── url_find ├── userChrome.css ├── utils_readme ├── v ├── version_up ├── vid2gif ├── vidir-open-untracked-git-files ├── vidir_by_dirsize ├── vidstream ├── vim-bindings ├── vim-time-fix-db ├── vim-writes-a-day ├── vim └── syntax │ └── overtime.vim ├── vim_old ├── vimcolors ├── viml ├── vimsyntax ├── vol_down ├── vol_up ├── vr ├── vrms ├── vt52 ├── vte ├── vw ├── wake ├── wallpaper_daemon ├── wallpaperfm ├── warn ├── we ├── wf ├── wgetdarknet ├── whatfont ├── whatsmyip ├── whatthedev ├── whoa-netplay-ripper.pl ├── wifi-enable ├── wikipedia_over_dns ├── winrarthemefetcher ├── woof ├── workdays ├── wp ├── wrap ├── wtc ├── wup ├── www ├── www-newwindow ├── x11-remote ├── xbmc-tv ├── xbox2ps4 ├── xdgdirs ├── xfiles.sh ├── xmk ├── xmodshit ├── xonotic-map-downloader.pl ├── xresources_dump ├── xstat ├── xterm-16colors.sh ├── xterm-256colors.pl ├── xterm-256colors2.pl ├── xterm-88colors.pl ├── xterm-88colors2.pl ├── xterm-8colors.sh ├── xterm-acolors.sh ├── xterm-blinkenlights ├── xterm-cycle_colormap ├── xterm-doublechars.sh ├── xterm-dynamic.sh ├── xterm-dynamic2.sh ├── xterm-fonts.sh ├── xterm-paste.pl ├── xterm-paste64.pl ├── xterm-query-fonts.pl ├── xterm-resize.pl ├── xterm-resize.sh ├── xterm-tcapquery.pl ├── xterm-title.sh ├── xtermcolchange ├── youtube ├── youtube-dl-channel ├── youtube-extract ├── youtube-getfavs ├── youtube-getplaylist ├── youtube-getuservideos ├── youtube2mp3 ├── youtube_parallelfetch ├── youtube_sanitize ├── yt-dlp-album-downloader ├── yt-dlp2mp3 ├── zsh_completions ├── zsh_path ├── zurl ├── öl └── ♫ /1984: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: fun with pv 3 | foo=$(uptime|perl -pe 's/.+up (.+)/$1/') 4 | echo -e "$(date)\b\b\b\b\b\b\t1984: $foo"|pv -L 10 -q 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: trapd00r 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.un~ 2 | _site/ 3 | .jekyll-cache/ 4 | -------------------------------------------------------------------------------- /absname: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: you can't trust $PWD in linux 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | use open qw(:std :utf8); 6 | use utf8; 7 | use Cwd qw(getcwd); 8 | my $cwd = getcwd(); 9 | print map { -e "$cwd/$_" ? "$cwd/$_\n" : "$_\n" } @ARGV; 10 | -------------------------------------------------------------------------------- /abstract: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: extract abstract from given file(s) 3 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 4 | use strict; 5 | use warnings FATAL => 'all'; 6 | use vars qw($VERSION); 7 | use autodie qw(:all); 8 | 9 | my $APP = 'abstract'; 10 | $VERSION = '0.001'; 11 | 12 | use File::LsColor qw(ls_color); 13 | 14 | 15 | print usage() unless @ARGV; 16 | 17 | for my $file ( grep{-f $_ && $_} @ARGV) { 18 | open(my $fh, '<', $file) or die $!; 19 | while(<$fh>) { 20 | if($_ =~ m/abstract: (.+)$/) { 21 | printf "%s %s\n", ls_color(sprintf("%20s", $file)), $1; 22 | last; 23 | } 24 | } 25 | } 26 | 27 | sub usage { 28 | print "usage: abstract [FILEs]\n"; 29 | exit; 30 | } 31 | -------------------------------------------------------------------------------- /add_md_indent: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | perl -pe 's/^/ /' 3 | -------------------------------------------------------------------------------- /add_userchrome_to_all_profiles.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/zsh 2 | # abstract: copies userChrome.css to all profiles in Firefox 3 | for x in ${HOME}/.mozilla/firefox/*.*/chrome(/); do cp -v ${HOME}/dev/utils/userChrome.css ${x}/userChrome.css; done 4 | -------------------------------------------------------------------------------- /afa: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use File::Path qw(make_path); 4 | use Term::ExtendedColor qw(fg); 5 | 6 | _mkdir(@ARGV); 7 | 8 | 9 | sub _mkdir { 10 | my $dir = shift; 11 | if(-f $dir) { 12 | if($dir =~ m|(.+)\..+$|) { # I know, works for me for now. 13 | warn "$dir is a file. Will mkdir $1\n"; 14 | $dir = $1; 15 | } 16 | } 17 | if(make_path($dir)) { 18 | printf("mkdir: created directory '%s'\n", fg('red1', fg('bold', $dir))); 19 | } 20 | else { 21 | print "mkdir: $!\n"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /al: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | my $links_file = "$ENV{HOME}/usr/share/doc/links"; 4 | 5 | die( &usage ) if @ARGV <= 1; 6 | 7 | my($link, $tag) = @ARGV; 8 | if($link !~ m{^https?:}) { 9 | die( &usage ); 10 | } 11 | 12 | 13 | open(my $fh, '>>', $links_file) or die($!); 14 | print $fh sprintf("[%25.25s] %s\n", $tag, $link); 15 | close $fh; 16 | 17 | sub usage { 18 | return "Usage: $0 link [description]\n"; 19 | } 20 | -------------------------------------------------------------------------------- /al_jazeera: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rtmpdump -v \ 4 | -r "rtmp://livestfslivefs.fplive.net/livestfslive-live/" \ 5 | -y "aljazeera_en_veryhigh?videoId=747084146001&lineUpId=&pubId=665003303001&playerId=751182905001&affiliateId=" \ 6 | -W "http://admin.brightcove.com/viewer/us1.24.04.08.2011-01-14072625/federatedVideoUI/BrightcovePlayer.swf -p "http://english.aljazeera.net/watch_now/ -a "aljazeeraflashlive-live?videoId=747084146001&lineUpId=&pubId=665003303001&playerId=751182905001&affiliateId=" \ 7 | | mplayer - 8 | -------------------------------------------------------------------------------- /album: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: get a quick list of albums by name 3 | # 4 | # > album most\ wanted\ music 5 | # +va/Most Wanted Music 10 (1999) [FLAC] 6 | # +va/Most Wanted Music 6 (1998) 7 | 8 | mpc search album "$1" \ 9 | | dirnamep \ 10 | | sort -u 11 | -------------------------------------------------------------------------------- /albumlist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: display all albums by artist 3 | 4 | artist="$@" 5 | [ -z $artist ] && artist=$(mpc --format '%artist%' | head -1) 6 | mpc search artist "$artist" \ 7 | | perl -pe 's{(.+)/.+$}{$1}' \ 8 | | sort -u \ 9 | | perl -pe "s!^!\$ENV{XDG_MUSIC_DIR}!e" 10 | -------------------------------------------------------------------------------- /albums_by_artist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | # abstract: display all unique albums by artist 4 | 5 | ARTIST=${1:-$(mpc current --format %artist%)} 6 | 7 | mpc search artist "$ARTIST" \ 8 | | ls_color \ 9 | | dirnamep \ 10 | | sort -u 11 | -------------------------------------------------------------------------------- /alias: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: display zsh aliases 3 | use strict; 4 | use Data::Dumper; 5 | use v5.10; 6 | 7 | my %alias = (); 8 | 9 | open(my $fh, '<', "$ENV{HOME}/etc/zsh/02-alias.zsh") or die($!); 10 | while(<$fh>) { 11 | s/^alias (.+)=(?:'|")(.+)(?:'|")/$1 => $2/; 12 | $alias{$2} = $1; 13 | } 14 | 15 | printf("\033[38;5;178m%-12s\033[0m \033[1m%s\033[0m\n", $alias{$_}, $_) 16 | for(sort({$alias{$a} cmp $alias{$b}} keys(%alias))); 17 | 18 | 19 | -------------------------------------------------------------------------------- /all_unicode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: print all unicode chars 3 | use strict; 4 | use utf8; 5 | use open qw(:utf8 :std); 6 | 7 | use charnames qw(:full); 8 | 9 | my $pattern = shift // '.+'; 10 | 11 | for my $u(0x000 .. 0x10ffff) { 12 | my $charname = charnames::viacode($u); 13 | printf("%s %s %s\n", $u, chr($u), $charname) if $charname =~ m/$pattern/i; 14 | } 15 | -------------------------------------------------------------------------------- /all_uptime: -------------------------------------------------------------------------------- 1 | printf " \e[1mshiva\e[0m: " 2 | uptime 3 | printf " \e[1mdvdc\e[0m: " 4 | ssh scp1@192.168.1.128 -p 19216 uptime 5 | printf " \e[1mindia\e[0m: " 6 | ssh scp1@192.168.1.102 -p 19216 uptime 7 | printf " \e[1mn900\e[0m: " 8 | ssh user@192.168.1.112 -p 19216 uptime 9 | printf "\e[1mwrt54-gl\e[0m: " 10 | ssh root@192.168.1.1 -p 19216 uptime 11 | -------------------------------------------------------------------------------- /amigaremix_dump_noprereq: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: synmaxcol& ft=zsh: 3 | # abstract: rip all songs from amigaremix.com 4 | mkdir -p amigaremix && cd amigaremix; 5 | wget $( \ 6 | for x in $( \ 7 | # for d in {1..64}; 8 | for d in {1..2}; 9 | do printf "http://amigaremix.com/remixes/$d\n"; 10 | done 11 | ); do curl -s $x; done \ 12 | | grep -iPo 'a href=..listen.+\.mp3"' \ 13 | | perl -pe 's/^a href="(.+mp3)"$/http:\/\/amigaremix.com$1/' \ 14 | | perl -pe "s/ /%20/g") 15 | -------------------------------------------------------------------------------- /ansic: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: show defined ansi colors 3 | use strict; 4 | 5 | my $map = { 6 | 0 => 'black', 7 | 1 => 'red', 8 | 2 => 'green', 9 | 3 => 'yellow', 10 | 4 => 'blue', 11 | 5 => 'magenta', 12 | 6 => 'cyan', 13 | 7 => 'white', 14 | 15 | 8 => 'bright black', 16 | 9 => 'bright red', 17 | 10 => 'bright green', 18 | 11 => 'bright yellow', 19 | 12 => 'bright magenta', 20 | 13 => 'bright cyan', 21 | 14 => 'bright white', 22 | }; 23 | 24 | for(0 .. 15) { 25 | print "\n" if $_ == 7; 26 | printf("\e[1m\e[48;5;$_%s %15s - % 3d\e[m\n", 'm', $map->{$_}, $_); 27 | } 28 | -------------------------------------------------------------------------------- /artists-by-letter: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # vim:ft:zsh: 3 | # abstract: how many artists in each top level directory? 4 | 5 | for x in ${XDG_MUSIC_DIR}/*; \ 6 | do printf "% 10s: %s artists\n" $(basename $x) $(ls $x|wc -l); \ 7 | done | sort -gk2 8 | 9 | 10 | -------------------------------------------------------------------------------- /audiobookrename: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | prename 's/(.+)_-_(.+)-AUDiOBOOK.+/$1 - $2/;s/_/ /g;s/oe/ö/g;s/aa/å/g;s/ae/ä/g' 3 | -------------------------------------------------------------------------------- /author: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: print japh author 3 | use strict; 4 | 5 | print << 'EOF'; 6 | 7 | \ \ | / / 8 | \ \ - / 9 | \ | / 10 | (O O) 11 | ( < ) 12 | (-=-) 13 | 14 | Magnus Woldrich 15 | CPAN ID: WOLDRICH 16 | m@japh.se 17 | http://japh.se 18 | http://github.com/trapd00r 19 | 20 | EOF 21 | -------------------------------------------------------------------------------- /autorepeat_some: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: turn off autorepeat for all keys but some 3 | # vim:ft=zsh: 4 | 5 | # 22 = backspace 6 | # 36 = enter 7 | # 44 = j 8 | # 45 = k 9 | 10 | # 65 = space 11 | 12 | for x in {10..21}; do 13 | xset -r $x 14 | done 15 | 16 | for x in {23..35}; do 17 | xset -r $x 18 | done 19 | 20 | for x in {37..43}; do 21 | xset -r $x 22 | done 23 | 24 | for x in {46..105}; do 25 | xset -r $x 26 | done 27 | -------------------------------------------------------------------------------- /bake: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh et sw=2: 3 | # abstract: build perl stuff 4 | if [[ -f Makefile.PL ]]; then 5 | perl Makefile.PL PREFIX=~ LIB=~/lib/ 6 | elif [[ -f Build.PL ]]; then 7 | perl Build.PL PREFIX=~ LIB=~/lib/ 8 | else 9 | cpanm . || dzil . 10 | fi 11 | -------------------------------------------------------------------------------- /basenamep: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl:et: 3 | # abstract: grab input from stdin and basename it 4 | 5 | use strict; 6 | use File::Basename; 7 | use File::LsColor qw(ls_color); 8 | 9 | 10 | my $colored = $ARGV[0] =~ m/--?c/; 11 | shift @ARGV if $colored; 12 | 13 | while(<>) { 14 | chomp; 15 | my $file = basename($_); 16 | printf "%s\n", $colored ? ls_color($file) : $file; 17 | } 18 | -------------------------------------------------------------------------------- /battery_prompt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | for(`acpi`) { 5 | s/Battery 0: (.).+, ([0-9]+)%.+\n/$1/; 6 | if($1 eq 'D') { 7 | print "◀▪$2"; 8 | } 9 | else { 10 | print "▪▶$2"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /batwarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | chomp(my $bat = `acpi`); 5 | for($bat) { 6 | s/.+, ([0-9]+)%.+/$1/; 7 | } 8 | 9 | if($bat < 90) { 10 | system("zenity --warning --text='Battery low: $bat%'"); 11 | } 12 | -------------------------------------------------------------------------------- /beep: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\a" 3 | -------------------------------------------------------------------------------- /beet-accumulate-artist-variations-in-single-dir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | echo " 5 | rewrite: 6 | artist .*Britney Spears.*: Britney Spears 7 | 8 | beet move 'Britney Spears' 9 | " 10 | -------------------------------------------------------------------------------- /beet-cleanup-duplicate-imports: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## fixes problems like this that might occur from time to time: 4 | # rwxrwxrwx ▏< mon │ 21M│ 01 Laleh - Sol Vind Och Vatten.flac 5 | # rwxrwxrwx ▏< mon │ 21M│ 01 Laleh - Sol Vind Och Vatten.1.flac 6 | # rwxrwxrwx ▏< mon │ 21M│ 01 Laleh - Sol Vind Och Vatten.2.flac 7 | 8 | find . -type f -regextype awk -iregex '.+[.][0-9][.](mp3|flac|jpg)$' | vidir - 9 | -------------------------------------------------------------------------------- /beet-dupes-in-fs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: find dupes created by beets in filesystem 4 | 5 | find . -type f -regextype awk \ 6 | -iregex '.+[.][0-9][.](mp3|flac|jpg|jpeg|png|bmp)' "$@" 7 | -------------------------------------------------------------------------------- /beet-import-single-live-tracks: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | 5 | beet import -AsW "$@" 6 | -------------------------------------------------------------------------------- /beet-import-singles: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # vim:ft=zsh: 3 | # abstract: importing single tracks and placing them where they belong 4 | # -> Artist/+tracks/ 5 | 6 | # -- new version 7 | 8 | # first, run vidir and clean up the filenames to a %artist - %title 9 | # template 10 | 11 | # clear all tags 12 | id3shit -s *(.) 13 | 14 | # read artist and title from filename after a vidir cleanup 15 | lltag --yes -F '%a - %t' *(.) 16 | 17 | # import to beets 18 | # -s singleton mode 19 | # -A noautotag 20 | # -W no write 21 | ; beet import -sAW *(.) "$@" 22 | -------------------------------------------------------------------------------- /beet-import-singles-place-in-album-dir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | printf "importing \033[38;5;197;3;1mSINGLE\033[m tracks\n" 5 | printf "placing them in directories created from \033[38;5;30mALBUM\033[m tag\n" 6 | beet import -gAW "$@" 7 | -------------------------------------------------------------------------------- /beet-import-singles-to-label: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # vim:ft=zsh: 3 | # abstract: importing single tracks and placing according to label 4 | 5 | printf "importing \033[38;5;197;3;1mSINGLE\033[m tracks\n" 6 | 7 | printf "\033[38;5;160;1mlabel\033[m: " 8 | read LABEL 9 | 10 | printf "> running beet import -sAW --set label='$LABEL' *(.) OK?\n" 11 | 12 | read foo 13 | 14 | # -s singleton mode 15 | # -A noautotag 16 | # -W no write 17 | #beet import -sAW --set label="$LABEL" "$@" 18 | beet import -sA --set label="$LABEL" "$@" 19 | -------------------------------------------------------------------------------- /beet-ls-albums: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: list paths of albums matching query in beets database 4 | 5 | beet ls "$@" \ 6 | | dirnamep \ 7 | | sort -u \ 8 | | ls_color \ 9 | | perl -pe 's/MP3/\033[38;5;137mMP3\033[m/' \ 10 | | perl -pe 's/FLAC/\033[38;5;204mFLAC\033[m/' \ 11 | -------------------------------------------------------------------------------- /beet-ls-albums-by-label: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: list albums by artist and show record label, helper for 4 | # https://www.japh.se/2021/05/23/custom-beet-path-rules-for-record-labels.html 5 | 6 | beet ls "$@" -f '·$label· $path' \ 7 | | dirnamep \ 8 | | sort -u \ 9 | | ls_color --ifs · -k3 \ 10 | | perl -pe 's/·//g' 11 | -------------------------------------------------------------------------------- /beet-missing: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | # 2 MISSING /mnt/music8/beets_test/Sophie Zelmani/Sophie Zelmani [2005] A Decade of Dreams (MP3) 5 | # 1 MISSING /mnt/music8/beets_test/test2/Sophie_Zelmani-Live_in_Gothenburg_25.02.02 6 | 7 | 8 | beet missing -c -f '"$path"' \ 9 | | ls_color --ifs '"' -k2 \ 10 | | perl -pe 's/"(.+)": (\d+)$/sprintf("% 2d \e[31mMISSING\e[m", $2) . $1/e' 11 | -------------------------------------------------------------------------------- /beet-move-tracks-from-music1-to-music2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source_dir="/home/scp1/mnt/nasse/music" 4 | dest_dir="/home/scp1/mnt/media2/music" 5 | 6 | # List all directories with the name "+tracks" in the source directory and its subdirectories 7 | find "$source_dir" -type d -name "+tracks" | while read -r source_tracks_dir; do 8 | # Extract the relative path of the "+tracks" directory from the source directory 9 | relative_path="${source_tracks_dir#$source_dir}" 10 | 11 | # Build the corresponding destination directory path 12 | dest_tracks_dir="$dest_dir$relative_path" 13 | 14 | # Move the "+tracks" directory to the destination directory 15 | mv -nv "$source_tracks_dir" "$dest_tracks_dir" 16 | # echo "Moved '$source_tracks_dir' to '$dest_tracks_dir'" 17 | done 18 | -------------------------------------------------------------------------------- /beet-np-info: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: show all available beets info for now playing song in mpd 3 | # 4 | beet info "${XDG_MUSIC_DIR}$(mpc current --format %file%)" 5 | -------------------------------------------------------------------------------- /beet-selfripped: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # vim:ft=zsh: 3 | # abstract: list albums I've ripped myself 4 | 5 | while read d; do tree --noreport $d; done <<(beet ls comments:KNARKMACKA|dirnamep|sort -u) 6 | 7 | -------------------------------------------------------------------------------- /beet-symlink-query: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | # abstract: symlink the results of a beets query 4 | 5 | QUERY="comments:knarkmacka" 6 | 7 | while read d; do ln -s $d; done <<(beet ls comments:knarkmacka|dirnamep|sort -u) 8 | 9 | #while read d; do 10 | # ln -s $d; done 11 | # <<(beet ls "$QUERY"|dirnamep|sort -u) 12 | -------------------------------------------------------------------------------- /beet-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: beet update that will NOT change any tags, neither move files around 3 | # only update deleted/missing files to stay in sync with mpd. 4 | 5 | ~/dev/beets/beet update -F field_that_isnt -M 6 | -------------------------------------------------------------------------------- /bigrand: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: generate n random numbers 3 | use strict; 4 | 5 | print "num> "; 6 | while(my $num = ) { 7 | chomp($num); 8 | $num = ord($num) unless $num =~ /^\d+$/; 9 | my @rand = map { int(rand(101)) } 0 .. 20; 10 | print "$_\n" for sort( grep{ $num < $_ } @rand); 11 | print "num> "; 12 | } 13 | -------------------------------------------------------------------------------- /binary: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | # Given number n: 5 | # If n is 1 - return 1 6 | # If n is 0 - return 0 7 | # If n is odd, the last bit is 1 8 | # If n is even, the last bit is 0 9 | # 10 | # 42 = 2 * 21 = 10101 . 0 = 101010 11 | # 21 = 2 * 10 + 1 = 1010 . 1 = 10101 12 | 13 | my $runs = 0; 14 | sub binary { 15 | my ($n) = shift; 16 | return $n if $n == 1 || $n == 0; 17 | my $k = int($n/2); 18 | my $b = $n % 2; 19 | 20 | my $r = binary($k); 21 | return $r . $b; 22 | } 23 | 24 | print binary(@ARGV), "\n"; 25 | -------------------------------------------------------------------------------- /bob: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: mount bob the boxeebox 3 | 4 | mkdir -p /mnt/bob 5 | mount -t cifs //BOXEEBOX/bob /mnt/bob \ 6 | -o user=guest \ 7 | -o password=a \ 8 | -o uid=scp1 \ 9 | -o gid=users \ 10 | -o workgroup=workgroup \ 11 | -o ip=192.168.10.158 \ 12 | -o iocharset=utf8 \ 13 | -o vers=1.0 14 | -------------------------------------------------------------------------------- /bolaget: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | # abstract: is the systembolaget open today? 4 | printf "\033[31;1mSYSTEMBOLAGET KARLSTAD, DROTTNINGGATAN\033[m "; 5 | date "+%A %Y%m%d%n" 6 | curl -s https://www.systembolaget.se/butiker-ombud/butik/varmlands-lan/karlstad/drottninggatan-26-28-1701 | 7 | grep '>Idag' | 8 | sed 's:<[^>]*>::g;s:Idag::;s: *::' | 9 | perl -pe 's;(..:..).(.....); open $1\nclose:\b\033[31m$2;' 10 | echo 11 | -------------------------------------------------------------------------------- /bold: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: bold input 3 | 4 | use strict; 5 | use Term::ExtendedColor qw(:attributes); 6 | 7 | if(!(@ARGV)) { 8 | while(<>) { 9 | chomp; 10 | printf "%s\n", bold($_); 11 | } 12 | } 13 | else { 14 | printf "%s\n", bold("@ARGV"); 15 | } 16 | -------------------------------------------------------------------------------- /bookmark-open: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | my $bookmarks = "$ENV{HOME}/doc/links"; 4 | 5 | open(my $fh, '<', $bookmarks) or die($!); 6 | chomp(my @u = <$fh>); 7 | for my $url(@u) { 8 | system("firefox", $url); 9 | } 10 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # abstract: install missing modules automagically 3 | 4 | su -c "cpanm $( 5 | perl "./Build.PL" 2>&1 | 6 | grep -P '^\s{4}' | 7 | perl -pe 's/^\s+!\s+(.+) is.+/$1/' | 8 | perl -pe 's/\n/ /' 9 | )" 10 | 11 | perl "./Build.PL" && ./Build && su -c './Build install' && printf "\n> Done!\n" 12 | -------------------------------------------------------------------------------- /c256-grey-colorscheme: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 3 | # abstract: generate a grey 256 color colorscheme 4 | use strict; 5 | use warnings FATAL => 'all'; 6 | use vars qw($VERSION); 7 | 8 | use Number::RGB; 9 | use Term::ExtendedColor::Xresources qw(set_xterm_color set_background_color); 10 | 11 | my $red_start :RGB(0, 0, 0); # 000 12 | 13 | 14 | my $i = 0; 15 | #for(0..256) { 16 | # printf "%s\n", Number::RGB->new(rgb => [$i, 0, 0])->hex; 17 | # $i += 1; 18 | #} 19 | 20 | # set xterm colors to shades of grey 21 | for(0..1024) { 22 | my $hex_color = Number::RGB->new(rgb => [$i, $i, $i])->hex; 23 | $hex_color =~ s/^\#//; 24 | set_xterm_color({ $i => $hex_color}); 25 | $i += 1; 26 | # set_background_color($hex_color); 27 | } 28 | -------------------------------------------------------------------------------- /calc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: simple calculator 3 | use strict; 4 | 5 | print "Expression?\n"; 6 | while (1) { 7 | print '> '; 8 | chomp(my $c = ); 9 | exit(0) if(($c =~ /^\s*:q\s*/)); 10 | my $i = eval($c); 11 | printf("%d 0x%x 0%o %b %f %s \n", $i, $i, $i, $i, $i, $i); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /camera_fetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | camera=$( \ 4 | ls -Al /dev/disk/by-label | 5 | grep CANON_DC | 6 | awk '{print $11}' \ 7 | ) 8 | camera="/dev/$( echo $camera | perl -pe 's/[^a-z0-9]//g')" 9 | target="/tmp/scp1/_camera-$(date +%Y%m%d)" 10 | mount_point="/tmp/scp1/camera" 11 | 12 | mkdir -p $mount_point 13 | mkdir -p $target 14 | 15 | umount $camera &>/dev/null; 16 | mount $camera $mount_point 17 | 18 | cp -v $mount_point/DCIM/100CANON/*.JPG -t $target 19 | 20 | cd $target 21 | exifdel *.JPG 22 | rm *_original 23 | -------------------------------------------------------------------------------- /caps2esc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape' 3 | -------------------------------------------------------------------------------- /cateverything: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if the file is an image, display it 4 | if file -b $1 | grep -q image; then 5 | kitten icat $1 6 | else 7 | /home/scp1/dev/vimcat/vimcat $1 8 | fi 9 | 10 | -------------------------------------------------------------------------------- /catimg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: cat images to the terminal 3 | use strict; 4 | use warnings; 5 | 6 | use Image::Term256Color; 7 | use v5.30; 8 | 9 | say "Provide an image!" and exit unless @ARGV; 10 | print Image::Term256Color::convert( shift , { scale_ratio => .5 } ) . "\n"; 11 | 12 | -------------------------------------------------------------------------------- /cdp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #cdp - cd up on dir 3 | cd $(pwd|perl -pe 's/^((?:\/[^\/]+)*\/).*/$1/') 4 | -------------------------------------------------------------------------------- /cfdg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | tmpfile=$(mktemp --suffix='-cfdg') 4 | $HOME/bin/cfdg -w 1920 -h 1080 -b 0 -x 0.1 "$@" -o $tmpfile && feh $tmpfile 5 | -------------------------------------------------------------------------------- /chr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use utf8; 3 | use open qw(:std :utf8); 4 | for(@ARGV) { 5 | $_ = looks_like_hex($_) ? hex($_) : $_; 6 | if(! -t STDOUT) { 7 | printf "%s\n", chr $_; 8 | next; 9 | } 10 | $|++; 11 | print chr $_; 12 | select STDERR; 13 | printf " [0x%x %d]", $_, $_; 14 | select STDOUT; 15 | print "\n"; 16 | } 17 | 18 | sub looks_like_hex { 19 | my $n = shift; 20 | 21 | if($n =~ m/\A0x([a-f0-9]+|[a-f]+|[0-9]+)/) { 22 | return 1; 23 | } 24 | if($n =~ m/^[a-f]+(?:[0-9]+)?$/) { 25 | return 1; 26 | } 27 | if($n =~ m/^[0-9]+[a-f]+$/) { 28 | return 1; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /classname: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use LWP::Simple; 4 | use feature 'say'; 5 | 6 | get('http://www.classnamer.org/') =~ m{classname">(.+)/dev/null| xclip -i; 6 | sleep 2; 7 | done 8 | -------------------------------------------------------------------------------- /colorclock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: a terminal color clock 3 | use strict; 4 | use vars qw($VERSION); 5 | my $APP = q{colorclock}; 6 | $VERSION = '0.003'; 7 | 8 | use Term::ExtendedColor qw(:attributes); 9 | use Term::ExtendedColor::Xresources qw(set_xterm_color); 10 | 11 | $SIG{INT} = sub { 12 | print "\e[?25h"; 13 | set_xterm_color({ 255 => 'eeeeee'}); 14 | exit; 15 | }; 16 | 17 | $|++; 18 | print "\e[?25l"; 19 | while(1) { 20 | my($s, $m, $h) = map { sprintf("%02d", $_) } (localtime)[0..2]; 21 | print values %{ set_xterm_color({ 255 => qq{$h$m$s}}) }; 22 | printf("%s\r", bg(255, "$h$m$s")); 23 | sleep 1; 24 | } 25 | 26 | __END__ 27 | -------------------------------------------------------------------------------- /colorscheme: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: change ansi colorscheme to mine 3 | 4 | use strict; 5 | use Term::ExtendedColor::Xresources qw(set_xterm_color); 6 | 7 | 8 | my %colors = ( 9 | 0 => '121212', 10 | 8 => 'ffffff', 11 | 1 => 'ff4747', 12 | 9 => 'ff6767', 13 | 2 => '2b4626', 14 | 10 => 'b03b31', 15 | 3 => 'ff8f00', 16 | 11 => 'bdf13d', 17 | 4 => '1165e9', 18 | 12 => '5496ff', 19 | 5 => 'aef7a4', 20 | 13 => 'b50077', 21 | 6 => 'cb1c13', 22 | 14 => '6be603', 23 | 7 => 'fcdeaf', 24 | 15 => 'abcdef', 25 | ); 26 | 27 | 28 | for my $ansi(keys(%colors)) { 29 | print values %{ set_xterm_color({$ansi => $colors{$ansi} }) }; 30 | } 31 | -------------------------------------------------------------------------------- /cols: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | my $n = shift; 4 | 5 | print_cols( 1..$n ); 6 | 7 | sub print_cols { 8 | my @list = @_; 9 | 10 | my $width = 0; 11 | for (@list) { 12 | $width = length if $width < length; 13 | } 14 | 15 | my $ncols = int((@list-1)/10)+1; 16 | $ncols = 4 if $ncols > 4; 17 | 18 | my $nrows = int((@list-1)/$ncols)+1; 19 | 20 | my @cols; 21 | for my $colno ( 1..$ncols ) { 22 | push( @cols, [ splice(@list,0,$nrows) ] ); 23 | } 24 | 25 | my $mask = join( " ", ("%-${width}.${width}s")x$ncols ); 26 | for $rowno ( 0..$nrows-1 ) { 27 | my @row = map { shift @{$cols[$_]} } 0..$ncols - 1; 28 | printf( " $mask\n", @row ); 29 | } 30 | 31 | use Data::Dumper; 32 | print Dumper( \@cols ); 33 | } 34 | -------------------------------------------------------------------------------- /corona: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | curl -s https://corona-stats.online/Sweden 3 | -------------------------------------------------------------------------------- /cpan-api: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | use JSON::XS; 5 | use LWP::Simple; 6 | use Data::Dumper; 7 | 8 | { 9 | package Data::Dumper; 10 | no strict "vars"; 11 | 12 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; 13 | $Quotekeys = 0; 14 | } 15 | 16 | 17 | #http://api.metacpan.org/dist/_search\?q\=name:colorcoke 18 | 19 | my $author = shift // 'woldrich'; 20 | my $url_author = 'http://api.metacpan.org/module/_search?q=author:'; 21 | 22 | my $str = decode_json( get("$url_author/$author") ); 23 | 24 | print Dumper $str; 25 | -------------------------------------------------------------------------------- /cpan-most_used_filenames_in_root_dir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl -s -XPOST api.metacpan.org/v0/file/_search -d '{ 4 | "query": { "filtered":{"query":{"match_all":{}},"filter":{"term":{"level":0}}} 5 | }, 6 | "facets": { 7 | "license": { 8 | "terms": { 9 | "size":100, 10 | "field":"file.name" 11 | } } }, 12 | "size":0 13 | }' \ 14 | | grep -A1 count \ 15 | | perl -pe 's/^[-]+|^.+"(.+)"\s*:\s*(.+)/$1 $2/g; s/^term\s+"(.+)"/ file $1/' 16 | -------------------------------------------------------------------------------- /cpan-multi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | perlbrew exec cpanm "$@" 3 | -------------------------------------------------------------------------------- /cpan-regulars: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: cpan regular releasers 3 | 4 | curl -s --user-agent p5p http://neilb.org/cpan-regulars/ \ 5 | | html2txt \ 6 | | tail -12 \ 7 | | perl -pe 's/WOLDRICH/\033[48;5;196;1;38;5;225mWOLDRICH\033[m/' 8 | -------------------------------------------------------------------------------- /cpan-what_depends_on_x: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl -s -XPOST api.metacpan.org/v0/release/_search -d '{ 4 | "query": { 5 | "match_all": {} 6 | }, 7 | "filter": { 8 | "term": { 9 | "release.dependency.module": "Term::ExtendedColor" 10 | } 11 | } 12 | }' \ 13 | | json_deparse \ 14 | | grep distribution \ 15 | | perl -pe 's/^\s+//, s/[",]+//g' \ 16 | | awk '{print $3}' \ 17 | | sort -u \ 18 | | uniq 19 | -------------------------------------------------------------------------------- /cpan_author_search: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | use Acme::CPANAuthors; 5 | 6 | my $query = shift // 'wo.*'; 7 | 8 | my @authors = Acme::CPANAuthors->look_for($query); 9 | die("Not a known author\n") if !@authors; 10 | 11 | printf("%s (%s) belongs to %s.\n", 12 | $_->{id}, $_->{name}, $_->{category} 13 | ) for @authors; 14 | -------------------------------------------------------------------------------- /cpan_authors_swedish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | use vars qw($VERSION); 5 | 6 | $VERSION = '0.01'; 7 | 8 | use lib 'lib'; 9 | use Acme::CPANAuthors; 10 | use Acme::CPANAuthors::Swedish; 11 | 12 | my $authors = Acme::CPANAuthors->new('Swedish'); 13 | 14 | printf("There are %d swedish CPAN authors:\n", $authors->count); 15 | 16 | for my $id($authors->id) { 17 | printf(" \e[1m%s\e[m\n", $id); 18 | my @dists = $authors->distributions($id); 19 | printf(" %s\n", 20 | @dists 21 | ? join(' ', map { local $_ = $_->name . "\n" } @dists) 22 | : '[No distributions]' 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /cpan_dep: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | curl -s -XPOST api.beta.metacpan.org/release/_search -d '{ 3 | "query": { 4 | "match_all": {} 5 | }, 6 | "size": 999999, 7 | "filter": { 8 | "term": { 9 | "release.dependency.module": "Term::ExtendedColor" 10 | } 11 | } 12 | }' | json_deparse 13 | -------------------------------------------------------------------------------- /cpan_get_test_db: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget http://devel.cpantesters.org./cpanstats.db.gz 3 | wget http://devel.cpantesters.org./uploads/uploads.csv.gz 4 | wget http://devel.cpantesters.org./release/release.db.gz 5 | -------------------------------------------------------------------------------- /cpan_recent: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use LWP::Simple; 4 | 5 | my $recent = 'http://cpan.japh.se/RECENT'; 6 | 7 | my %r; 8 | for(split(/\n/, get($recent))) { 9 | if($_ =~ m{.+/(.+)[.]tar[.]gz$}) { 10 | $r{ $1 } = 1 unless $1 =~ m/^perl-?5[.]/; 11 | } 12 | } 13 | 14 | for my $d(sort(keys(%r))) { 15 | printf("%s\n", $d); 16 | } 17 | -------------------------------------------------------------------------------- /cpan_upload: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | 5 | use CPAN::Uploader; 6 | 7 | my $file = shift or die("Usage: $0 [FILE...]\n"); 8 | 9 | my $uploader = CPAN::Uploader->new( 10 | { 11 | user => 'WOLDRICH', 12 | password => do { $_ = `smokingkills`; chomp $_; $_ }, 13 | debug => 1, 14 | }, 15 | ); 16 | 17 | $uploader->upload_file( $file ); 18 | -------------------------------------------------------------------------------- /cpanm-github: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | 5 | my @args = grep { /^-/ } @ARGV; 6 | my ($src) = grep { !/^-/ } @ARGV; 7 | die "Usage: $0 user/proj[/branch]" unless $src; 8 | 9 | my ($user, $proj, $branch) = split m{/}, $src; 10 | $branch = 'master' unless defined $branch; 11 | 12 | my $url = "http://github.com/$user/$proj/tarball/$branch"; 13 | 14 | exec 'cpanm', @args, $url; 15 | die "cannot exec: $!"; 16 | 17 | -------------------------------------------------------------------------------- /cpanupgrade: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)' 4 | -------------------------------------------------------------------------------- /cpmpd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # transfer the playing song on the remote mpd server to the local box 3 | 4 | target=$HOME/http/japh.se/music 5 | 6 | if [ -d $target ]; then 7 | file="/mnt/Music_1/$(mpc -h $MPD_HOST --format '%file%'|head -1)" 8 | file=$(echo $file| perl -pe 's/([;<>\*\|&\$!#\(\)\[\]\{\}:])/\\$1/gm'); 9 | scp -P 19217 scp1@192.168.1.128:"'$file'" $target 10 | fi 11 | -------------------------------------------------------------------------------- /cups_fix: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | my $chown = 'chown root:lp'; 5 | my $chmod = 'chmod 660'; 6 | 7 | my $device; 8 | 9 | open(my $fh, '-|', 'lsusb') or die($!); 10 | while(<$fh>) { 11 | if($_ =~ m/PIXMA/) { 12 | my($bus, $device) = $_ =~ m{Bus (\d+) Device (\d+)}; 13 | print "Printer found on $bus/$device\n\n"; 14 | print "chmod 660 /dev/bus/usb/$bus/$device \\ \n"; 15 | print "chown root:lp /dev/bus/usb/$bus/$device \\ \n"; 16 | print "/etc/rc.d/cups restart \\ \n\n-\n"; 17 | print "http://localhost:631/admin/\n"; 18 | 19 | last; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | latex cv.tex 3 | dvips -Ppdf cv.dvi -o 4 | ps2pdf cv.ps 5 | apvlv cv.pdf 6 | pdffonts cv.pdf 7 | -------------------------------------------------------------------------------- /dahbug: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | function locate_dahbug { 4 | if [ -f "$(git rev-parse --show-toplevel)"/../dahbug.log ]; then 5 | echo "$(git rev-parse --show-toplevel)"/../dahbug.log 6 | elif [ -f "$(git rev-parse --show-toplevel)"/dahbug.log ]; then 7 | echo "$(git rev-parse --show-toplevel)"/dahbug.log 8 | else 9 | echo "" 10 | fi 11 | } 12 | 13 | dahbug_path=$(locate_dahbug) 14 | 15 | tail -F $dahbug_path 16 | -------------------------------------------------------------------------------- /ddmpc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ddmpc 3 | 4 | out=$(mpc $(mpc help | grep " mpc [a-z]" | awk '{print $2}' \ 5 | | dmenu -i -b $DMENU_LINES -fn $DMENU_FONT -nb $DMENU_NORMAL_BG \ 6 | -nf $DMENU_NORMAL_FG -sb $DMENU_SELECT_BG -sf $DMENU_SELECT_FG)) 7 | 8 | echo "$out" | dzen2 -p 5 \ 9 | -fn -xos4-terminus-medium-r-normal--24-240-72-72-c-120-koi8-u \ 10 | -x $DZEN_X_POS -y $DZEN_Y_POS \ 11 | -ta $DZEN_ALIGNMENT -sa $DZEN_ALIGNMENT -w $DZEN_WIDTH \ 12 | -fg $DZEN_FG -bg $DZEN_BG 13 | -------------------------------------------------------------------------------- /define: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: look up words in the terminal 3 | use strict; 4 | 5 | use Net::Dict; 6 | 7 | my $word = shift; 8 | my $dict = Net::Dict->new('dict.org'); 9 | $dict->setDicts('wn', 'web1913'); 10 | 11 | my $defs = $dict->define( $word ); 12 | print $defs->[0]->[1]; 13 | -------------------------------------------------------------------------------- /deploy_japh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | scp -r ~/dev/japh.se/_site/* pi@pi:httpd 4 | -------------------------------------------------------------------------------- /diffurl: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | $EDITOR -dMN \ 3 | -c 'windo set fen dip& dip+=foldcolumn:1,vertical scb' \ 4 | -dMN <(curl -s "$1") <(curl -s "$2") 5 | -------------------------------------------------------------------------------- /dirnamep: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl:et: 3 | # abstract: grab input from stdin and dirname it 4 | 5 | use strict; 6 | use File::Basename; 7 | 8 | 9 | while(<>) { 10 | chomp; 11 | my $dir = dirname($_); 12 | printf "%s\n", $dir; 13 | } 14 | -------------------------------------------------------------------------------- /dltrack: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: track a file while it's being downloaded 3 | # usage: dltrack /path/to/file-that-is-being-downloaded.ext 4 | 5 | perl -e 'BEGIN{$|=1;$f="@ARGV";$s=(stat$f)[7];$t=time}while(sleep 1){printf"\r$f %s bytes at %.2f Kb/s ",$_=(stat$f)[7],($_-$s)/1024/(time-$t)}' $1 6 | -------------------------------------------------------------------------------- /dmenushit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | $(dmenu_path | \ 3 | dmenu -fn '-windows-montecarlo-medium-r-normal--11-110-72-72-c-60-microsoft-cp1252' \ 4 | -nb \#111111 -nf \#d7005f -sb \#111111 -sf \#299ee8) 5 | 6 | -------------------------------------------------------------------------------- /docupdate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | scp -r -P 19216 $HOME/usr/share/doc/* scp1@laleh::http/japh.se/doc/ 3 | -------------------------------------------------------------------------------- /domain_snatch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: generate a valid domain name and snatch it 3 | use strict; 4 | use LWP::Simple (); 5 | 6 | my $u = 'http://www.iis.se/data/bardate_domains.txt'; 7 | 8 | my $d = max_len_domain(shift(@ARGV) // 3, get($u)); 9 | 10 | for my $domain(sort{ $d->{$b} cmp $d->{$a} } keys( %{ $d } )) { 11 | printf("%5s - %s\n", $domain, $d->{$domain}); 12 | } 13 | 14 | sub max_len_domain { 15 | my $len = shift || 3; 16 | $len += 3; # .se 17 | my $s = shift or return; 18 | my %h; 19 | 20 | map { (length($_) == $len) && ($h{$_} = $s->{$_}) } keys %$s; 21 | return \%h; 22 | 23 | } 24 | 25 | sub get { 26 | my %d; 27 | map { m{([[a-z0-9-_.]+[.]se)\s+(.+)} and $d{$1} = $2 } 28 | split(/\n/, LWP::Simple::get( $_[0] )); 29 | return \%d; 30 | } 31 | -------------------------------------------------------------------------------- /dump: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # dump to httpd 3 | 4 | 5 | if [ "$1" == "-d" ]; then 6 | scp -P 19216 -r /mnt/Music_1/$(mpc --format %file% | 7 | head -1 | 8 | perl -pe 's/(\/.*\/).*$/$1/g') scp1@192.168.1.33:/srv/http/psy/dump/ && echo "http://psy.trapd00r.se/dump/$(mpc --format %file% | 9 | head -1 | 10 | perl -pe 's/^..?\///g')"| 11 | xclip 12 | else 13 | scp /mnt/Music_1/$(mpc --format %file% |head -1) 14 | scp1@192.168.1.33:/srv/http/psy/dump/ -P 19216 && echo "http://psy.trapd00r.se/dump/$(mpc --format %file% | 15 | head -1 | 16 | perl -pe 's/.*\/.*\///g')"| 17 | xclip 18 | fi 19 | -------------------------------------------------------------------------------- /dusch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: what's eating all the space? 3 | IFS="$(printf '\n\t')" 4 | du -sk $@ \ 5 | | sort -nr \ 6 | | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }' 7 | -------------------------------------------------------------------------------- /duschiamej: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh et sw=2 smc=80 cc=: 3 | # abstract: what's eating all the space, take two? 4 | 5 | where="${@:-.}" 6 | printf '\033[?7l' 7 | 8 | # hi, I was going to explain why the abuse of the %d format specifier for the 9 | # first column is not a bug, but there's pie in the kitchen that needs to be 10 | # eaten and you, you could need some exercise 11 | dush -mfdcsn $(($(stty size|awk '{print $1}') / 2)) $where 2>&1 \ 12 | | awk -F: ' 13 | { 14 | printf("\033[38;5;202;1m% 6d\033[m\033[38;5;241mMB\033[m \033[38;5;86m%1s\033[m\033[38;5;30m%s\033[m\n", $2, "", $1 ) 15 | } 16 | ' 17 | printf '\033[?7h' 18 | -------------------------------------------------------------------------------- /ebookextract: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | find . -type f -iname '*.zip' -print0 \ 3 | | xargs -L1 -0 unzip -j -o -C 4 | yes|unrarec 5 | yes|clean 6 | 7 | chmod a-x og-w **/*(.) 8 | -------------------------------------------------------------------------------- /epoch2localtime: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | my $time = @ARGV ? shift : <>; 5 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); 6 | 7 | my %days = ( 8 | 0 => 'Sunday', 9 | 1 => 'Monday', 10 | 2 => 'Tuesday', 11 | 3 => 'Wednesday', 12 | 4 => 'Thursday', 13 | 5 => 'Friday', 14 | 6 => 'Saturday', 15 | 7 => 'Sunday', 16 | ); 17 | 18 | printf "%s %s-%02d-%02d %02d:%02d:%02d\n", $days{$wday}, $year += 1900, $mon += 1, $mday, $hour, $min, $sec, 19 | -------------------------------------------------------------------------------- /exifdel: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # abstract: delete all exif data from photos 3 | 4 | exiftool -all= "$@" 5 | # kshglob doesn't allow use to do (jpe?g|[ct]iff ...), that's why it looks like 6 | # this :( 7 | #setopt kshglob 8 | rm -v *.(jpg|jpeg|png|tiff|pdf)_original 9 | -------------------------------------------------------------------------------- /facebook_url_count: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: how many times have $url been shared on facebook? 3 | 4 | use LWP::Simple; 5 | 6 | my $url = shift || 'http://graph.facebook.com/'; # 75 2011-03-21 7 | $url = "http://$url" if $url !~ /^http/; 8 | 9 | print get( "http://graph.facebook.com/$url" ); 10 | -------------------------------------------------------------------------------- /facebook_user_info: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: print information for $user on facebook 3 | 4 | use LWP::Simple; 5 | 6 | my $user = shift // 'zibri'; 7 | 8 | print get( "http://graph.facebook.com/$user" ); 9 | -------------------------------------------------------------------------------- /fehctrl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | kill('USR' . (pop =~ m/^n/ ? 1 : 2), qx(pgrep feh)); 3 | -------------------------------------------------------------------------------- /ff: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find . -type f \ 4 | | sort \ 5 | | perl -MFile::LsColor=ls_color_internal -lne \ 6 | 'if($_ =~ m{^([.]/)([^/]+)/(.+)}) { 7 | printf "\e[1;3m$1\e[m\e[38;5;30m$2/\e[m%s\n", ls_color_internal($3) 8 | }' 9 | -------------------------------------------------------------------------------- /fileinfo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | file "$@" 3 | du -hs "$@" 4 | -------------------------------------------------------------------------------- /filetypes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/filetypes -------------------------------------------------------------------------------- /fillmp3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umount /mnt/mp3 3 | mount /dev/sdi1 /mnt/mp3 && \ 4 | cd /mnt/mp3/MUSIC && \ 5 | rmfile * && \ 6 | mv /home/scp1/toburn/* . && \ 7 | cd /mnt && \ 8 | umount mp3 && \ 9 | printf '\e[38;5;34;1mFinished.\e[m\n' 10 | -------------------------------------------------------------------------------- /filter_ext_lscolor: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 3 | # abstract: prints filetypes matching query, colored if defined in LS_COLORS 4 | # usage: filter_ext_lscolor audio 5 | use strict; 6 | use warnings FATAL => 'all'; 7 | use autodie qw(:all); 8 | 9 | use File::Extension qw(filter_by_meta); 10 | 11 | use File::LsColor qw(ls_color); 12 | 13 | 14 | my $query = shift or die "What to filter?\n"; 15 | 16 | my $filter = filter_by_meta($query); 17 | 18 | for my $ext(sort(keys(%{$filter}))) { 19 | printf("%s | %s\n", sprintf("%40s", $filter->{$ext}), ls_color(" .$ext")); 20 | } 21 | -------------------------------------------------------------------------------- /fimpc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | use strict; 4 | # abstract: use fifos to control mpd using mpc 5 | 6 | sub readFifo { 7 | my $FIFO = shift; 8 | while(1) { 9 | unless(-p $FIFO) { 10 | unlink $FIFO; 11 | system('mknod', $FIFO, 'p'); 12 | } 13 | open(FIFOR, "< $FIFO") or die "Cannot read $FIFO: $!\n"; 14 | while() { 15 | my $cmd = $_; 16 | system("mpc $cmd"); 17 | } 18 | } 19 | } 20 | 21 | &readFifo('/tmp/tompc'); 22 | -------------------------------------------------------------------------------- /findls: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . |ls_color 3 | -------------------------------------------------------------------------------- /findrec: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find . -type f -print0 | perl -0 -wn -e '@f=<>; foreach $file (@f){ (@el)=(stat($file)); push @el, $file; push @files,[ @el ];} @o=sort{$a->[9]<=>$b->[9]} @files; for $i (0..$#o){print scalar localtime($o[$i][9]), "\t$o[$i][-1]\n";}'|tail 4 | 5 | -------------------------------------------------------------------------------- /firefox_gtk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | GTK2_RC_FILES=/home/scp1/etc/gtkrc-firefox /usr/bin/firefox -new-tab "$@" 3 | -------------------------------------------------------------------------------- /fix-EHCI_TT_NEWSCHED: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Enable CONFIG_USB_EHCI_TT_NEWSCHED and recompile 3 | ## 4 | ## -> Device Drivers 5 | ## -> USB support 6 | ## -> Support for Host-side USB 7 | ## -> EHCI HCD (USB 2.0) support 8 | ## 9 | ## As a temporary fix, this script should work 10 | 11 | echo 64 > /sys/block/sdn/device/max_sectors && mount -a 12 | -------------------------------------------------------------------------------- /font-10-anonymous: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Anonymous Pro:style=Regular:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Anonymous Pro:style=Bold:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Anonymous Pro:style=Italic:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 9 | printf '\033]713;%s\007' \ 10 | 'xft:Anonymous Pro:style=Bold Italic:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-10-anonymous-it: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Anonymous Pro:style=Regular:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Anonymous Pro:style=Bold:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 7 | # xft:DejaVu Sans Mono:style=Bold:pixelsize=10:antialias=1:hinting=1:hintstyle=3 8 | printf '\033]712;%s\007' \ 9 | '6x9' 10 | #'-b&h-lucidatypewriter-medium-r-normal-sans-11-80-100-100-m-70-iso8859-1' 11 | printf '\033]713;%s\007' \ 12 | '-nil-profont-medium-r-normal--10-100-72-72-c-50-iso8859-1' 13 | -------------------------------------------------------------------------------- /font-10-dejavu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=10:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-10-fixed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Fixed:weight=light:pixelsize=10:antialias=0' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Fixed:weight=bold:pixelsize=10:antialias=0' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Fixed:pixelsize=9:antialias=0' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-10-profont: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' \ 3 | 'xft:ProFontWindows Nerd Font Mono:style=Book:pixelsize=12:antialias=0:hinting=none:hintstyle=0' 4 | printf '\033]711;%s\007' \ 5 | 'xft:ProFont:style=Regular:pixelsize=10:embolden=1' 6 | printf '\033]712;%s\007' \ 7 | 'xft:ProFontIIx Nerd Font Mono:style=Book:pixelsize=9:antialias=0:hinting=0:hintstyle=0' 8 | printf '\033]713;%s\007' \ 9 | '-windows-montecarlo-bold-r-normal--11-110-72-72-c-60-microsoft-cp1252' 10 | -------------------------------------------------------------------------------- /font-11-dejavu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=11:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-11-neepalt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | '-jmk-neep-medium-r-normal--11-100-75-75-c-60-iso8859-1' 5 | printf '\033]711;%s\007' \ 6 | '-jmk-neep-bold-r-normal--11-100-75-75-c-60-iso8859-1' 7 | printf '\033]712;%s\007' \ 8 | 6x9 9 | printf '\033]713;%s\007' \ 10 | '-jmk-neep-bold-r-semicondensed--11-100-75-75-c-50-iso8859-1' 11 | -------------------------------------------------------------------------------- /font-11-profont: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' \ 3 | '-nil-profont-medium-r-normal--11-110-72-72-c-60-iso8859-1' 4 | printf '\033]711;%s\007' \ 5 | 'xft:ProFont:style=Regular:pixelsize=11:embolden=1' 6 | printf '\033]712;%s\007' \ 7 | 'xft:Lucida:style=Sans Italic:antialias=1:hinting=1:hintstyle=3:pixelsize=11' 8 | printf '\033]713;%s\007' \ 9 | '-erus-erusfont-bold-r-normal--11-80-100-100-c-60-iso10646-1' 10 | -------------------------------------------------------------------------------- /font-12-anonymous: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Anonymous Pro:style=Regular:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Anonymous Pro:style=Bold:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 7 | 8 | printf '\033]712;%s\007' \ 9 | 'xft:ProFontWindows Nerd Font:style=Book:pixelsize=12:antialias=none' 10 | 11 | printf '\033]713;%s\007' \ 12 | 'xft:Anonymous Pro:style=Regular:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 13 | -------------------------------------------------------------------------------- /font-12-anonymous-test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Anonymous Pro:style=Regular:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Anonymous Pro:style=Bold:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Anonymous Pro:style=Italic:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 9 | printf '\033]713;%s\007' \ 10 | 'xft:Anonymous Pro:style=Regular:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-12-dejavu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=12:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-12-droid: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Droid Sans Mono Slashed:style=Regular:pixelsize=12:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Droid Sans Mono Slashed:pixelsize=12:antialias=1:hinting=1:embolden=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Droid Sans Mono Slashed:pixelsize=12:antialias=1:hinting=1:slant=italic' 9 | printf '\033]713;%s\007' \ 10 | '-nil-profont-medium-r-normal--15-150-72-72-c-70-iso8859-1' 11 | -------------------------------------------------------------------------------- /font-12-nerdfonts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | 5 | 6 | printf "\033]712;%s\007" \ 7 | "xft:ProFontWindows Nerd Font:style=Book:pixelsize=12:antialias=none" 8 | 9 | -------------------------------------------------------------------------------- /font-12-terminus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | '-xos4-terminus-bold-r-normal--12-120-72-72-c-60-iso10646-1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:xos4 Terminus:style=Bold:pixelsize=12:antialias=1:hinting=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Anonymous Pro:style=Italic:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 9 | printf '\033]713;%s\007' \ 10 | 'xft:Anonymous Pro:style=Bold Italic:pixelsize=12:antialias=1:hinting=1:hintstyle=3' 11 | 12 | -------------------------------------------------------------------------------- /font-13-dejavu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=13:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=13:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=13:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=13:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-14-dejavu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=14:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=14:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=14:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=14:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-14-terminus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Terminus:style=Regular:pixelsize=14:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Terminus:style=Bold:pixelsize=14:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Terminus:style=Regular:pixelsize=14:antialias=1:hinting=1:hintstyle=3' 9 | printf '\033]713;%s\007' \ 10 | 'xft:Terminus:style=Bold:pixelsize=14:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-14-unifont: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The GNU unifont claims to support all printable codepoints in the Unicode 5.1 3 | # Basic Multilingual Plane (BMP). That's U+0000..U+ffff, a total of 65536 4 | # codepoints. 5 | 6 | printf '\033]710;xft:unifont:pixelsize=14:antialias=0:hinting=1\007' 7 | printf '\033]711;xft:unifont:pixelsize=14:antialias=0:hinting=1:hintstyle=3:embolden=1\007' 8 | printf '\033]712;xft:unifont:pixelsize=14:antialias=0:hinting=1:\007' 9 | printf '\033]713;xft:unifont:pixelsize=14:antialias=0:hinting=1:\007' 10 | -------------------------------------------------------------------------------- /font-15-proggytiny: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:ProggyTinyTTSZ:weight=light:spacing=proportional:pixelsize=15:antialias=0:hinting=0:width=condensed' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Fixed:pixelsize=10:antialias=0:weight=light' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Fixed:pixelsize=9:antialias=0' 9 | -------------------------------------------------------------------------------- /font-16-daewoo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | -daewoo-mincho-medium-r-normal--16-120-100-100-c-160-ksc5601.1987-0 5 | printf '\033]711;%s\007' 7x13bold 6 | #-schumacher-clean-bold-r-normal--13-130-75-75-c-80-iso646.1991-irv 7 | printf '\033]712;%s\007' \ 8 | -nil-profont-medium-r-normal--12-120-72-72-c-60-iso8859-1 9 | #-windows-proggycleansz-medium-r-normal--13-80-96-96-c-70-iso8859-1 10 | #-schumacher-clean-medium-r-normal--13-130-75-75-c-60-iso646.1991-irv 11 | -------------------------------------------------------------------------------- /font-16-dejavu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=16:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=16:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=16:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=16:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-16-dejavu64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=16:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=16:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=16:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=16:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-16-droid: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Droid Sans Mono Slashed:style=Regular:pixelsize=16:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Droid Sans Mono Slashed:pixelsize=16:antialias=1:hinting=1:embolden=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Droid Sans Mono Slashed:pixelsize=16:antialias=1:hinting=1:slant=italic' 9 | printf '\033]713;%s\007' \ 10 | '-nil-profont-medium-r-normal--15-150-72-72-c-70-iso8859-1' 11 | -------------------------------------------------------------------------------- /font-16-monofur: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:monofur:style=Regular:pixelsize=16:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:monofur:pixelsize=16:antialias=1:hinting=1:embolden=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:monofur:pixelsize=16:antialias=1:hinting=1:slant=italic' 9 | printf '\033]713;%s\007' \ 10 | '-xos4-terminus-medium-r-normal--16-160-72-72-c-80-koi8-u' 11 | -------------------------------------------------------------------------------- /font-16-terminus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:xos4 Terminus:style=Regular:pixelsize=16:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:xos4 Terminus:style=Bold:pixelsize=16:antialias=1:hinting=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Aerial Mono:style=italic:pixelsize=16:antialias=1:hinting=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:Aerial Mono:style=Bold Italic:pixelsize=16:antialias=1:hinting=1' 11 | -------------------------------------------------------------------------------- /font-18-terminus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:xos4 Terminus:style=Regular:pixelsize=18:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:xos4 Terminus:style=Bold:pixelsize=18:antialias=1:hinting=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Aerial Mono:style=italic:pixelsize=18:antialias=1:hinting=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:Aerial Mono:style=Bold Italic:pixelsize=18:antialias=1:hinting=1' 11 | -------------------------------------------------------------------------------- /font-20-dejavu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=20:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\007' \ 6 | 'xft:DejaVu Sans Mono:style=Bold:pixelsize=20:antialias=1:hinting=1:hintstyle=3' 7 | printf '\033]712;%s\007' \ 8 | 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=20:antialias=1:hinting=1:hintstyle=3:embolden=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=20:antialias=1:hinting=1:hintstyle=3' 11 | -------------------------------------------------------------------------------- /font-20-terminus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | '-xos4-terminus-medium-r-normal--20-200-72-72-c-100-iso10646-1' 5 | printf '\033]711;%s\007' \ 6 | '-xos4-terminus-bold-r-normal--20-200-72-72-c-100-iso10646-1' 7 | printf '\033]712;%s\007' \ 8 | '-xos4-terminus-medium-r-normal--18-180-72-72-c-100-iso10646-1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:FiraMono Nerd Font:style=Bold:pixelsize=18' 11 | -------------------------------------------------------------------------------- /font-2022: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\a' \ 4 | 'xft:Anonymous Pro:style=Regular:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 5 | printf '\033]711;%s\a' \ 6 | "xft:Anonymous Pro:style=Bold:pixelsize=10:antialias=0:hinting=0:hintstyle=3" 7 | printf '\033]712;%s\a' \ 8 | '-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1' 9 | printf '\033]713;%s\a' \ 10 | 'neep-10' 11 | -------------------------------------------------------------------------------- /font-24-droid: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Droid Sans Mono Slashed:style=Regular:pixelsize=24:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Droid Sans Mono Slashed:pixelsize=24:antialias=1:hinting=1:embolden=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Droid Sans Mono Slashed:pixelsize=24:antialias=1:hinting=1:slant=italic' 9 | printf '\033]713;%s\007' \ 10 | -xos4-terminus-bold-r-normal--24-240-72-72-c-120-koi8-u 11 | -------------------------------------------------------------------------------- /font-32-droid: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Droid Sans Mono Slashed:style=Regular:pixelsize=32:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Droid Sans Mono Slashed:pixelsize=32:antialias=1:hinting=1:embolden=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Droid Sans Mono Slashed:pixelsize=32:antialias=1:hinting=1:slant=italic' 9 | printf '\033]713;%s\007' \ 10 | -xos4-terminus-bold-r-normal--32-320-72-72-c-160-koi8-u 11 | -------------------------------------------------------------------------------- /font-32-monofur: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:monofur:style=Regular:pixelsize=32:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:monofur:pixelsize=32:antialias=1:hinting=1:embolden=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:monofur:pixelsize=32:antialias=1:hinting=1:slant=italic' 9 | printf '\033]713;%s\007' \ 10 | -xos4-terminus-bold-r-normal--32-320-72-72-c-160-koi8-u 11 | -------------------------------------------------------------------------------- /font-32-terminus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:xos4 Terminus:style=Regular:pixelsize=32:antialias=1:hinting=1' 5 | printf '\033]711;%s\007' \ 6 | 'xft:xos4 Terminus:style=Bold:pixelsize=32:antialias=1:hinting=1' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Aerial Mono:style=italic:pixelsize=32:antialias=1:hinting=1' 9 | printf '\033]713;%s\007' \ 10 | 'xft:Aerial Mono:style=Bold Italic:pixelsize=32:antialias=1:hinting=1' 11 | -------------------------------------------------------------------------------- /font-5x7: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' 5x7 3 | printf '\033]711;%s\007' 'xft:fixed:pixelsize=7:antialias=1:hinting=1:embolden=1' 4 | printf '\033]712;%s\007' '-schumacher-clean-medium-r-normal--6-60-75-75-c-40-iso646.1991-irv' 5 | printf '\033]713;%s\007' 5x7 6 | -------------------------------------------------------------------------------- /font-5x8: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' 5x8 3 | printf '\033]711;%s\007' \ 4 | 'xft:Neep:style=Bold SemiCondensed:pixelsize=10' 5 | printf '\033]712;%s\007' \ 6 | 'xft:Neep:SemiCondensed:pixelsize=10' 7 | -------------------------------------------------------------------------------- /font-6x10: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\a' \ 3 | 6x10 4 | printf '\033]711;%s\a' \ 5 | '-fontforge-proggytinysz-bold-r-normal--10-80-96-96-c-60-iso8859-1' 6 | printf '\033]712;%s\a' \ 7 | '-b&h-lucidatypewriter-bold-r-normal-sans-10-100-75-75-m-60-iso10646-1' 8 | -------------------------------------------------------------------------------- /font-6x9: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' 6x9 3 | printf '\033]711;%s\007' 6x9 4 | printf '\033]712;%s\007' 6x9 5 | -------------------------------------------------------------------------------- /font-7x13: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' 7x13 3 | printf '\033]711;%s\007' 7x13bold 4 | #-schumacher-clean-bold-r-normal--13-130-75-75-c-80-iso646.1991-irv 5 | printf '\033]712;%s\007' \ 6 | -nil-profont-medium-r-normal--12-120-72-72-c-60-iso8859-1 7 | #-windows-proggycleansz-medium-r-normal--13-80-96-96-c-70-iso8859-1 8 | #-schumacher-clean-medium-r-normal--13-130-75-75-c-60-iso646.1991-irv 9 | -------------------------------------------------------------------------------- /font-7x14: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' 7x14 3 | printf '\033]711;%s\007' 7x14bold 4 | printf '\033]712;%s\007' \ 5 | -------------------------------------------------------------------------------- /font-8-fixed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Fixed:weight=medium:pixelsize=8:antialias=0' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Fixed:weight=bold:pixelsize=8:antialias=0' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Fixed:pixelsize=8:antialias=0' 9 | -------------------------------------------------------------------------------- /font-9-fixed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:Fixed:weight=medium:pixelsize=9:antialias=0' 5 | printf '\033]711;%s\007' \ 6 | 'xft:Fixed:weight=bold:pixelsize=9:antialias=0' 7 | printf '\033]712;%s\007' \ 8 | 'xft:Fixed:pixelsize=8:antialias=0' 9 | -------------------------------------------------------------------------------- /font-argv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | font=$1 4 | 5 | printf "\033]710;%s\007" "$font:antialias=none:hinting=none" 6 | printf "\033]711;%s\007" "$font:antialias=none:hinting=none" 7 | printf "\033]712;%s\007" "$font:antialias=none:hinting=none" 8 | printf "\033]713;%s\007" "$font:antialias=none:hinting=none" 9 | 10 | -------------------------------------------------------------------------------- /font-atari: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | # abstract: set terminal font to the Atari 800XL std font 4 | 5 | printf "\033]710;%s\007" 'xft:Atari:pixelsize=16:antialias=none' 6 | printf "\033]711;%s\007" 'xft:Atari:pixelsize=16:antialias=none' 7 | printf "\033]712;%s\007" 'xft:Atari:pixelsize=16:antialias=none' 8 | printf "\033]713;%s\007" 'xft:Atari:pixelsize=16:antialias=none' 9 | -------------------------------------------------------------------------------- /font-clean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf '\033]710;%s\007' \ 3 | -schumacher-clean-medium-r-normal--10-100-75-75-c-50-iso646.1991-irv 4 | printf '\033]711;%s\007' \ 5 | -fontforge-proggytinysz-bold-r-normal--10-80-96-96-c-60-iso8859-1 6 | printf '\033]712;%s\007' \ 7 | -nil-profont-medium-r-normal--10-100-72-72-c-50-iso8859-1 8 | -------------------------------------------------------------------------------- /font-cleanproggy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007\033]711;%s\007\033]712;%s\007' \ 4 | -schumacher-clean-medium-r-normal--10-100-75-75-c-50-iso646.1991-irv \ 5 | -fontforge-proggytinysz-bold-r-normal--10-80-96-96-c-60-iso8859-1 \ 6 | -nil-profont-medium-r-normal--10-100-72-72-c-50-iso8859-1 7 | -------------------------------------------------------------------------------- /font-fixed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh smc=120 tw=120 et: 3 | printf "\033c\033(K\033[J\033[m\033[?25h" 4 | xft='hinting=0:autohint=0:rgba=0:antialias=0:lcdfilter=0' 5 | printf "\033]710;xft:Fixed:size=9:${xft}\a" 6 | printf "\033]711;xft:Fixed:size=9:${xft}:embolden=1\a" 7 | printf "\033]712;-fontforge-proggytinysz-bold-r-normal--10-80-96-96-c-60-iso8859-1\a" 8 | printf "\033]713;xft:Fixed:size=9:${xft}:embolden=1:scale=.8:lcdfilter=2:autohint=1:hintstyle=3\a" 9 | -------------------------------------------------------------------------------- /font-monte: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\a' \ 4 | '-windows-montecarlo-medium-r-normal--11-110-72-72-c-60-microsoft-cp1252' 5 | printf '\033]711;%s\a' \ 6 | '-windows-montecarlo-bold-r-normal--11-110-72-72-c-60-microsoft-cp1252' 7 | 8 | printf '\033]712;%s\a' \ 9 | 'xft:ProFont:style=Regular:pixelsize=10:embolden=1' 10 | 11 | printf '\033]713;%s\a' \ 12 | 'xft:ProFont:style=Regular:pixelsize=10:antialias=0:hinting=0:hintstyle=0' 13 | # '-jmk-neep-medium-r-normal--11-100-75-75-c-60-iso8859-1' 14 | -------------------------------------------------------------------------------- /font-nerdanonymous: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf "\033]710;%s\007" 'xft:AnonymicePro Nerd Font:style=Regular:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 4 | printf "\033]711;%s\007" 'xft:AnonymicePro Nerd Font:style=Bold:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 5 | printf "\033]712;%s\007" 'xft:AnonymicePro Nerd Font:style=Italic:pixelsize=11:antialias=1:hinting=1:hintstyle=3' 6 | printf "\033]713;%s\007" 'xft:AnonymicePro Nerd Font:style=Bold Italic:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 7 | -------------------------------------------------------------------------------- /font-nerdfonts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033]710;%s\007" 'xft:ProFontIIx Nerd Font Mono:style=Book:pixelsize=9:antialias=0:hinting=0:hintstyle=0' 3 | printf "\033]711;%s\007" 'xft:ProFontIIx Nerd Font Mono:style=Book:pixelsize=9:antialias=1:hinting=1:hintstyle=3' 4 | printf "\033]712;%s\007" 'xft:ProFontIIx Nerd Font Mono:style=Book:pixelsize=9:antialias=1:hinting=1:hintstyle=3' 5 | printf "\033]713;%s\007" 'xft:ProFontIIx Nerd Font Mono:style=Book:pixelsize=9:antialias=1:hinting=1:hintstyle=3' 6 | -------------------------------------------------------------------------------- /font-tamsyn: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033]710;%s\007" \ 3 | 'xft:Misc Tamsyn:style=Regular:antialias=none:hinting=0:pixelsize=16' 4 | printf "\033]711;%s\007" \ 5 | 'xft:Misc Tamsyn:style=Bold:antialias=none:hinting=0:pixelsize=16' 6 | printf "\033]712;%s\007" \ 7 | 'xft:Terminus:style=Regular=none:hinting=0:pixelsize=16' 8 | printf "\033]713;%s\007" \ 9 | 'xft:Profont:style=Bold:antialias=none:hinting=0:pixelsize=16' 10 | -------------------------------------------------------------------------------- /font-tamsyn-12: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033]710;%s\007" \ 3 | 'xft:Misc Tamsyn:style=Regular:antialias=none:hinting=0:pixelsize=12' 4 | printf "\033]711;%s\007" \ 5 | 'xft:Misc Tamsyn:style=Bold:antialias=none:hinting=0:pixelsize=12' 6 | printf "\033]712;%s\007" \ 7 | 'xft:Misc Tamsyn:style=Regular=none:hinting=0:pixelsize=11' 8 | printf "\033]713;%s\007" \ 9 | 'xft:Misc Tamsyn:style=Bold:antialias=none:hinting=0:pixelsize=11' 10 | -------------------------------------------------------------------------------- /font-tamsyn-20: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033]710;%s\007" \ 3 | 'xft:Misc Tamsyn:style=Regular:antialias=none:hinting=0:pixelsize=20 ' 4 | printf "\033]711;%s\007" \ 5 | 'xft:Misc Tamsyn:style=Bold:antialias=none:hinting=0:pixelsize=20 ' 6 | printf "\033]712 ;%s\007" \ 7 | 'xft:Misc Tamsyn:style=Regular=none:hinting=0:pixelsize=18' 8 | printf "\033]713;%s\007" \ 9 | 'xft:Misc Tamsyn:style=Bold:antialias=none:hinting=0:pixelsize=18' 10 | -------------------------------------------------------------------------------- /font-terminus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | pickyfont set ter2 normal 3 | pickyfont set ter2b bold 4 | pickyfont set pro2 italic 5 | -------------------------------------------------------------------------------- /font-ubuntu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf '\033]710;%s\007' \ 4 | 'xft:UbuntuTitleBook:style=Book,Ubuntu-Title' 5 | 6 | printf '\033]711;%s\007' \ 7 | 'xft:UbuntuTitleBold:style=Bold,Ubuntu-Title:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 8 | printf '\033]712;%s\007' \ 9 | 'xft:Liberation Sans Narrow:style=Regular:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 10 | 11 | 12 | 13 | # 'xft:Ubuntu,Ubuntu Light:style=Light Italic,Italic:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 14 | # 'xft:DejaVu LGC Sans Mono:style=Book:pixelsize=10:antialias=1:hinting=1:hintstyle=3:embolden=1' 15 | printf '\033]713;%s\007' \ 16 | 'xft:DejaVu Sans Mono:style=Book:pixelsize=10:antialias=1:hinting=1:hintstyle=3' 17 | # 'xft:Ubuntu:style=Bold Italic:pixelsize=10:antialias=1:hinting=1:hintstyle=4' 18 | -------------------------------------------------------------------------------- /font-yoshi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | printf '\033]710;%s\007' \ 5 | "xft:Yoshi's Story game text BRK:style=Regular:pixelsize=20:antialias=1:hinting=1:hintstyle=3" 6 | printf '\033]711;%s\007' \ 7 | "xft:Yoshi's Story game text BRK:style=Bold:pixelsize=20:antialias=1:hinting=1:hintstyle=3" 8 | printf '\033]712;%s\007' \ 9 | "xft:Yoshi's Story game text BRK:style=Italic:pixelsize=20:antialias=1:hinting=1:hintstyle=3" 10 | printf '\033]713;%s\007' \ 11 | "xft:Yoshi's Story game text BRK:style=Black:pixelsize=20:antialias=1:hinting=1:hintstyle=3" 12 | -------------------------------------------------------------------------------- /font_preview: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: preview all fonts in your terminal 3 | 4 | setty alternate 5 | setty ttyscroll 6 | setty wrap 7 | setty reverse 8 | 9 | for x in $(xlsfonts | grep -P 'mono|tiny|cod[ie]|altsys|erus|proggy|fixed'); do 10 | printf " %s\n" $x 11 | pickyfont "$x" 12 | done 13 | 14 | setty reverse 15 | setty wrap 16 | setty ttyscroll 17 | setty alternate 18 | -------------------------------------------------------------------------------- /ft: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: show filetype info 3 | ack -f --show-types | 4 | perl -MFile::LsColor=ls_color -ln -e 'm/(.+) => (.+)/ and printf("%15.15s => %s\n", $2, ls_color($1))' 5 | -------------------------------------------------------------------------------- /fuckingscreenbugshit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | urxvtc -e screen -x; screen -X screen zsh 3 | -------------------------------------------------------------------------------- /fx_ramdisk_sync: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh: 3 | # 4 | # 0 */2 * * * ~/dev/utils/fx_ramdisk_sync 5 | # echo ~/dev/utils/fx_ramdisk_sync | tee ~/.zlog{in,out} 6 | 7 | static=main 8 | link=4yri02ns.default 9 | volatile=~/shm/firefox 10 | 11 | IFS= 12 | set -efu 13 | 14 | cd ~/.mozilla/firefox 15 | 16 | if [ ! -r $volatile ]; then 17 | mkdir -m0700 $volatile 18 | fi 19 | 20 | if [ "$(readlink $link)" != "$volatile" ]; then 21 | mv $link $static 22 | ln -s $volatile $link 23 | fi 24 | 25 | if [ -e $link/.unpacked ]; then 26 | rsync -av --delete --exclude .unpacked ./$link/ ./$static/ 27 | else 28 | rsync -av ./$static/ ./$link/ 29 | touch $link/.unpacked 30 | fi 31 | -------------------------------------------------------------------------------- /fxshot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | FNAME=$(fxr shot|awk '{print $3}') 3 | scp -P 19216 "$FNAME" scp1@laleh:http/japh.se/scrots/fxr 4 | echo "http://i.japh.se/fxr/$FNAME" 5 | echo "http://i.japh.se/fxr/$FNAME"|xclip 6 | -------------------------------------------------------------------------------- /fzf-perlsub-githistory: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # abstract: display a perl subs git history over time 3 | 4 | # FZF Wrapper over git to interactively search code changes inside functions 5 | 6 | readarray -t choices < <(git ls-files | fzf \ 7 | --prompt="Choose File: " \ 8 | --height 40% --reverse \ 9 | ) 10 | 11 | printf "%s\n" "$(grep -o -P '(?<=sub )(.+)' $choices)" | fzf \ 12 | --ansi --preview "echo {} | xargs -I{} git log --color -L :{}:$choices" \ 13 | --prompt="Choose function/method: " \ 14 | --bind 'j:down,k:up,ctrl-j:preview-down,ctrl-k:preview-up,ctrl-space:toggle-preview' --preview-window right:60% \ 15 | -------------------------------------------------------------------------------- /gb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git blame --color-by-age "$@" 4 | -------------------------------------------------------------------------------- /generate-tags.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: generate tags for vim 3 | # set tags=./tags,tags,~/dev/tags,~/dev/askas/utils-askas/vim/tags 4 | 5 | # " go to tag definition and go back 6 | # nnoremap 7 | # nnoremap 8 | 9 | ctags -f ~/dev/tags --recurse --totals \ 10 | --exclude=blib --exclude=.svn --exclude=CLEAN \ 11 | --exclude=.git --exclude='*~' \ 12 | --extras=q \ 13 | --languages=Perl \ 14 | --langmap=Perl:+.t \ 15 | ~/dev/ 16 | -------------------------------------------------------------------------------- /generate_swedish_names: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | 5 | use Mock::Person; 6 | 7 | my $sex = shift // 'female'; 8 | 9 | for(0 .. 9) { 10 | print Mock::Person::name( 11 | sex => $sex, 12 | country => 'sv', 13 | ), "\n"; 14 | } 15 | -------------------------------------------------------------------------------- /generate_zsh_completion: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: generate zsh completion 3 | use strict; 4 | 5 | my @apps = @ARGV or die "Files?\n"; 6 | 7 | for my $app(@apps) { 8 | open(my $fh, '>', "_$app") or die "$!\n"; 9 | print $fh "#compdef $app\ncompdef _gnu_generic $app\n"; 10 | } 11 | -------------------------------------------------------------------------------- /get_ls_colors: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: print all defined LS_COLORS 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | 6 | use File::LsColor qw(get_ls_colors ls_color); 7 | 8 | for my $e(sort(keys(%{ get_ls_colors() }))) { 9 | printf("%s\n", ls_color("file.$e", )); 10 | } 11 | 12 | __END__ 13 | -------------------------------------------------------------------------------- /get_tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sync_cpantesters -a WOLDRICH -d /home/scp1/dev/_cpants 3 | -------------------------------------------------------------------------------- /getphotos: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | target="/tmp/scp1/n900-$(date +%Y-%m-%d)" 3 | mkdir -p $target 4 | scp n900:MyDocs/DCIM/* $target 5 | -------------------------------------------------------------------------------- /getstash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use Data::Dumper; 5 | 6 | { 7 | package Data::Dumper; 8 | no strict 'vars'; 9 | 10 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; 11 | $Quotekeys = 0; 12 | } 13 | 14 | print Dumper get_stash( shift // 'IO::File' ); 15 | 16 | sub get_stash { 17 | eval "require $_[0]" or return $@; 18 | 19 | { 20 | no strict 'refs'; 21 | \%{"$_[0]::"}; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gh_clone_all_gists: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # abstract: clone all gists of username given on the command line 3 | # -*- coding: utf-8 -*- 4 | 5 | import subprocess 6 | import sys 7 | import requests 8 | 9 | if len(sys.argv) > 1: 10 | gh_user = sys.argv[1] 11 | else: 12 | print("Usage: clone-gists.py ") 13 | sys.exit(1) 14 | 15 | req = requests.get('https://api.github.com/users/%s/gists' % gh_user) 16 | 17 | for gist in req.json(): 18 | ret = subprocess.call(['git', 'clone', gist['git_pull_url']]) 19 | if ret != 0: 20 | print("ERROR cloning gist %s. Please check output." % gist['id']) 21 | -------------------------------------------------------------------------------- /gh_clone_all_user_repos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: clone all repos from $GITHUB_USER 3 | 4 | CNTX='users'; NAME=$GITHUB_USER 5 | 6 | # 189 repos as of 2018-12-18 15:34:34 7 | 8 | for PAGE in {1..3}; do 9 | curl -s "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=100" | 10 | grep -e 'git_url*' | 11 | cut -d \" -f 4 | 12 | xargs -L1 git clone 13 | done 14 | -------------------------------------------------------------------------------- /git-changed-files: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # git diff --name-only master...HEAD 3 | git diff --name-only master...|ls_color 4 | -------------------------------------------------------------------------------- /git-cpan-release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # print the most recent CPAN release tag (looks like "v0.03"). 3 | git tag | perl -ne'$s{$_}++ if /^v\d+\.\d+/; END { print ((sort keys %s)[-1]) }' 4 | -------------------------------------------------------------------------------- /git-effort: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | files=$(git ls-files) 4 | 5 | printf "\e[4mcommits\e[m \e[4mfile\e[m\n" 6 | 7 | for file in $files; do 8 | commits=`git log --oneline $file | wc -l` 9 | color='38;5;2;9;9' 10 | 11 | test $commits -gt 10 && color='38;5;33;9;9' 12 | test $commits -gt 25 && color='38;5;93;1;9' 13 | test $commits -gt 50 && color='38;5;85;3;1' 14 | test $commits -gt 100 && color='38;5;92;9;9' 15 | 16 | commits="$(printf '%04d' $commits)" 17 | commits="$(printf \\e\[${color}m%s\\e[m $commits)" 18 | 19 | printf " %s ┃ %.72s\n" $commits "$(echo $file|ls_color_internal)" \ 20 | | perl -pe 's/^/ /' 21 | 22 | done | sort -rnk1 | perl -pe 's/0[^1-9]//g' 23 | -------------------------------------------------------------------------------- /git-top: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: git highscore 3 | git shortlog -sn|perl -pe 's/^/sprintf("#% 2d", $.)/e' 4 | -------------------------------------------------------------------------------- /gitcheck: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dir=$HOME/devel 4 | 5 | gitbunch check $dir 2>&1| 6 | uncolor | 7 | grep -v 'is not a git repo' | 8 | grep -v 'figure out result' | 9 | perl -pe 's/(untracked)/\e[38;5;59m$1\e[m/' | 10 | perl -pe 's/(commit)/\e[38;5;130m$1\e[m/' 11 | 12 | -------------------------------------------------------------------------------- /github-referrers: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## vim:ft=sh: 3 | ## abstract: get referrer urls for all github repos 4 | ## this is messy but it works 5 | 6 | CNTX='users'; 7 | ## a maximum of 100 repos per page 8 | START_URL="https://api.github.com/repos" 9 | END_URL="traffic/popular/referrers" 10 | 11 | END_PAGE=3 12 | 13 | for REPO in $( 14 | for PAGE in {1..$END_PAGE}; do 15 | curl -s "https://api.github.com/$CNTX/${GITHUB_USER}/repos?page=$PAGE&per_page=100" | 16 | grep '"name":' | perl -pe 's/.+"(.+)",/$1/' 17 | done 18 | ); do printf "> \e[1;4m$REPO\e[m\n" 19 | curl -s -u $GITHUB_USER:$GITHUB_TOKEN "$START_URL/$GITHUB_USER/$REPO/$END_URL" | 20 | grep referrer | grep -vP '(?:documentation_url|github.com)' | perl -pe 's/".+": "(.+)",/$1/'; done 21 | 22 | -------------------------------------------------------------------------------- /gitsnap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git cat-file -p $(cat ".git/$(cat .git/HEAD|perl -pe 's{[\S\s]{5}}{}')") 3 | -------------------------------------------------------------------------------- /gl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #PAGER="" 3 | #git log --date=short --shortstat --summary --color=auto --abbrev=5 \ 4 | # --ignore-space-at-eol \ 5 | # --pretty=format:"%Cgreen--%Creset%n %C(137)%s%Creset%n %C(108)%ar%Creset by %C(243)%an%Creset%n " \ 6 | # --abbrev-commit --date=short --date-order | 7 | # perl -pe 's{(\d+) insertions}{\e[38;5;106;1m$1\e[m insertions};s{, (\d+) deletions}{\e[38;5;124;1m $1\e[m deletions}' 8 | git last 9 | -------------------------------------------------------------------------------- /gl1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git log -1 -- "$@" > /tmp/git_log && v /tmp/git_log 4 | -------------------------------------------------------------------------------- /gll: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #PAGER="" 3 | #git log --date=short --shortstat --summary --color=auto --abbrev=5 \ 4 | # --ignore-space-at-eol \ 5 | # --pretty=format:"%Cgreen--%Creset%n %C(137)%s%Creset%n %C(108)%ar%Creset by %C(243)%an%Creset%n " \ 6 | # --abbrev-commit --date=short --date-order | 7 | # perl -pe 's{(\d+) insertions}{\e[38;5;106;1m$1\e[m insertions};s{, (\d+) deletions}{\e[38;5;124;1m $1\e[m deletions}' 8 | git lastt 9 | -------------------------------------------------------------------------------- /glll: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #PAGER="" 3 | #git log --date=short --shortstat --summary --color=auto --abbrev=5 \ 4 | # --ignore-space-at-eol \ 5 | # --pretty=format:"%Cgreen--%Creset%n %C(137)%s%Creset%n %C(108)%ar%Creset by %C(243)%an%Creset%n " \ 6 | # --abbrev-commit --date=short --date-order | 7 | # perl -pe 's{(\d+) insertions}{\e[38;5;106;1m$1\e[m insertions};s{, (\d+) deletions}{\e[38;5;124;1m $1\e[m deletions}' 8 | git lasttt 9 | -------------------------------------------------------------------------------- /gnext: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | stumpish gnext 3 | -------------------------------------------------------------------------------- /goimg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo -n "search> "; 3 | read "QUERY" && 4 | wget -O - `wget -O - -U "Mozilla/5.0" "http://images.google.com/images?q=${QUERY}" 2>/dev/null | 5 | sed -e 's/","http/\n","http/g' | 6 | awk -F \" '{print $3}' | 7 | grep -i http: | 8 | head -1` > "$QUERY.png" && feh -FZ "$QUERY.png" && 9 | rm -v "$QUERY.png" 10 | 11 | -------------------------------------------------------------------------------- /google_dmenu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # google_dmenu.pl 3 | # thanks to Gazj for the original bash version 4 | use strict; 5 | 6 | my $dmenu = 'dmenu -i -b -nb #1c1c1c -nf #d7005f -sb #252525'; 7 | my $d_cmd = `$dmenu -p search`; 8 | 9 | system("firefox -new-window http://google.com/search?q=$d_cmd") 10 | unless !$d_cmd; 11 | -------------------------------------------------------------------------------- /gotoalbum: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 3 | # abstract: goto to root directory of currently playing album 4 | use strict; 5 | use warnings FATAL => 'all'; 6 | use vars qw($VERSION); 7 | use autodie qw(:all); 8 | 9 | use utf8; 10 | use open qw(:std :utf8); 11 | 12 | my $APP = 'gotoalbum'; 13 | $VERSION = '0.001'; 14 | 15 | 16 | use Audio::MPD; 17 | use File::Basename; 18 | 19 | 20 | my $base_dir = "$ENV{XDG_MUSIC_DIR}"; 21 | my $mpd = Audio::MPD->new; 22 | 23 | my $current = $mpd->current; 24 | 25 | my $album_dir = sprintf("%s/%s", $base_dir, dirname($current->file)); 26 | 27 | if(-d $album_dir) { 28 | chdir($album_dir); 29 | system($ENV{SHELL}); 30 | } 31 | else { 32 | die("$album_dir doesn't exist: $!\n"); 33 | } 34 | -------------------------------------------------------------------------------- /gprev: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | stumpish gprev 3 | -------------------------------------------------------------------------------- /grmpd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # copy the playing track from remote mpd session to local machine 3 | # This was sexier in Perl, but Net::SCP is retarded and wraps scp anyway 4 | 5 | if [ $@ ]; then 6 | dir=$@; 7 | else 8 | dir='.'; 9 | fi 10 | 11 | scp -P 19216 "192.168.1.101:'/mnt/Music_1/$(mpc -h 192.168.1.101 --format %file%|head -1)'" $dir 12 | -------------------------------------------------------------------------------- /hardcopy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | lp -d Canon_MP150 -o outputorder=reverse "$@" 4 | -------------------------------------------------------------------------------- /hextermcolors: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: display hex values of defined terminal colors in color 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | 6 | use Term::ExtendedColor qw(fg); 7 | use Term::ExtendedColor::Xresources qw(get_xterm_colors); 8 | 9 | my $single_index = shift; 10 | 11 | my $colors = get_xterm_colors( 12 | { 13 | index => [$single_index ? $single_index : 0..255], 14 | type => 'hex', 15 | }, 16 | ); 17 | 18 | for my $index(sort { $colors->{$a} <=> $colors->{$b} } keys %{ $colors }) { 19 | printf "% 3d: %s\n", $index, fg($index, $colors->{$index}->{rgb}) 20 | } 21 | -------------------------------------------------------------------------------- /hotswap/config.conf: -------------------------------------------------------------------------------- 1 | $c[1] = 'yellow18'; 2 | $c[2] = 'yellow12'; 3 | $c[3] = 'yellow14'; 4 | $c[4] = 'blue5'; 5 | $c[5] = 'red1'; 6 | $c[6] = 'yellow17'; 7 | $c[7] = 'magenta25'; 8 | $c[8] = 'orange1'; 9 | $c[9] = 'clear'; 10 | $c[10] = 'green27'; 11 | $c[11] = 'green26'; 12 | $c[12] = 'cyan19'; 13 | $c[13] = 'blue10'; 14 | $c[14] = 'grey18'; 15 | $c[15] = 'green16'; 16 | -------------------------------------------------------------------------------- /hotswap/hotswap.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # hotswap 3 | use strict; 4 | use Term::ExtendedColor qw(fg); 5 | use Data::Dumper; 6 | 7 | my $config = './config.conf'; 8 | our @c; 9 | 10 | print "> "; 11 | while(chomp(my $line = )) { 12 | if($line =~ /^r/) { 13 | delete($INC{'config.conf'}); 14 | reload(); 15 | print Dumper \%INC; 16 | } 17 | print "> "; 18 | } 19 | 20 | 21 | sub reload { 22 | require './config.conf'; 23 | for my $fg(@c) { 24 | print fg($fg, $fg), "\n"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /httrack_with_linked_images: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: rip entire blog + linked external images 3 | httrack -O "./$1" -v -s0 --depth=2 -n "$1" 4 | -------------------------------------------------------------------------------- /hue-toggle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | use vars qw($VERSION); 6 | use autodie qw(:all); 7 | 8 | use utf8; 9 | use open qw(:std :utf8); 10 | 11 | use Power::Outlet::Hue; 12 | 13 | my $hue = Power::Outlet::Hue->new( 14 | host => "192.168.32.2", 15 | id=>1, 16 | username => 'W8pQVe4hNRt3jxvWz7oDcSVe0ypOGG-vfONEAlmo', 17 | ); 18 | 19 | 20 | my $command = $hue->query eq 'OFF' ? 'on' : 'off'; 21 | 22 | $hue->$command; 23 | -------------------------------------------------------------------------------- /inanonenin: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | for in an on en in echo in do done; do $in $on $an $en; done 3 | -------------------------------------------------------------------------------- /inc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | use File::Find::Rule; 5 | 6 | my @pm = File::Find::Rule->file() 7 | ->name('*.pm') 8 | ->in(@INC); 9 | 10 | for(@INC) { 11 | next if /^..?$/; 12 | system("du -hs $_"); 13 | } 14 | 15 | printf("\n%d modules installed\n", scalar(@pm)); 16 | -------------------------------------------------------------------------------- /inc_search: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use feature 'say'; 4 | use File::Find::Rule; 5 | 6 | my $pattern = shift // '.+'; 7 | 8 | my @pm = sort( 9 | File::Find::Rule->file() 10 | ->name('*.pm') 11 | ->in(@INC) 12 | ); 13 | 14 | for(@pm) { 15 | say $_ if $_ =~ m/$pattern/i; 16 | }; 17 | -------------------------------------------------------------------------------- /initial_letter: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: print initial letter of given word(s) 3 | use strict; 4 | 5 | my $line = shift; 6 | chomp($line = <>) unless defined $line; 7 | 8 | my @words = ($line =~ m/(\S+)/g); 9 | printf "%s\n", $_ for map { uc(substr($_, 0, 1)) } @words; 10 | -------------------------------------------------------------------------------- /inverse: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: inverse input 3 | 4 | use strict; 5 | use Term::ExtendedColor qw(:attributes); 6 | 7 | if(!(@ARGV)) { 8 | while(<>) { 9 | chomp; 10 | printf "%s\n", inverse($_); 11 | } 12 | } 13 | else { 14 | printf "%s\n", inverse("@ARGV"); 15 | } 16 | -------------------------------------------------------------------------------- /invert_screen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: invert the entire screen 3 | 4 | xcalib -verbose -alter -invert 5 | -------------------------------------------------------------------------------- /issues: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | # abstract: list all issues relevant for me cause the github ui is worthless 4 | 5 | PAGER="" ghi list -g -s open --sort created \ 6 | | /bin/grep -vP 'dots|Advent|sharpsaw|^# ' \ 7 | | perl -pe 's{(LS_COLORS)}{\e[38;5;220m$1\e[m}g' 8 | -------------------------------------------------------------------------------- /italic: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: italic input 3 | 4 | use strict; 5 | use Term::ExtendedColor qw(:attributes); 6 | 7 | if(!(@ARGV)) { 8 | while(<>) { 9 | chomp; 10 | printf "%s\n", italic($_); 11 | } 12 | } 13 | else { 14 | printf "%s\n", italic("@ARGV"); 15 | } 16 | -------------------------------------------------------------------------------- /japh.pl: -------------------------------------------------------------------------------- 1 | print($_->($_))for(sub{return(grep(!m$(?:[b-gik-oq-ty]+)$,split(m;;,qw-jyatopnh-)));}); 2 | -------------------------------------------------------------------------------- /json_check: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # PODNAME: check_json.pl 3 | use 5.010; 4 | 5 | use JSON::XS; 6 | use Data::Dumper; 7 | 8 | { 9 | package Data::Dumper; 10 | no strict 'vars'; 11 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; 12 | $Quotekeys = 0; 13 | } 14 | 15 | my $json = JSON::XS->new->utf8; 16 | 17 | foreach my $file ( @ARGV ) { 18 | say "Processing $file"; 19 | eval { 20 | my $hash = $json->decode( 21 | do { local ( @ARGV, $/ ) = $file; <> } 22 | ); 23 | print Dumper( $hash ); 24 | }; 25 | 26 | if ( $@ ) { say "\terror in $file: $@" } 27 | } 28 | -------------------------------------------------------------------------------- /json_deparse: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | use open qw(:utf8); 5 | use utf8; 6 | 7 | use Data::Dumper; 8 | use JSON::XS; 9 | 10 | { 11 | package Data::Dumper; 12 | no strict "vars"; 13 | 14 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; 15 | $Quotekeys = 0; 16 | } 17 | 18 | $/ = ""; 19 | my $j = <>; 20 | print Dumper decode_json( $j ); 21 | -------------------------------------------------------------------------------- /kbdrate-fix-repeat-keys: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # fix repeating keys on vortex pok3r rgb 3 | 4 | kbdrate -r 25 -d 500 5 | -------------------------------------------------------------------------------- /kitty_feh_handler: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # show image "fullscreened" inside a fixed geometry window 3 | 4 | # protocol file 5 | # ext jpg,jpeg,png,gif 6 | # action launch --title ${FILE} --type=os-window kitty_feh_handler ${FILE_PATH} 7 | 8 | xy=$(xdotool getwindowgeometry $(xdotool getwindowfocus) | grep 'Geometry:' | awk '{print $2}') 9 | 10 | /usr/bin/feh --scale-down --image-bg black -g $xy $1 11 | 12 | -------------------------------------------------------------------------------- /knnp-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: now playing for knradio 3 | 4 | curl -s "http://www.knradio.se/latlist/exfile.php" \ 5 | | grep -i spelas \ 6 | | perl -pe 's/^.+:(.+)$/$1/' 7 | -------------------------------------------------------------------------------- /knradioold: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | trap 'exit' SIGHUP SIGINT SIGTERM 4 | cvlc http://juice.citrus3.com:2199/tunein/knradio.pls & 5 | echo "np: knradio 92.2" 6 | read a 7 | -------------------------------------------------------------------------------- /lapd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mplayer http://www.radioreference.com/scripts/playlists/1/899/0-5218582748.m3u 4 | -------------------------------------------------------------------------------- /lastfmnp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use XML::Simple; 4 | use LWP::Simple; 5 | use utf8; 6 | use open qw(:std :utf8); 7 | 8 | 9 | my $user = shift // 'betbot'; 10 | my $url = "http://ws.audioscrobbler.com/1.0/user/$user/recenttracks.rss"; 11 | 12 | lfm(); 13 | 14 | sub lfm { 15 | my $xml = XML::Simple->new; 16 | my $content = get($url); 17 | 18 | my $rss = $xml->XMLin($content); 19 | 20 | my $html_title = $rss->{channel}->{item}[0]->{title}; 21 | 22 | my($artist, $song) = ('unknown') x 2; 23 | ($artist, $song) = split(/\x{2013}/, $html_title); 24 | 25 | printf("lastfm: $artist %s\n", ( $song) ? "- $song" : "no record for $user"); 26 | } 27 | -------------------------------------------------------------------------------- /lc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -p 2 | # vim: ft=perl smc&: 3 | $_ = lc $_; 4 | 5 | print lc while <>; 6 | -------------------------------------------------------------------------------- /len: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | while(<>) { 5 | chomp; 6 | printf("% 4d %s\n", length($_), $_); 7 | } 8 | -------------------------------------------------------------------------------- /lessfilter: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this is a example of .lessfilter, you can change it 3 | mime=$(file -bL --mime-type "$1") 4 | category=${mime%%/*} 5 | kind=${mime##*/} 6 | if [ -d "$1" ]; then 7 | exa --git -hl --color=always "$1" 8 | elif [ "$category" = image ]; then 9 | chafa "$1" 10 | hr 11 | exiftool "$1" 12 | elif [ "$kind" = vnd.openxmlformats-officedocument.spreadsheetml.sheet ] || \ 13 | [ "$kind" = vnd.ms-excel ]; then 14 | in2csv "$1" | xsv table | bat -ltsv --color=always 15 | elif [ "$category" = text ]; then 16 | cat "$1" 17 | # bat --color=always "$1" 18 | else 19 | lesspipe.sh "$1" | bat --color=always 20 | fi 21 | # lesspipe.sh don't use exa, bat and chafa, it use ls and exiftool. so we create a lessfilter. 22 | -------------------------------------------------------------------------------- /lib/Deparse/Makefile.PL: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use ExtUtils::MakeMaker; 3 | 4 | WriteMakefile( 5 | NAME => 'Deparse::Syntax', 6 | AUTHOR => 'Magnus Woldrich "GPLv2", 8 | MIN_PERL_VERSION => 0, 9 | ); 10 | 11 | 12 | -------------------------------------------------------------------------------- /lib/Deparse/Syntax.pm: -------------------------------------------------------------------------------- 1 | package Deparse::Syntax; 2 | require Exporter; 3 | @ISA = qw(Exporter); 4 | @EXPORT_OK = qw(deparse); 5 | 6 | use strict; 7 | use warnings; 8 | use Carp; 9 | use B::Deparse; 10 | use Data::Dumper; 11 | 12 | my $fname = "/tmp/@{[time()]}.pl"; 13 | my $body = undef; 14 | 15 | sub deparse { 16 | my $coderef = shift; 17 | my $dp = B::Deparse->new('q', '-si2'); 18 | $body = $dp->coderef2text($coderef); 19 | 20 | mktemp(); 21 | 22 | exec("v $fname && rm -v $fname") or die($!); 23 | } 24 | 25 | 26 | sub mktemp { 27 | open(my $tmp, '>', "$fname") or croak($!); 28 | print $tmp $body; 29 | close($tmp); 30 | } 31 | 32 | 1; 33 | -------------------------------------------------------------------------------- /lib/Net::Google::TLD/Makefile.PL: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use ExtUtils::MakeMaker; 4 | 5 | WriteMakefile( 6 | NAME => 'Net::Google::TLD',, 7 | AUTHOR => q{Magnus Woldrich }, 8 | VERSION_FROM => 'lib/Net/Google/TLD.pm', 9 | ABSTRACT_FROM => 'lib/Net/Google/TLD.pm', 10 | 11 | ($ExtUtils::MakeMaker::VERSION >= 6.3002 12 | ? ('LICENSE'=> 'perl') 13 | : ()), 14 | 15 | PL_FILES => {}, 16 | 17 | PREREQ_PM => { 18 | }, 19 | 20 | 21 | MAN1PODS => { 22 | }, 23 | 24 | MIN_PERL_VERSION => 0, 25 | 26 | dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, 27 | clean => { FILES => 'Net-Google-TLD-*' }, 28 | ); 29 | -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/arch/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/arch/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/arch/auto/Net/Google/TLD/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/arch/auto/Net/Google/TLD/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/bin/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/bin/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/lib/Net/Google/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/lib/Net/Google/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/lib/auto/Net/Google/TLD/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/lib/auto/Net/Google/TLD/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/man1/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/man1/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/man3/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/man3/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/blib/script/.exists: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/blib/script/.exists -------------------------------------------------------------------------------- /lib/Net::Google::TLD/pm_to_blib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/lib/Net::Google::TLD/pm_to_blib -------------------------------------------------------------------------------- /linenr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: add linenr to input 3 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 4 | use strict; 5 | use warnings FATAL => 'all'; 6 | use vars qw($VERSION); 7 | use autodie qw(:all); 8 | 9 | my $APP = ''; 10 | $VERSION = '0.001'; 11 | 12 | use Data::Dumper; 13 | 14 | { 15 | package Data::Dumper; 16 | no strict 'vars'; 17 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; 18 | $Quotekeys = 0; 19 | } 20 | 21 | while(<>) { 22 | printf "% 3d %s", $., $_; 23 | } 24 | -------------------------------------------------------------------------------- /load: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: a non-interactive top 3 | printf '\e[?7t' 4 | ps aux | sort -k3 | tail -40 | 5 | perl -e ' 6 | @_=<>; 7 | $sum = 0; 8 | for(@_) { 9 | $user = m/^(\w+)/; 10 | $sum = 0; 11 | for my $c(split(//, $user)) { 12 | $sum += ord $c; 13 | } 14 | print if /^USER/; 15 | } 16 | print for reverse grep { ! /^USER/ } @_ 17 | '; 18 | printf '\e[?7t' 19 | -------------------------------------------------------------------------------- /localtime: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | print scalar localtime( <> ), "\n"; 3 | -------------------------------------------------------------------------------- /loved: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | pimpd2 --loved 3 | -------------------------------------------------------------------------------- /ls2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: colored ls, again 3 | \ls -hAlv --group-directories-first --color=always --indicator-style=file-type "$@"|awk '{print "\033[48;5;232m\033[38;5;32m\033[31;1m\033[38;5;236m"$1 "\033[0m\033[48;5;232m\033[38;5;244m▕\033[0m " $9 $10 $11}'|perl -pe 's/->/\033[38;5;148m \033[1m▪▶ \033[0m/'|perl -pe 's/.+total.+//'|perl -pe 's/^\s+//' 4 | 5 | # vim: set textwidth=0 nowrap: 6 | 7 | -------------------------------------------------------------------------------- /lscolorpicker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | $(perl lscolorpicker.pl) 4 | -------------------------------------------------------------------------------- /lsp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ls -hovA --indicator-style=file-type --color=always --group-directories-first --time=ctime --time-style=full-iso "$@"| 3 | tr -s "[:blank:]" " "| 4 | awk {'print "\033[38;5;241m[\033[38;5;240m"$1 "\033[38;5;241m]\033[38;5;241m "$5 "\033[38;5;255m " $8 "\033[0m"'} 5 | 6 | #:vim: set nowrap: 7 | -------------------------------------------------------------------------------- /lyrics: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use feature 'say'; 4 | use Audio::MPD; 5 | 6 | use Term::ExtendedColor qw(fg); 7 | 8 | my $mpd = Audio::MPD->new; 9 | 10 | my $artist = $mpd->current->artist; 11 | my $title = $mpd->current->title; 12 | 13 | my $lyrics_dir = "$ENV{HOME}/dev/lyrics/lyrics"; 14 | 15 | my $lyrics = "$lyrics_dir/$artist - $title.txt"; 16 | 17 | if(-f $lyrics) { 18 | printf "\n \t%s - %s\n", fg('38;5;208', $artist), fg('38;5;208;1', $title); 19 | open(my $fh, '<', $lyrics) or die $!; 20 | while(<$fh>) { 21 | $_ =~ s{\[(.+)\]}{\e[1m[\e[m\e[38;5;37;1m$1\e[m\e[1m]\e[m}; 22 | print "$_"; 23 | } 24 | say; 25 | } 26 | else { 27 | print "No lyrics found for $artist - $title\n"; 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /lyrics_update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | # abstract: update lyrics db on github 4 | cd $HOME/dev/lyrics && 5 | git add . && 6 | git commit -m 'update lyrics' && 7 | git push 8 | 9 | cd $HOME/dev/private && 10 | git add . 11 | git commit -m 'update' 12 | git push 13 | -------------------------------------------------------------------------------- /m: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # abstract: send now playing artist to mtree 3 | 4 | album="$(mpc current --format %album%)" 5 | =mtree -d "$(mpc current --format %artist%)" | perl -pe "s/$album/\033[38;5;208m$album/" 6 | -------------------------------------------------------------------------------- /mag2tor: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## usage: ./download_magnet_url.sh "magnet_link" 3 | ## magnet link shoul be enclosed in quotes. 4 | 5 | cd $HOME/Downloads/_torrent # set your watch directory here 6 | [[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit; 7 | echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent" 8 | -------------------------------------------------------------------------------- /magento_rebuild_broken.sh: -------------------------------------------------------------------------------- 1 | 2 | # rebuild broken magento 3 | 4 | docker compose exec php php -d memory_limit=-1 /srv/magento/bin/magento cache:flush 5 | docker compose exec php php -d memory_limit=-1 /srv/magento/bin/magento setup:di:compile 6 | docker compose exec php php -d memory_limit=-1 /srv/magento/bin/magento setup:upgrade 7 | docker compose exec php php -d memory_limit=-1 /srv/magento/bin/magento cache:flush 8 | docker compose exec php php -d memory_limit=-1 /srv/magento/bin/magento setup:di:compile 9 | 10 | -------------------------------------------------------------------------------- /make_flac: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | in="$1" 4 | out=$( echo "$in" | perl -pe 's{[.](?:mp4|flv)$}{.flac}' ) 5 | 6 | printf "Original file is \e[1m%s\e[m\n" $in 7 | printf "FLAC file is \e[33m%s\e[m\n" $out 8 | 9 | ffmpeg -i "$in" -f flac "$out" && printf "\e[34;1mDone!\e[m\n" 10 | -------------------------------------------------------------------------------- /makejaph: -------------------------------------------------------------------------------- 1 | # vim:ft=zsh: 2 | #!/bin/sh 3 | 4 | ### 5 | # build and deploy japh.se using hugo 6 | ### 7 | cd C:/Users/japh/Documents/Github/dev/japh.se.hugo && 8 | make clean && 9 | hugo --buildDrafts --theme=japh -d ../japh.github.io 10 | -------------------------------------------------------------------------------- /makevimcommentheader: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: create vim comment headers 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | use vars qw($VERSION); 6 | use autodie qw(:all); 7 | 8 | use utf8; 9 | 10 | my $header_title = join(' ', @ARGV); 11 | 12 | my $comment = '"'; 13 | my $header_char = '='; 14 | my $pre_header_len = 10; 15 | 16 | my $available_len = (54 - length($comment . $header_title)) - $pre_header_len; 17 | 18 | my $final_header = sprintf "%s %s %s %s", 19 | $comment, $header_char x $pre_header_len, uc($header_title), $header_char x $available_len; 20 | 21 | printf "%s\n", $final_header; 22 | 23 | system("echo '$final_header'|xclip"); 24 | -------------------------------------------------------------------------------- /map: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | #use strict; 4 | #use warnings FATAL => 'all'; 5 | use Data::Dumper; 6 | use Eval::WithLexicals; 7 | 8 | my $expr = shift or die usage(); 9 | my $eval = Eval::WithLexicals->new; 10 | 11 | print "$_\n" for map { $eval->eval( $expr ); $_ } @ARGV; 12 | 13 | sub usage { 14 | "Usage: $0 [FILE...]\n" 15 | } 16 | -------------------------------------------------------------------------------- /markdown_preview: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #use strict; 3 | use Text::Markdown qw(markdown); 4 | use File::Temp qw(tempfile); 5 | use utf8; 6 | use open qw(:std :utf8); 7 | 8 | 9 | my($fh, $file) = tempfile('markdown_previewXXXX', SUFFIX => '.html'); 10 | print $fh markdown(do { local $/; <> }); 11 | close $fh; 12 | 13 | system( ($ENV{DISPLAY}) ? 'x-www-browser' : $ENV{BROWSER}, $file); 14 | unlink $file; 15 | -------------------------------------------------------------------------------- /md2html: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 3 | # abstract: convert input markdown file to html 4 | use strict; 5 | use warnings FATAL => 'all'; 6 | 7 | use Text::Markdown qw(markdown); 8 | 9 | if(!@ARGV) { 10 | print usage(), "\n"; 11 | exit; 12 | } 13 | 14 | my $file = shift; 15 | 16 | # slurp file content into scalar 17 | local $/; 18 | open(my $fh, '<', $file) or die "Cannot open '$file': $!\n"; 19 | my $markdown = <$fh>; 20 | close $fh; 21 | 22 | my $html = markdown($markdown); 23 | print $html; 24 | 25 | sub usage { 26 | return "Usage: $0 file.md"; 27 | } 28 | -------------------------------------------------------------------------------- /md5rename: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for x; do 3 | mv -nv "$x" \ 4 | "$(md5sum "$x" | awk '{print $1}').$(ffprobe -show_format $x 2> /dev/null | awk -F '=' '/format_name|codec_name/ {print $2}')" 5 | done 6 | #vim: set tw=0: 7 | -------------------------------------------------------------------------------- /meet: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | google-chrome-stable --new-window meet.google.com 3 | -------------------------------------------------------------------------------- /melodikryss: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | trap 'exit' SIGHUP SIGINT SIGTERM 4 | cvlc http://sverigesradio.se/topsy/direkt/204-hi-mp3.m3u & 5 | echo "np: SR P4 Värmland - Melodikrysset med Anders Eldeman (lycka till!)" 6 | read a 7 | -------------------------------------------------------------------------------- /melodikrysset: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh: 3 | while true; do 4 | mplayer \ 5 | -include ${HOME}/etc/mplayer/config \ 6 | -profile sid \ 7 | -softvol \ 8 | -volume 30 \ 9 | http://sverigesradio.se/topsy/direkt/179-hi.mp3 10 | sleep 0.86 11 | done 12 | -------------------------------------------------------------------------------- /merlyn-columns: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # merlyn fetcher 3 | use strict; 4 | use WWW::Mechanize; 5 | 6 | my $base = 'http://cpan.se/authors/id/M/ME/MERLYN'; 7 | my $m = WWW::Mechanize->new; 8 | 9 | $m->get($base) or die; 10 | 11 | 12 | $\ = "\n"; 13 | for(map{ $_->url_abs; } $m->find_all_links) { 14 | if(my($mag, $col) = $_ =~ m;http://.+merlyn/(.+)/(.+(?:\.txt|html))$;) { 15 | my $file = lc($mag) . "-$col"; 16 | 17 | $m->follow_link(url => $_) unless($_ !~ /http/); 18 | print "Saving $file"; 19 | $m->save_content($file); 20 | $m->back; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /mount-camera: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | umount /mnt/camera &> /dev/null 4 | mount $( 5 | file /dev/disk/by-label/CANON_DC \ 6 | | awk '{ sub(/`[.]+\/[.]+\//, "/dev/", $5); print $5 }' \ 7 | | sed "s/'//" \ 8 | ) /mnt/camera && printf "Mounted.\n" 9 | -------------------------------------------------------------------------------- /mount-n900: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | fusermount -u /mnt/n900 &> /dev/null 4 | sshfs n900:MyDocs/.sounds /mnt/n900/ && printf 'Mounted.\n' 5 | -------------------------------------------------------------------------------- /mount-nas: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | # mount pi 5 | 6 | #sshfs root@192.168.1.4:/recalbox ~/pi 7 | 8 | # or, autmount -v as root for pure nfs mount 9 | # mount nas backup 10 | 11 | #sshfs root@192.168.1.6:/var/media/extra2tb ~/nas2tb 12 | 13 | # mount nas media 14 | #sshfs root@192.168.1.6:/nfs/japh/ ~/nas 15 | 16 | mount WDMyCloud:/nfs /home/scp1/nas 17 | -------------------------------------------------------------------------------- /mountlast: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | my $mount_point = shift // '/mnt/tmp'; 5 | 6 | open(my $dmesg, '-|', 'dmesg') or die($!); 7 | for(reverse(<$dmesg>)) { 8 | if(/^sd .+ \[(sd.+)\]/) { 9 | system('mount', "/dev/$1", $mount_point); 10 | last; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /mpd-copy-coverart: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # abstract: update coverart on httpd for playing song in mpd for use in homeassistant 3 | # better use the idle loop but... 4 | oldsong=$(mpc current) 5 | 6 | # Stays on loop while the script is active 7 | while "true"; do 8 | # Check if the current song is equal to the one that was playing before (oldsong) 9 | if [[ "$(mpc current)" != "$oldsong" ]]; then 10 | # If not equal, assign the new song to the variable to be checking again correctly 11 | oldsong=$(mpc current) 12 | 13 | # update coverart 14 | DIRNAME=$(echo /mnt/music8/+TAGGED/$(mpc --format=%file%|head -1) | perl -MFile::Basename -lnE 'say dirname($_)') 15 | scp "${DIRNAME}"/cover.* debbie:/var/www/html/_pix/ 16 | fi 17 | sleep 10 18 | done 19 | -------------------------------------------------------------------------------- /mpd-copy-path-to-clipboard: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | # abstract: copy now playing full path to clipboard 4 | 5 | FULL_PATH=${XDG_MUSIC_DIR}/$(mpc current -f %file%) 6 | 7 | echo $FULL_PATH | xclip 8 | -------------------------------------------------------------------------------- /mpd-goto-album-dir: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: goto now playing album directory 3 | 4 | use strict; 5 | use warnings; 6 | 7 | use open qw(:std :utf8); 8 | use Audio::MPD; 9 | use IPC::Cmd qw(run); 10 | 11 | my $mpd = Audio::MPD->new; 12 | 13 | my $path = "$ENV{XDG_MUSIC_DIR}/" . $mpd->current->file; 14 | 15 | my ($album_path) = $path =~ m{^(.+)/.+[.].+$}; 16 | 17 | run( 18 | command => "urxvt -name sid -chdir '$album_path'", 19 | verbose => 0, 20 | ); 21 | -------------------------------------------------------------------------------- /mpd-goto-artist-dir: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: goto now playing artist directory 3 | 4 | use strict; 5 | use warnings; 6 | 7 | use open qw(:std :utf8); 8 | use Audio::MPD; 9 | use IPC::Cmd qw(run); 10 | 11 | my $mpd = Audio::MPD->new; 12 | 13 | my $path = "$ENV{XDG_MUSIC_DIR}/" . $mpd->current->file; 14 | 15 | my ($artist_path) = $path =~ m{^(.+)/.+/.+/.+[.].+$}; 16 | 17 | run( 18 | command => "urxvt -name sid -chdir '$artist_path'", 19 | verbose => 1, 20 | ); 21 | -------------------------------------------------------------------------------- /mpd-show-coverart: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: display cover art for currently playing album: 3 | 4 | use strict; 5 | use warnings; 6 | 7 | use open qw(:std :utf8); 8 | use Audio::MPD; 9 | use IPC::Cmd qw(run); 10 | 11 | my $mpd = Audio::MPD->new; 12 | 13 | my $path = "$ENV{XDG_MUSIC_DIR}/" . $mpd->current->file; 14 | 15 | my ($album_path) = $path =~ m{^(.+)/.+[.].+$}; 16 | 17 | $album_path = quotemeta $album_path; 18 | 19 | run( 20 | command => "/usr/bin/feh -B black -. -r $album_path", 21 | verbose => 0, 22 | ); 23 | -------------------------------------------------------------------------------- /mpd_add_musicdir: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | my $where = $ENV{MPD_MUSIC_DIR} // '/mnt/Music_1'; 4 | 5 | $where =~ s{/+\z}{}; 6 | 7 | while(my $f = <>) { 8 | chomp $f; 9 | $f =~ s{^}{$where/}; 10 | print "$f\n"; 11 | } 12 | -------------------------------------------------------------------------------- /mpd_del: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: remove songs matching PATTERN from mpd playlist 3 | 4 | pattern="$1" 5 | 6 | mpc --format "%position% %artist% %album% %title%" playlist \ 7 | | grep -iP $pattern \ 8 | | awk '{print $1}' \ 9 | | mpc del 10 | -------------------------------------------------------------------------------- /mpd_edit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Edit playlists known by MPD 3 | use strict; 4 | use App::Pimpd; 5 | use App::Pimpd::Validate; 6 | use Trapd00r::Common; 7 | 8 | if(!@ARGV) { 9 | @ARGV = get_valid_lists(undef); 10 | } 11 | 12 | _edit(_valid_list(@ARGV)); 13 | 14 | sub _valid_list { 15 | my @lists = @_; 16 | 17 | my @valid; 18 | for(@lists) { 19 | if(not(isa_valid_playlist($_))) { 20 | next; 21 | } 22 | push(@valid, abs_playlist_path($_)); 23 | } 24 | return @valid; 25 | } 26 | 27 | sub _edit { 28 | system("$ENV{HOME}/devel/time-spent-in-vim/vim", 29 | @_, 30 | ); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /mpd_ftp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ftphost="user@host.tld" 3 | username="foo" 4 | password="bar" 5 | tempfile=$(mktemp) 6 | 7 | echo -e "debug\n open -u $username,$password $ftphost" > $tempfile 8 | 9 | if [ $# == 0 ]; then 10 | echo -e "Usage: $0 [OPTION]... 11 | -a\t query artist 12 | -al\t query album" 13 | fi 14 | 15 | if [ "$1" == "-a" ]; then 16 | files=("$(mpc search artist "$2"|perl -pe 's/(.*\/.*\/).*/$1/')") 17 | elif [ "$1" == "-al" ]; then 18 | files=("$(mpc search album "$2"|perl -pe 's/(.*\/.*\/).*/$1/')") 19 | fi 20 | for file in "${files[@]}"; do 21 | echo "$file"|perl -pe 's/^/mirror -R \/mnt\/Music_1\//g' >> $tempfile 22 | done 23 | lftp -f $tempfile 24 | -------------------------------------------------------------------------------- /mpd_keep: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: remove songs NOT matching PATTERN from mpd playlist 3 | 4 | pattern="$1" 5 | 6 | mpc --format "%position% %artist% %album% %title%" playlist \ 7 | | ngrep $pattern \ 8 | | awk '{print $1}' \ 9 | | mpc del 10 | -------------------------------------------------------------------------------- /mpd_mv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ $# -eq 0 ]]; then 4 | printf "usage: $0 [OPTIONS]\n" 5 | exit 6 | fi 7 | TARGET='.' 8 | MPD_MUSIC_DIR=/mnt/Music_1 9 | 10 | if [[ "$1" == "-d" ]]; then 11 | cp -Rv /mnt/Music_1/$(mpc --format %file% \ 12 | | head -1 \ 13 | | perl -pe 's/(\/.*\/).*$/$1/g') $TARGET 14 | else 15 | cp -vn "$MPD_MUSIC_DIR/$(mpc --format %file% | head -1)" $TARGET 16 | fi 17 | -------------------------------------------------------------------------------- /mpd_random_hiphop: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | mpc clear > /dev/null 5 | mpc search genre hip-hop \ 6 | | dirnamep \ 7 | | sort -u \ 8 | | sort -R \ 9 | | head -10 \ 10 | | mpc add 11 | mpc play 12 | -------------------------------------------------------------------------------- /mpd_random_playlist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | # abstract: create a new playlist with n random tracks 4 | 5 | NO_TRACKS=100 6 | 7 | if [ $1 ]; then 8 | NO_TRACKS=$1 9 | fi 10 | 11 | pimpd2 --clear 12 | pimpd2 --randomize $NO_TRACKS | pimpd2 -af 13 | -------------------------------------------------------------------------------- /mpd_sock: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | socat - tcp-connect:192.168.1.128:6600 3 | -------------------------------------------------------------------------------- /mpd_stats: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | database="$HOME/.mpd/mpd.db" 3 | 4 | LC_ALL="C" 5 | 6 | number_of() { 7 | local N=$(grep "$1" "$database" | sort | uniq | wc -l) 8 | echo $N 9 | } 10 | 11 | most_from() { 12 | local most=$(grep "$1" "$database" | sort | uniq -c | sort -r | head -1 | cut -d ':' -f 2-) 13 | echo $most 14 | } 15 | 16 | echo 17 | echo "tracks : $(number_of '^Title: ')" 18 | echo "artists : $(number_of '^Artist: ')" 19 | echo "albums : $(number_of '^Album: ')" 20 | echo 21 | echo "most from artist : $(most_from '^Artist: ')" 22 | echo "most from year : $(most_from '^Date: ')" 23 | echo "most from genre : $(most_from '^Genre: ')" 24 | echo 25 | 26 | -------------------------------------------------------------------------------- /mpd_stumpwm_status: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | stumpish echo $( 4 | mpc --host $MPD_HOST \ 5 | --format "%file%" | 6 | head -1 7 | ) 8 | -------------------------------------------------------------------------------- /mpd_symlink_all_by_artist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | # find all albums by artist in mpd database, symlink the dirs in ., for 5 | # ease of copying/moving/etc 6 | 7 | IFS=$'\n' 8 | for x in $(mpc search artist "$1" | dirnamep | sort -u); do ln -s "/mnt/${x}"; done 9 | -------------------------------------------------------------------------------- /mpd_trans: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Audio::MPD; 4 | 5 | my $mpd = Audio::MPD->new; 6 | 7 | my $basedir = '/mnt/Music_1'; 8 | my $current = $mpd->current->file; 9 | my $file = "$basedir/$current"; 10 | 11 | my ($basename) = $current =~ m;.+/(.+)$;; 12 | 13 | 14 | system("scp -P 19216 '$file' scp1\@192.168.1.128:http/japh.se/pub/"); 15 | system("echo http://l.japh.se/$basename"); 16 | system("echo http://l.japh.se/$basename|xclip"); 17 | -------------------------------------------------------------------------------- /mpd_twmn: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: mpd notifications in a tiling wm 3 | 4 | if [ $@ ]; then 5 | mpc next 6 | fi 7 | twmnc -fn Sans -p 9797 -c "$(mpc current)" --pos top_right 8 | -------------------------------------------------------------------------------- /mpd_update_status: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: mpd update with status 3 | 4 | use Audio::MPD; 5 | 6 | $SIG{INT} = sub { printf("\e[?25h"); exit }; 7 | 8 | my $mpd = Audio::MPD->new( 9 | host => $ENV{MPD_HOST}, 10 | port => $ENV{MPD_PORT}, 11 | ); 12 | 13 | 14 | printf("\e[?25l"); 15 | 16 | my $stats = $mpd->stats; 17 | 18 | $|++; 19 | while($mpd->status->updating_db == 1) { 20 | printf("Updating db...\r"); 21 | sleep 5; 22 | } 23 | print "\nUpdate finished!\n"; 24 | printf("%10s: %s\n", $_, $stats->{$_}) for qw(artists albums songs db_update); 25 | 26 | 27 | END { 28 | printf("\e[?25h"); 29 | exit 30 | }; 31 | -------------------------------------------------------------------------------- /mpdcp.rc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/rc 2 | # mpdcp.rc 3 | 4 | dest = /tmp/scp1 5 | file = /mnt/Music_1/`{mpc --format %file%|head -1} 6 | 7 | if(~ $1 '-d') { 8 | album = `{echo $file|perl -pe 's;(.+)/.+;$1;'} 9 | echo $album 10 | for(file in `{find $album}) { 11 | cp -v $file $dest 12 | } 13 | exit 0 14 | } 15 | 16 | cp -v $file $dest 17 | -------------------------------------------------------------------------------- /mplayer_podcast: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mplayer -af scaletempo -speed 1.8 "$@" 4 | -------------------------------------------------------------------------------- /mpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | chmod +x "$@" && mplayer "$@" 3 | -------------------------------------------------------------------------------- /mpnp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: mplayer now-playing using Mplayer::NowPlaying 3 | 4 | use strict; 5 | use Mplayer::NowPlaying; 6 | 7 | my $log = "$ENV{HOME}/.mplayerlog"; 8 | my $c = now_playing($log, 'identify'); 9 | 10 | if( (!-t STDOUT) or (@ARGV) ) { 11 | printf("mplayer: %s { [ %s - %s (%s) [%s] ] }\n", 12 | $c->{file}, $c->{artist}, $c->{title}, $c->{album}, $c->{year}, 13 | ); 14 | exit 0; 15 | } 16 | 17 | for my $wanted(qw(artist album title file year)) { 18 | printf("%7s: %s\n", ucfirst($wanted), $c->{$wanted}) 19 | unless(!exists($c->{$wanted})); 20 | } 21 | -------------------------------------------------------------------------------- /msg_me: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Linux::Inotify2; 4 | 5 | my $log = '/mnt/irclogs/192/bitlbee_current.log'; 6 | 7 | my $in = Linux::Inotify2->new; 8 | $in->watch($log, IN_MODIFY); 9 | 10 | while(1) { 11 | my @e = $in->read; 12 | my $c = reopen($log); 13 | print $_->fullname, "\n" for @e; 14 | osd( $c->[-1] ) and next; 15 | }; 16 | 17 | sub reopen { 18 | my $f = shift; 19 | open(my $fh, '<', $f) or die($!); 20 | my @c = <$fh>; 21 | close($fh); 22 | return \@c; 23 | } 24 | 25 | 26 | sub osd { 27 | my ($msg) = @_; 28 | my $color = '\#a8ff00'; 29 | # yeah, yeah. I'll fix 30 | system("echo '$msg' | osd_cat -A right -p bottom -c $color -s 5 -d 0 "); 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /music: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | 4 | media_sort -t music $1 5 | -------------------------------------------------------------------------------- /mvdir: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use File::Copy; 5 | 6 | my($what, $where) = @ARGV; 7 | 8 | die "not a dir: $what\n" if !-d $what; 9 | move($what, $where); 10 | -------------------------------------------------------------------------------- /mvid_mkdir: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: 3 | # 4 | # 5 | ### strip extension 6 | # $ for x in *(.); do mkdir "$x"(:r); done 7 | ### 8 | ### 9 | use strict; 10 | use warnings FATAL => 'all'; 11 | use vars qw($VERSION); 12 | use autodie qw(:all); 13 | 14 | use utf8; 15 | use open qw(:std :utf8); 16 | 17 | my $APP = ''; 18 | $VERSION = '0.001'; 19 | 20 | use File::Glob; 21 | 22 | my @videos = grep { -f $_ } glob('*'); 23 | 24 | 25 | for my $new_dir(@videos) { 26 | $new_dir =~ s/^(.+)\s+-\s+.+$/$1/; 27 | 28 | -d $new_dir 29 | ? next 30 | : mkdir($new_dir); 31 | } 32 | -------------------------------------------------------------------------------- /mvmusic: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for x in A B C D E F G H I J K L M N O P Q R S T U W X Y Z; do 3 | mv -v $x* ../$x; done 4 | -------------------------------------------------------------------------------- /n900_mount: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sshfs user@192.168.0.198: $HOME/n900 4 | sshfs user@192.168.0.198:/media/mmc1 $HOME/n900sd 5 | -------------------------------------------------------------------------------- /n950_bruteforce_flash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh: 3 | 4 | # http://harmattan-dev.nokia.com/release/N950-39-5/Linux_OCF_39-5_RM680-RM680-OEM1.bin 5 | # http://harmattan-dev.nokia.com/release/N950/firmware/Linux_OCF_02-6_RM680-RM680-OEM1.bin 6 | 7 | wget http://harmattan-dev.nokia.com/release/N950/firmware/Linux_OCF_02-6_RM680-RM680-OEM1.bin -O knark 8 | if [[ $? == 0 ]] 9 | then 10 | chmod +x knark 11 | su -c 'while true 12 | do 13 | modprobe -r cdc_phonet phonet 14 | ./knark 15 | sleep .1 16 | done' 17 | fi 18 | -------------------------------------------------------------------------------- /n950_screencast: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh cc= smc=80: 3 | gst-launch-0.10 ximagesrc ! videorate ! ffmpegcolorspace ! jpegenc ! multipartmux ! fdsink fd=1 \ 4 | | ssh -p 19210 scp1@192.168.1.3 'cat > /tmp/screenlapse.mjpeg' 5 | #mencoder /tmp/screenlapse.mjpeg -fps 25 -ofps 3 -o screenlapse.avi -vf scale=1280:720 -ovc lavc -lavcopts vcodec=mjpeg -oac copy 6 | -------------------------------------------------------------------------------- /net_on_på_sid: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: enable ethernet on 82579V chipsets 3 | echo on > /sys/bus/pci/devices/0000\:00\:19.0/power/control 4 | dhcpcd -D eno1 5 | 6 | bitlbee -D 7 | sh /home/scp1/dev/utils/bob 8 | -------------------------------------------------------------------------------- /newrel: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Flexget::Parse; 4 | use Flexget::PatternMatch; 5 | 6 | my $log = "$ENV{HOME}/.local/share/flexget/flexget.log"; 7 | 8 | open(my $fh, '<', $log) or die($!); 9 | chomp(my @new = flexparse(<$fh>)); 10 | 11 | print $new[-1], "\n"; 12 | -------------------------------------------------------------------------------- /ngrep: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # negative grep 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | 6 | use utf8; 7 | use open qw(:utf8 :std); 8 | 9 | my ($pattern, $file) = @ARGV; 10 | 11 | if(!defined($pattern)) { 12 | warn "Usage: ngrep PATTERN [FILE]...\n"; 13 | exit; 14 | } 15 | 16 | my $fh; 17 | if(!defined($file) or ($file eq '-')) { 18 | $fh = *STDIN; 19 | } 20 | else { 21 | open($fh, '<', $file) or die("Cant open $file: $!\n"); 22 | } 23 | 24 | while(my $line = <$fh>) { 25 | if($line !~ /$pattern/) { 26 | print $line; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /nicefind: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: a very nice find ui 3 | find "$@" -printf "\033[38;5;172m%M\033[38;5;104m %TY-%Tm-%Td\033[0m ▎ \033[38;5;100m%d\033[38;5;197m%y\033[0m ▎ %f\033[38;5;190m ->\033[0m(\033[38;5;166m%.20P\033[0m) \n" 4 | -------------------------------------------------------------------------------- /non: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | while(<>) { 4 | s/\n/ » /; 5 | print; 6 | } 7 | -------------------------------------------------------------------------------- /nowrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf %b '\033[?7l' 3 | -------------------------------------------------------------------------------- /np-info: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: dump info from beets and pimpd2 about now playing song in mpd 3 | use strict; 4 | use warnings; 5 | 6 | use DDP; 7 | 8 | use Music::Beets::Info qw(beet_info); 9 | use App::Pimpd; 10 | use App::Pimpd::Playlist::Favorite qw(already_loved); 11 | 12 | use File::LsColor qw(ls_color); 13 | 14 | $config{loved_database} = "$ENV{HOME}/var/pimpd2/pimpd2.db"; 15 | #p %App::Pimpd::config; 16 | 17 | 18 | my $mpd = Audio::MPD->new; 19 | my $file = $ENV{XDG_MUSIC_DIR} . $mpd->current->file; 20 | 21 | my $love = already_loved($mpd->current->file); 22 | 23 | my $data = beet_info($file); 24 | 25 | printf "> %s\n", ls_color($file); 26 | $data->{loved} = 'YES' if $love; 27 | p $data; 28 | -------------------------------------------------------------------------------- /np-lyrics: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: lyrics for currently playing song in mpd 4 | # lyrics taken from the lyrics tag, populated by beets 5 | 6 | beet info -i 'lyrics' "$XDG_MUSIC_DIR/$(mpc --format %file%|head -1)" \ 7 | 2> /dev/null \ 8 | | perl -pe 's/^lyrics:\s+/\n/' \ 9 | | ls_color 10 | -------------------------------------------------------------------------------- /npbeets: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | 4 | beet info "$XDG_MUSIC_DIR/$(mpc --format %file%|head -1)" 2> /dev/null 5 | -------------------------------------------------------------------------------- /offensive: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Regexp::Common qw(profanity); 4 | use Term::ExtendedColor qw(:attributes); 5 | 6 | if(@ARGV) { 7 | for my $f(@ARGV) { 8 | my $seen = 0; 9 | open(my $fh, '<', $f) or die("Cant open $f: $!\n"); 10 | 11 | while(<$fh>) { 12 | if($_ =~ m/($RE{profanity})/) { 13 | my $bad = $1; 14 | $seen++; 15 | print bold($f), "\n" unless $seen >=2; 16 | printf("@{[fg(85, '% 6d:')]}: %s\n", $., $bad); 17 | } 18 | } 19 | } 20 | exit; 21 | } 22 | 23 | 24 | while(<>) { 25 | m/($RE{profanity})/ and print "$.: $1\n"; 26 | } 27 | -------------------------------------------------------------------------------- /ord: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use utf8; 3 | use open qw(:std :utf8); 4 | 5 | for(@ARGV) { 6 | printf("0x%x, %d\n", (ord($_)) x 2); 7 | } 8 | -------------------------------------------------------------------------------- /pac+x: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh et sw=2 fen fdm=marker fmr=#<,#>: 3 | 4 | # 13 | 14 | pacman -Ql "$@" \ 15 | | perl -lne ' 16 | m!bin/([ -~]+)$! && print map { 17 | (-x "$_/$1" && ! -l "$_/$1") 18 | ? "\e[38;5;30m$_\e[1m/\e[m\e[38;5;208;3m$1\e[m" 19 | : "" 20 | } split /:/, $ENV{PATH}' 21 | -------------------------------------------------------------------------------- /pack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | for my $w(qw(abc), 42, 3.1415) { 5 | for(qw(a A Z b B h H c C W s S l L i I n N v V j J f d F u U w)) { 6 | printf("%s: %s (%s)\n", $w, unpack("$_*", $w), $_); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /pacstat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: pacman statisticts 3 | open(my $pp, 'pacman -Qq|'); 4 | chomp(my @all_pkg = <$pp>); 5 | close($pp); 6 | 7 | open(my $fh, 'pacman -Qqs "^perl-"|'); 8 | chomp(my @perl_pkg = <$fh>); 9 | close($fh); 10 | 11 | open(my $fh, 'pacman -Qe|'); 12 | chomp(my @expl_pkg = <$fh>); 13 | close($fh); 14 | 15 | my $percent_perl = sprintf("%.2f", scalar(@perl_pkg) / scalar(@all_pkg)); 16 | ($percent_perl) = $percent_perl =~ m/0\.(.+)$/; 17 | 18 | printf("%d installed packages (%d installed explicitly), %d installed perl modules (%d%% of all installed packages)\n", 19 | scalar(@all_pkg), scalar(@expl_pkg), scalar(@perl_pkg), $percent_perl 20 | ); 21 | -------------------------------------------------------------------------------- /parselscolors: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | my $i = 0; 5 | for(split(/:/, $ENV{LS_COLORS})) { 6 | my($ft,$color) = $_ =~ /\*\.(.+)=(.+)/; 7 | if(!@ARGV) { 8 | printf("\e[$color%s %10s\e[m\n", 'm', $ft); 9 | $i++; 10 | } 11 | else { 12 | open(my $fh, '>', "ls_color.$ft"); 13 | close($fh); 14 | } 15 | } 16 | print "\n"; 17 | -------------------------------------------------------------------------------- /passwd_gen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: generate a safe password 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | use List::Util qw(shuffle); 6 | 7 | my @chars = shuffle( ( ('a'..'z'), (0 .. 9), qw(? ! " ¤ % & / ( ) - _) ) ); 8 | 9 | print my $word = substr(join('', @chars), 0, 30), "\n"; 10 | -------------------------------------------------------------------------------- /paste: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use File::Copy; 4 | 5 | my $int_host = '192.168.1.128'; 6 | my $ext_host = 'http://p.japh.se'; 7 | 8 | my @html; 9 | for(@ARGV) { 10 | -f $_ and vimpaste($_); 11 | my $time_str = substr(time(), -3); 12 | move("$_.html", "$_-$time_str.html") and push(@html, "$_-$time_str.html"); 13 | } 14 | 15 | for(@html) { 16 | system("scp -P 19216 $_ $int_host:/home/scp1/http/japh.se/paste/"); 17 | my $abs_url = "$ext_host/$_"; 18 | print "$abs_url\n"; 19 | system("echo $abs_url|xclip && rm -v $_"); 20 | } 21 | 22 | sub vimpaste { 23 | for(@_) { 24 | system("vim \"$_\" -c 'set nonumber' -c TOhtml -c :w :q! -c :q!"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /path_update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for dir in $(find $HOME/devel -maxdepth 1 -type d); do PATH=$dir:$PATH; done 3 | -------------------------------------------------------------------------------- /pc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # upload Perl module/script to the perlcritic web service 3 | 4 | wget -q -O - --post-file="$@" http://perlcritic.com/perl/critic.pl 5 | -------------------------------------------------------------------------------- /pcp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #pcp - copy files matching pattern $1 to $2 3 | 4 | find . -regextype awk -iregex ".*$1.*" -print0 \ 5 | | xargs -0 cp -vR -t "$2" 6 | -------------------------------------------------------------------------------- /peak: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # vim: ft=zsh: 3 | # abstract: return human readable strings from bins 4 | print -C4 $(strings "${@:-$0}" | grep -Po '\b[^_][A-Z_]{3,}' | uniq) 5 | 6 | # PEAK WHAT WHERE DUDE 7 | -------------------------------------------------------------------------------- /periodic: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: modify fg, bg and cursor color nicely 3 | printf "\e]10;#%06x\a\e]12;#%06x\a\e]11;#%06x\a", 4 | int rand 256**3, 255*255*int rand 255, (12, 16, 20, 32, 48)[int rand 5] 5 | -------------------------------------------------------------------------------- /perl-multi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | perlbrew exec perl "$@" 3 | -------------------------------------------------------------------------------- /picam: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # set up: 4 | # credentials for auto-scp'ing 5 | # photo save dir 6 | # sleep time 7 | 8 | USER='scp1' 9 | HOST='laleh' 10 | SAVE_DIR_LOCAL="${HOME}/camera" 11 | SAVE_DIR_REMOTE="_picam" 12 | SLEEP=360 13 | 14 | while true; do 15 | FILE=$(date +"%Y-%m-%d_%H%M%S").jpg 16 | 17 | printf -- "----------\n" 18 | raspistill -vf -n -o $FILE && printf "$FILE written\n" 19 | scp $FILE ${USER}@${HOST}:${SAVE_DIR_REMOTE} && rm -v $FILE 20 | printf -- "----------\n" 21 | sleep $SLEEP 22 | done 23 | -------------------------------------------------------------------------------- /pimpla: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: perl interface for mplayer using fifos 3 | use strict; 4 | my $fifo = "/home/scp1/.mplayer/fifo"; 5 | my %commands = ('fs' => 'vo_fullscreen', 6 | 'stop' => 'stop', 7 | 'pause' => 'pause', 8 | 'soff' => 'mute 1', 9 | 'son' => 'mute 0', 10 | 'fstep' => 'frame_step', 11 | 'osd' => 'osd', 12 | ); 13 | 14 | if(!@ARGV) { 15 | foreach my $choice(sort(keys(%commands))) { 16 | printf("%6s %s\n", $choice, $commands{$choice}); 17 | } 18 | } 19 | 20 | my $cmd = shift; 21 | &talk($commands{$cmd}); 22 | 23 | sub talk { 24 | my $cmd = shift; 25 | open(FIFO,'>',$fifo) or die $!; 26 | print FIFO $cmd, "\n"; 27 | close(FIFO); 28 | } 29 | -------------------------------------------------------------------------------- /pkgfont: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: list packages that includes fonts 3 | use strict; 4 | use File::LsColor qw(ls_color); 5 | 6 | my %font_pkgs; 7 | open(my $pacman, '-|', 'pacman -Ql') or die($!); 8 | while(<$pacman>) { 9 | push(@{$font_pkgs{$1}}, $2) if($_ =~ /(.*)?\s+(.*font.*)/) and(! -d $2); 10 | } 11 | 12 | for my $pkg(sort(keys(%font_pkgs))) { 13 | printf("\t\033[31;1m%s\033[0m => [\n", $pkg); 14 | for my $font(@{$font_pkgs{$pkg}}) { 15 | print "\t\t", ls_color($font), "\n"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /playlist_cleanup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Tie::File; 4 | 5 | my @playlists = glob("/mnt/Music_1/Playlists/*"); 6 | 7 | 8 | for my $p(@playlists) { 9 | tie(my @songs, 'Tie::File', $p) or die("Cant tie: $!"); 10 | my $i = 0; 11 | for my $s(@songs) { 12 | if(! -f "/mnt/Music_1/$s") { 13 | print "/mnt/Music_1/$s\n"; 14 | splice(@songs, $i, 1) or die($!) 15 | } 16 | } 17 | untie(@songs) or die("Cant close file: $!"); 18 | } 19 | -------------------------------------------------------------------------------- /playlists_update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | # abstract: update playlists of loved songs (pimpd2 --love) 4 | cd $HOME/dev/pimpd2_playlists && 5 | git add . && 6 | git commit -m 'update playlists' && 7 | git push 8 | -------------------------------------------------------------------------------- /plexampnext: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | xdotool key ctrl+p 4 | -------------------------------------------------------------------------------- /plexampprev: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | xdotool key ctrl+o 4 | -------------------------------------------------------------------------------- /pmdesc: -------------------------------------------------------------------------------- 1 | use strict; 2 | use CPANPLUS::Backend; 3 | 4 | my $cp = CPANPLUS::Backend->new; 5 | 6 | 7 | 8 | foreach my $mod($cp->installed()) { 9 | my $package = $mod->details->{Package}; 10 | $package =~ s/\.tar.gz//; 11 | printf("%-35.35s %42s\n", 12 | $package,$mod->details->{Description}); 13 | } 14 | -------------------------------------------------------------------------------- /pmv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #pmv - move files matching pattern $1 to $2 3 | 4 | find . -ignore_readdir_race -regextype awk -iregex ".*$1.*" -print0 \ 5 | | xargs -0 mv -v -t "$2" 6 | -------------------------------------------------------------------------------- /podcheck: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | podchecker $(find -iname '*.pod') 3 | -------------------------------------------------------------------------------- /poormansls++: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: poor mans ls++, demonstrate ls_color from File::LsColor 4 | DELIMITER="\033[38;5;240m|\033[m" 5 | find "$@" -printf "\033[33m%M\033[m $DELIMITER \033[38;5;38m%TY-%Tm-%Td\033[m $DELIMITER %d%y %f\n" \ 6 | | ls_color -k6 7 | -------------------------------------------------------------------------------- /prove-multi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | perlbrew exec prove "$@" 3 | -------------------------------------------------------------------------------- /pushall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # push to all remote repos 3 | 4 | for repo in $(git remote); do 5 | printf "\e[1m\e[34m%10s\e[0m" $repo && 6 | git push $repo 7 | done 8 | -------------------------------------------------------------------------------- /radio: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl: 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | use Net::Domain qw(hostname); 6 | 7 | my %channels = map { $_ => "http://japh.se/$_" } qw( 8 | p1 p2 p3 p4 dingata street 9 | dnb hc hs gabber ds 10 | psy psy2 psy3 psy4 11 | kohina kohina2 keygen rainwave cvgm paralax slay sid 12 | hard dnb2 13 | moh wc 14 | ost old 15 | ); 16 | my $choice = (defined $ARGV[0] && exists($channels{$ARGV[0]})) 17 | ? shift @ARGV 18 | : 'kohina'; 19 | 20 | play($channels{$choice}); 21 | 22 | sub play { 23 | system('mplayer', 24 | '-identify', 25 | '-really-quiet', 26 | '-include', $ENV{MPLAYER_CONFIG}, 27 | '-profile', hostname(), 28 | shift @_ 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /rainbow: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: a rainbow in your shell 4 | 5 | printf "\033c\033(K\033[J\033[0m\033[?25h" 6 | yes "$(seq 231 -1 16)" | while read i; do printf "\033[48;5;${i}m\n"; sleep .02; done 7 | -------------------------------------------------------------------------------- /randalbum2go: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | 4 | ## 2016-08-18 5 | # Having a hard time selecting what albums to take 6 | # with me on the go, this script is doing all the 7 | # hard work for me. Bonus: I get to listen to new 8 | # tunes. 9 | # 10 | # Features: 11 | # - Hardcoded values (enjoy) 12 | # - Colors! 13 | # - Should do this in perl instead of making an external call 14 | # - It works! In MS Windows! (msys2) 15 | ## 16 | 17 | tmpdir='F:/tomp3' 18 | album_path="$(find F:/music -maxdepth 2 -type d|sort -R|head -1)" 19 | album=$(printf "%s" $album_path|perl -pe 's;^.+/(.+)$;$1;') 20 | 21 | 22 | mkdir -p $tmpdir 23 | echo "> processing..." 24 | cp -r "$album_path" $tmpdir && 25 | printf "beamed: \e[31;1m%.60s\e[m\n" $album 26 | -------------------------------------------------------------------------------- /randwall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | # randwall 4 | use List::Util qw(shuffle); 5 | 6 | my $wdir = '/mnt/Docs/Wallpapers/3360x1050'; 7 | opendir(my $walls, $wdir) or die "Cant open $wdir: $!\n"; 8 | my @walls = readdir($walls); 9 | @walls = shuffle(@walls); 10 | 11 | system("feh --bg-center \"$wdir/$walls[0]\""); 12 | -------------------------------------------------------------------------------- /ratrepl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl et sw=2: 3 | # abstract: ratpoison repl 4 | use strict; 5 | 6 | sub prompt; 7 | prompt(); 8 | while(my $cmd = <>) { 9 | chomp $cmd; 10 | if( ($cmd eq 'help') or ($cmd eq 'usage') or ($cmd eq '') ) { 11 | help(); 12 | prompt(); 13 | next; 14 | } 15 | print do { local $/; "\e[1m" . `$ENV{RATPOISON} -c '$cmd'` . "\e[m" }; 16 | prompt(); 17 | } 18 | 19 | sub prompt { 20 | printf "\e[32mrat\e[1m»\e[m "; 21 | } 22 | 23 | sub help { 24 | print do { local $/; "\e[1m" . `$ENV{RATPOISON} -c help` . "\e[m\n" }; 25 | } 26 | -------------------------------------------------------------------------------- /reddit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use JSON::XS; 4 | use Data::Dumper; 5 | use LWP::Simple; 6 | 7 | my $user = shift // $ENV{REDDIT_USERNAME} // get_username(); 8 | my $url = "http://www.reddit.com/user/$user/about.json"; 9 | 10 | my $status = decode_json(get($url)); 11 | 12 | for my $tag(qw(link_karma comment_karma has_mail)) { 13 | if( ($tag == 'has_mail') && (!defined($status->{data}->{$tag})) ) { 14 | next; 15 | } 16 | printf("%13s: %s\n", $tag, $status->{data}->{$tag}); 17 | } 18 | 19 | 20 | sub get_username { 21 | print 'user: '; 22 | chomp(my $answer = ); 23 | 24 | die("No username provided, giving up...\n") if ! defined($answer); 25 | 26 | return $answer; 27 | } 28 | -------------------------------------------------------------------------------- /remount: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umount "$@" && mount "$@" 3 | -------------------------------------------------------------------------------- /rename-tv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: rename tv episodes 3 | 4 | prename 's/[.]([0-9]+)[.]of.([0-9]+)/.S01E0$1/i' "$@" 5 | prename 's/[.]p(?:ar)?t[.]?([0-9]+)/.S01E0$1/i' "$@" 6 | prename 's/(s[0-9]+e[0-9]+)/\U$1/' "$@" 7 | 8 | prename 's/^nova/PBS.NOVA/i' "$@" 9 | prename 's/^horizon/BBC.Horizon/i' "$@" 10 | prename 's/^sciencenow/scienceNOW/i' "$@" 11 | -------------------------------------------------------------------------------- /rename2dirname.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # rename files in subdirs to the name of the subdir_____originalfilename 3 | for f in */* ;do fp=$(dirname "$f"); fl=$(basename "$f"); mv -v "$fp/$fl" "$fp/$fp"_____"$fl"; done 4 | -------------------------------------------------------------------------------- /renamefromid3v2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | kid3-cli -c 'fromtag "%{artist} - %{title}" 2' 3 | -------------------------------------------------------------------------------- /rensafilm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # rensafilm 3 | use strict; 4 | 5 | opendir(my $dh, '/mnt/Movies_1') or die($!); 6 | my @movies_1 = readdir($dh); 7 | close($dh); 8 | 9 | opendir(my $dh, '/mnt/Movies_2') or die($!); 10 | my @movies_2 = readdir($dh); 11 | close($dh); 12 | 13 | for my $foo(@movies_1) { 14 | for(@movies_2) { 15 | my($name) = $foo =~ /(.+)\.[0-9]{4}\..+/; 16 | next if(!$name); 17 | if($_ =~ /$name/) { 18 | printf("\e[38;5;148m/mnt/Movies_1/\e[1m\e[38;5;100m%s\e[0m => \e[38;5;131m/mnt/Movies_2/\e[1m\e[38;5;166m$_\e[0m\n", 19 | $foo, $_); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /rensamusik: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # rensamusik 3 | 4 | use strict; 5 | my $DEBUG = 0; 6 | 7 | my $base = shift // '/mnt/Music_'; 8 | my @ignores = qw( 9 | 00-Random 10 | ); 11 | 12 | for my $n(1,3,4,5,6,7) { 13 | my $next; 14 | 15 | ($n == 7) ? $next = 1 : $next = $n + 1; 16 | $next = 3 if $next == 2; 17 | $next = 1 if $next > 7; 18 | 19 | for my $nn(1,3,4,5,6,7) { 20 | for my $c('A' .. 'Z', 'VA', 'FLAC', 'Not_Scene') { 21 | printf("\e[1m\e[38;5;148m%s \e[38;5;196m%s\e[0m\n", 22 | "$base$nn/$c => ", "/mnt/Music_$next/$c") if($DEBUG); 23 | system("diff -i $base$nn/$c /mnt/Music_$next/$c|grep -v Only|grep -v @ignores|awk '{print \$3}'"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rescue_chmod: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # abstract: chmod -x /bin/chmod, HELP 3 | echo 'main(){chmod("/bin/chmod", 0755);}'|gcc -xc - -o rescue_chmod && ./rescue_chmod 4 | -------------------------------------------------------------------------------- /retrieve: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use Storable; 4 | use Data::Dumper; 5 | 6 | my $db = shift // "$ENV{HOME}/.music_full.db"; 7 | 8 | print Dumper retrieve( $db ); 9 | -------------------------------------------------------------------------------- /revdnsinternet: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for d in $(seq 1 254); do 3 | for c in $(seq 1 254); do 4 | for b in $(seq 1 254); do 5 | for a in {1..4} {6..9} {11..13} {15..22} {24..30} {32..35} 38 \ 6 | {40..41} {43..38} {50..61} {62..99} {107..109} {128..175} 178 \ 7 | {180,182..184} {186..222}; do 8 | printf "%s.%s.%s.%s " $a $b $c $d | tee -a $a 9 | RESULT=$(dig +short -x $a.$b.$c.$d) 10 | echo $RESULT | tee -a $a 11 | done 12 | done 13 | done 14 | done 15 | -------------------------------------------------------------------------------- /rfc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | system($ENV{PAGER} // 'less', "/usr/share/doc/rfc/txt/rfc" . shift // 2324); 3 | -------------------------------------------------------------------------------- /rgbtohex: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: converts the X11 colortable RGB values to hexadecimal 4 | use strict; 5 | my $rgbfile = "/usr/share/X11/rgb.txt"; 6 | open(RGB,"<", $rgbfile) or die; 7 | while(my $rgb = ) { 8 | if($rgb =~ /(\d+ \d+ \d+)/) { 9 | my $rgbstring = $1; 10 | my ($r,$g,$b) = split(/\s/, $rgbstring); 11 | printf("%x %x %x | %12s", $r, $g, $b, $rgb); 12 | } 13 | } 14 | close(RGB); 15 | -------------------------------------------------------------------------------- /rmc_old: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /bin/rm -vr "$@" \ 4 | | sort \ 5 | | perl -MFile::LsColor=ls_color_internal -lne ' 6 | s/removed `(.+)(.$)/"removed \e[38;5;240m`\e[m" . ls_color_internal($1) . "\e[38;5;240m$2\e[m"/e; 7 | print' 8 | -------------------------------------------------------------------------------- /rmfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: there's rmdir but no rmfile... 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | use File::LsColor; 6 | 7 | for(grep { -f $_ } @ARGV) { 8 | printf "%s %s\n", 9 | (unlink $_) 10 | ? "removed" 11 | : "W: $_ - $!", 12 | "'" . File::LsColor::ls_color_internal($_) . "'"; 13 | } 14 | -------------------------------------------------------------------------------- /rotate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: rotate screen based on current rotation 4 | 5 | ROTATION=$(xrandr -q | head -2 | tail -1 | awk '{print $5}') 6 | 7 | if [ "$ROTATION" = 'left' ]; then 8 | xrandr --output DVI-D-0 --rotate normal 9 | else 10 | xrandr --output DVI-D-0 --rotate left 11 | fi 12 | -------------------------------------------------------------------------------- /rp-mplayer-np: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh:smc&: 3 | ratpoison -c "set bargravity nw" 4 | ratpoison -c "set font Terminus:pixelsize=32:weight=bold:antialias=1:autohint=1:hinting=1:hintstyle=3:rgba=rgba\a" 5 | ratpoison -c "echo $(mplayer_exec -np|uncolor)" 6 | ratpoison -c "set bargravity c" 7 | ratpoison -c "set font Terminus:size=14:weight=bold" 8 | -------------------------------------------------------------------------------- /rp-runorraise: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl et sw=2 cc=+1 smc=80: 3 | # abstract: ratpoison run OR raise (hi firefox) 4 | my ($class, $command) = @ARGV; 5 | die "Usage: $0 windowclassname [ command ]" 6 | unless defined $class and $class =~ /\w/i; 7 | $command ||= lc $class; 8 | my @windows = sort { $b->[1] <=> $a->[1] } 9 | map { [split /\\000/] } 10 | grep { /^$class\\000/i } 11 | split /\n/, `ratpoison -c "windows %c\\000%l\\000%n"`; 12 | exec $command unless scalar @windows; 13 | my $current = `ratpoison -c "info %n"`; 14 | shift @windows if $windows[0]->[2] == $current; 15 | exec "ratpoison -c 'select $windows[0]->[2]'"; 16 | -------------------------------------------------------------------------------- /rt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim: ft=sh: 3 | export RT_SOCKET=${HOME}/var/rtorrent/scgi 4 | test -S $RT_SOCKET \ 5 | && lsof $RT_SOCKET > /dev/null \ 6 | && { echo "rTorrent already running pal"; exit 1; } 7 | test ! -e $RT_SOCKET || rm $RT_SOCKET 8 | 9 | _at_exit() { 10 | test -z "$TMUX" || tmux set-w automatic-rename on # >/dev/null 11 | stty sane 12 | test ! -e $RT_SOCKET || rm $RT_SOCKET 13 | } 14 | trap _at_exit INT TERM EXIT 15 | 16 | rtorrent -n -o import=$HOME/etc/rtorrent.rc 17 | -------------------------------------------------------------------------------- /rt_magnet_handler: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # vim: ft=sh: 3 | # :o about:config 4 | # create a new boolean: 5 | # network.protocol-handler.expose.magnet = false 6 | watch_folder=~/Downloads/ 7 | cd $watch_folder || exit 1 8 | [[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit; 9 | echo "d10:magnet-uri${#1}:${1}e" >> "meta-${BASH_REMATCH[1]}.torrent" 10 | ratpoison -c "echo '${BASH_REMATCH[1]} ${watch_folder}'" 11 | -------------------------------------------------------------------------------- /rt_notify: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | printf "$@: completed %s" "$(date +%c)" | mailx 'm@japh.se' 3 | -------------------------------------------------------------------------------- /rt_query: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: query rtorrent for files matching PATTERN 3 | 4 | if [ $# -lt 1 ]; then 5 | echo "Usage: $0 PATTERN" 6 | exit 7 | fi 8 | 9 | rtcontrol -qo '{{chr(10).join([d.directory+chr(47)+x.path for x in d.files])|h.subst(chr(47)+chr(43),chr(47))}}' /$1/ | \ 10 | ls_color 11 | -------------------------------------------------------------------------------- /rt_remove_torrents_by_tracker: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | # abstract: remove all torrents from TRACKER in rtorrent 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "remove all torrents from TRACKER in rtorrent" 7 | echo "Usage: $0 TRACKER ID" 8 | exit 9 | fi 10 | 11 | tracker=$1 12 | rtcontrol alias=$tracker --stop -o- 13 | rtcontrol alias=$tracker -A dupes+ -V 14 | rtcontrol views=rtcontrol is_open=yes -A dupes+ -V --alter remove 15 | rtcontrol --from rtcontrol // --cull --yes 16 | rtcontrol alias=$tracker --delete --yes 17 | -------------------------------------------------------------------------------- /rtorrent_search: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Filter torrents in the rtorrent ui 3 | # 4 | # s => string 5 | # t => tracker 6 | # f => file 7 | 8 | ( set +x && sleep .05 && rtcontrol -q -V "$@" ) & 9 | -------------------------------------------------------------------------------- /rupl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | while 1 4 | print "\e[38;5;202;1m>\e[m " 5 | begin 6 | str = gets 7 | error = nil 8 | 9 | result = eval( str ) 10 | rescue SyntaxError, NameError => error 11 | puts "\e[1mDoes no compute\e[m: \e[38;5;160m" + error + "\e[m" 12 | end 13 | 14 | if !error 15 | print "\e[38;5;34m", result, "\e[m\n" 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /sanitize_input: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | while(<>) { 4 | s/%20/_/g; 5 | s/%28/-/g; 6 | s/%29//g; 7 | s/[åä]/a/g; 8 | s/[ö]/o/g; 9 | s/,+/./g; 10 | s/_+/_/g; 11 | s/[#'[]]/_/g; 12 | print; 13 | } 14 | -------------------------------------------------------------------------------- /sascii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: interactive key inspector 4 | 5 | use strict; 6 | use Term::ReadKey; 7 | 8 | ReadMode('cbreak'); 9 | 10 | while (1) { 11 | my $char = ReadKey(0); 12 | printf("%3s - %3d | 0x%x\n",$char, ord($char), ord($char)); 13 | } 14 | 15 | ReadMode('normal'); 16 | -------------------------------------------------------------------------------- /scandeps: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This was initially a debugging aid for Module::LocalLoad 3 | use strict; 4 | use Module::ScanDeps; 5 | use Data::Dumper; 6 | 7 | my $data = scan_deps( 8 | files => [ '/usr/lib/perl5/core_perl/IO/File.pm'], 9 | recurse => 0, 10 | ); 11 | 12 | print "- Real dependencies for IO::File\n"; 13 | for my $basename(sort((@{$data->{'IO/File.pm'}{uses}}))) { 14 | printf("%s\n", _2module($basename)); 15 | } 16 | 17 | sub _2module { 18 | my $file = shift; 19 | s{/}{::}g, s{\.pm$}{} for $file; 20 | return $file; 21 | } 22 | -------------------------------------------------------------------------------- /scpan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # scpan 3 | use strict; 4 | use LWP::Simple; 5 | use HTML::FormatText::Lynx; 6 | use Term::ExtendedColor qw(fg); 7 | 8 | my $base_url = 'http://search.cpan.org/search?query='; 9 | my $search = shift // 'woldrich'; 10 | 11 | my $html = get("$base_url$search&mode=all&n=100"); 12 | my @result = split(/\n/, HTML::FormatText::Lynx->format_string($html)); 13 | 14 | for(@result) { 15 | last if /^References/; 16 | s/^\[\d+\](\S+::\S+)+/fg('bold', fg('blue4', $1))/e; 17 | 18 | print "$_\n"; 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /screen-start-or-attach: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: start screen or attach to a running session 3 | 4 | status="$(/usr/bin/screen -ls)" 5 | 6 | if [[ "${status}" =~ "No Sockets found" ]]; then 7 | /usr/bin/screen 8 | else 9 | sdorfehs -c 'echo attaching screen session' 10 | /usr/bin/screen -x 11 | fi 12 | -------------------------------------------------------------------------------- /screen_status: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mpc --format "%artist% - %title%" | head -1 | perl -pe 's/[åä]/a/gi; s/[ö]/o/gi' 3 | -------------------------------------------------------------------------------- /scrot2debbie: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | scp "$@" debbie:/var/www/html/_pix/ && echo "http://i.japh.se/$1" | xclip && echo "http://i.japh.se/$1" 4 | -------------------------------------------------------------------------------- /sdorfehs-define-escapekey: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sdorfehs -c 'escape C-f' 3 | -------------------------------------------------------------------------------- /sdorfehs-definekey-tops: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: define keys for switching workspaces 3 | 4 | sdorfehs -c 'definekey top s-1 vselect 0' 5 | sdorfehs -c 'definekey top s-2 vselect 1' 6 | sdorfehs -c 'definekey top s-3 vselect 2' 7 | sdorfehs -c 'definekey top s-4 vselect 3' 8 | sdorfehs -c 'definekey top s-5 vselect 4' 9 | sdorfehs -c 'definekey top s-6 vselect 5' 10 | sdorfehs -c 'definekey top s-7 vselect 6' 11 | sdorfehs -c 'definekey top s-8 vselect 7' 12 | sdorfehs -c 'definekey top s-9 vselect 8' 13 | sdorfehs -c 'definekey top s-0 vselect 9' 14 | sdorfehs -c 'definekey top s-q vselect 10' 15 | sdorfehs -c 'definekey top s-w vselect 11' 16 | sdorfehs -c 'definekey top s-e vselect 12' 17 | -------------------------------------------------------------------------------- /sdorfehs-undefine-escapekey: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # to disable/change metakey + F-keys prior to launching a game from steam and restoring the settings when the game finishes: 3 | # sdorfehs-undefine-escapekey;sdorfehs-undefinekey-tops; %command%; sdorfehs-define-escapekey;sdorfehs-definekey-tops 4 | sdorfehs -c 'escape C-g' 5 | -------------------------------------------------------------------------------- /sdorfehsrepl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl et sw=2: 3 | # abstract: sdorfehs repl 4 | use strict; 5 | 6 | sub prompt; 7 | prompt(); 8 | while(my $cmd = <>) { 9 | chomp $cmd; 10 | if( ($cmd eq 'help') or ($cmd eq 'usage') or ($cmd eq '') ) { 11 | help(); 12 | prompt(); 13 | next; 14 | } 15 | print do { local $/; "\e[1m" . `sdorfehs -c '$cmd'` . "\e[m" }; 16 | prompt(); 17 | } 18 | 19 | sub prompt { 20 | printf "\e[32msdorfehs\e[1m»\e[m "; 21 | } 22 | 23 | sub help { 24 | print do { local $/; "\e[1m" . `sdorfehs -c help` . "\e[m\n" }; 25 | } 26 | -------------------------------------------------------------------------------- /seen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: abuse sticky bits etc to mark a movie or show as seen 4 | use strict; 5 | use warnings FATAL => 'all'; 6 | 7 | if(!@ARGV) { 8 | use Cwd (); 9 | push @ARGV, Cwd::abs_path 10 | } 11 | 12 | for my $f(@ARGV) { 13 | if(-f $f) { 14 | chmod(02740, $f) or warn "chmod: $!\n"; 15 | } 16 | elsif(-d $f) { 17 | chmod(01700, $f) or warn "chmod: $!\n"; 18 | } 19 | else { 20 | warn "E: $_ is neither a file or a directory\n"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /separate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | 5 | 6 | my $old; 7 | while(<>) { 8 | my($current) = $_ =~ m{(.*/).+}; 9 | if($current ne $old) { 10 | print "\n"; 11 | $old = $current; 12 | print; 13 | next; 14 | } 15 | print; 16 | } 17 | -------------------------------------------------------------------------------- /set_album_title_for_losa_latar_to_various: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: set album title to "Various" for everything in */+tracks/ for plex{,amp}. also set year/date to 1337-01-01 3 | 4 | # For the entire music collection: 5 | # for x in ~/mnt/nasse/music/*/**/*+tracks; do cd "$x"; kid3-cli -c pwd -c "select *" -c "set album 'Various'" -c "set date '1337-01-01'" -c ls -c save; done 6 | 7 | 8 | # for current directory: 9 | kid3-cli -c pwd -c "select *" -c "set album 'Various'" -c "set date '1337-01-01'" -c save 10 | -------------------------------------------------------------------------------- /setallfonts: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # vim: ft=sh: 3 | # abstract: set all fonts to ARG 4 | 5 | for i in 71{0..3}; do 6 | printf "\033]${i};%s\007" "$@" 7 | done 8 | -------------------------------------------------------------------------------- /setbg_sshhosts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: set terminal background differently for each ssh host 4 | 5 | # if [[ $UID != 0 ]] 6 | # then 7 | # if [ -f "$HOME/.ssh/config" ] 8 | # then 9 | # for host in $( 10 | # perl -ne 'print "$1\n" if /\A[Hh]ost\s+(.+)$/' $HOME/.ssh/config 11 | # ); do 12 | # alias $host="setbg_sshhosts $host; ssh $host $@" 13 | # done 14 | # fi 15 | # fi 16 | 17 | 18 | my $host = shift; 19 | 20 | my %hosts = ( 21 | fantomen => '161212', 22 | debbie => '000000', 23 | dockie => '121216', 24 | x1 => '141414', 25 | ); 26 | 27 | bg(); 28 | sub bg { 29 | my $background = $hosts{ $host } ? $hosts{ $host } : '361212'; 30 | print "\e]11;#$background\a"; 31 | print "\e]10;#ffffff\a"; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /shift-insert: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: shift+insert 4 | # xte is part of the xautomation package 5 | # 6 | xte 'keydown Shift_R' 'key Insert' 'keyup Shift_R' 7 | -------------------------------------------------------------------------------- /shortdate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | date +%Y-%m-%d 3 | -------------------------------------------------------------------------------- /shot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: take screenshot and upload to httpd 3 | 4 | shot() { 5 | FNAME=$(date +%s.png) 6 | /usr/bin/scrot $@ $FNAME; 7 | scp $FNAME pi@pi:httpd/scrots/$DNAME && 8 | rm $FNAME && 9 | echo http://i.japh.se/$DNAME/$FNAME|xclip 10 | } 11 | 12 | shot $@ 13 | -------------------------------------------------------------------------------- /shoutcast_parser: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl: 3 | use strict; 4 | use LWP::Simple; 5 | 6 | my $url = shift or usage(); 7 | 8 | my $seen_title = 0; 9 | for my $l(split(/\n/, LWP::Simple::get($url))) { 10 | if(($seen_title < 1) && ($l =~ m/Title[0-9]+=(.+)$/)) { 11 | $seen_title++; 12 | print STDERR "$1\n"; 13 | } 14 | elsif($l =~ m/^File[0-9]+=(\S+)$/) { 15 | print "$1\n"; 16 | } 17 | } 18 | 19 | sub usage() { 20 | die << "." 21 | Usage: $0 url 22 | . 23 | ; 24 | } 25 | -------------------------------------------------------------------------------- /shrug: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: shift+insert 4 | # xte is part of the xautomation package 5 | # 6 | # insert the string "¯\_(ツ)_/¯" 7 | 8 | echo '¯\_(ツ)_/¯' | xclip 9 | 10 | -------------------------------------------------------------------------------- /sidtop: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # <3 dunz0r 3 | use strict; 4 | use LWP::Simple; 5 | 6 | 7 | sub fav { 8 | my %top100 = (); 9 | for(split(/\n/, get("http://www.c64.org/HVSC/DOCUMENTS/Creators.txt"))) { 10 | m;\s*([0-9]+)+.+(/MUSICIANS/.+\.sid);; 11 | $top100{$1} = $2; 12 | } 13 | return(\%top100); 14 | } 15 | 16 | sub play { 17 | my $sids = fav(); 18 | for my $n(sort {$b <=> $a} (keys(%$sids))) { 19 | printf("\e[1m%3d\e[0m %s\n", $n, $sids->{$n}) 20 | unless($n == 0); 21 | 22 | } 23 | chomp(my $choice = ); 24 | # yeah, I know 25 | system('wget', "http://www.c64.org/HVSC/$sids->{$choice}", '-O', "$$.sid");; 26 | system('sidplay2', "$$.sid"); 27 | unlink("$$.sid"); 28 | 29 | } 30 | 31 | play(); 32 | 33 | -------------------------------------------------------------------------------- /simart: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | # simart - find similar artists 4 | 5 | use Audio::MPD; 6 | use LWP::Simple; 7 | 8 | my $mpd = Audio::MPD->new; 9 | my $artist = shift // $mpd->current->artist // undef; 10 | my $url = "http://ws.audioscrobbler.com/1.0/artist/$artist/similar.txt"; 11 | 12 | sub fetch_similars { 13 | if($artist) { 14 | my @fetched = split/\n/, get($url); 15 | print "Artists similar to $artist:\n\n"; 16 | s/.+,//g for(@fetched); 17 | foreach my $sim(@fetched) { 18 | print $sim, "\n"; 19 | } 20 | } 21 | else { 22 | print "ID3 tag ARTIST missing\n"; 23 | exit 0; 24 | } 25 | exit 0; 26 | } 27 | 28 | &fetch_similars; 29 | -------------------------------------------------------------------------------- /sort_aliases: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | my $alias = "$ENV{HOME}/etc/zsh/02-alias.zsh"; 5 | 6 | open(my $fh, '<', $alias) or die($!); 7 | 8 | my %aliases; 9 | 10 | while(<$fh>) { 11 | next if /^#/; 12 | if(m/^\s*alias\s+(\w+)=(?:'|")(.+)(?:'|")/) { 13 | $aliases{$1} = $2; 14 | } 15 | } 16 | 17 | for my $k(sort{ $aliases{$b} cmp $aliases{$a} } (keys(%aliases))) { 18 | print "alias $k='$aliases{$k}'\n"; 19 | } 20 | -------------------------------------------------------------------------------- /sort_video: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings FATAL => 'all'; 5 | use JSON; 6 | use Data::Dumper; 7 | 8 | my $file = shift // '/mnt/Mvids/Aerosmith/Aerosmith-Amazing.mpg'; 9 | 10 | close(STDERR) or die $!; 11 | my $meta = ffprobe($file); 12 | 13 | printf("\e[38;5;196;1m%s\e[m\n", $file); 14 | print Dumper $meta; 15 | sub ffprobe { 16 | chomp(my $s = `ffprobe -show_streams -print_format json $_[0]`); 17 | $s; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /sshc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | # abstract: change and restore bg/fg colors based on ssh host 4 | # $ export GIT_SSH=/bin/ssh 5 | 6 | # defaults 7 | BG_COLOR='000' 8 | FG_COLOR='fff' 9 | 10 | # no host specified, set default color 11 | if [ $# -eq 0 ]; then 12 | printf '\e]11;#%s\a' $BG_COLOR 13 | printf '\e]10;#%s\a' $FG_COLOR 14 | exit 1 15 | fi 16 | 17 | HOST=$1 18 | 19 | if [ "$HOST" == 'lid' ]; then 20 | BG_COLOR='272727' 21 | FG_COLOR='fff' 22 | shift 23 | elif [ "$HOST" == 'pi' ]; then 24 | BG_COLOR='18130b' 25 | FG_COLOR='cdd5d8' 26 | shift 27 | fi 28 | 29 | printf "\e]11;#%s\a" $BG_COLOR 30 | printf "\e]10;#%s\a" $FG_COLOR 31 | 32 | /bin/ssh "$@" $HOST 33 | 34 | printf '\e]11;#000%s\a' 35 | printf '\e]10;#fff%s\a' 36 | -------------------------------------------------------------------------------- /stderr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: print input to stderr 3 | 4 | use strict; 5 | 6 | select STDERR; 7 | if(!(@ARGV)) { 8 | while(<>) { 9 | chomp; 10 | printf "%s\n", $_; 11 | } 12 | } 13 | else { 14 | printf "%s\n", "@ARGV"; 15 | } 16 | -------------------------------------------------------------------------------- /strip_esc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: strip data from escape sequences 4 | # \e[1m 5 | # \e[38;5;197m 6 | # \033[31;1m 7 | 8 | use strict; 9 | 10 | if(!@ARGV) { 11 | while() { 12 | push(@ARGV, $_); 13 | } 14 | print for parse(@ARGV); 15 | exit(0); 16 | } 17 | 18 | my $file = shift; 19 | open(my $fh, '<', $file) or die($!); 20 | print for parse(<$fh>); 21 | close($fh); 22 | 23 | sub parse { 24 | my @data = @_; 25 | 26 | for(@data) { 27 | s/(?:\e|\033)\[[0-9]+(?:;[0-9]+)?(;[0-9]+)m//g; 28 | s/(?:\e|\033)\[[0-9]+m//g; 29 | } 30 | return(@data); 31 | } 32 | -------------------------------------------------------------------------------- /strip_html: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | # No - use a real HTML Parser 5 | 6 | while(<>) { 7 | s{<(?>/?)(?:[^\s>/])[^>]*>}{}g and print; 8 | } 9 | -------------------------------------------------------------------------------- /stumpdump: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # stumpdump 3 | 4 | my $fname = int(rand(100)); 5 | system("stumpish dump-desktop-to-file $fname"); 6 | my $foo = ; 7 | system("stumpish restore-from-file $fname && rm \$HOME/$fname"); 8 | -------------------------------------------------------------------------------- /sub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # sub 3 | # do what perl -pi -e does, but faster 4 | use strict; 5 | 6 | use File::Slurp; 7 | 8 | my $opt; 9 | 10 | my $pattern = shift or usage() and exit; 11 | 12 | for( grep{ -f $_ } @ARGV ) { 13 | File::Slurp::edit_file { 14 | eval "$pattern"; 15 | warn "$@\n" if $@; 16 | } $_ 17 | } 18 | 19 | sub usage { 20 | printf("sub [PATTERN] [FILE..]\n"); 21 | } 22 | -------------------------------------------------------------------------------- /subscript: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | use vars qw($VERSION); 5 | 6 | my $APP = 'subscript'; 7 | $VERSION = '0.001'; 8 | 9 | my $map = { 10 | 0 => '₀', # 2080 SUBSCRIPT ZERO 11 | 1 => '₁', # 2081 SUBSCRIPT ONE 12 | 2 => '₂', # 2082 SUBSCRIPT TWO 13 | 3 => '₃', # 2083 SUBSCRIPT THREE 14 | 4 => '₄', # 2084 SUBSCRIPT FOUR 15 | 5 => '₅', # 2085 SUBSCRIPT FIVE 16 | 6 => '₆', # 2086 SUBSCRIPT SIX 17 | 7 => '₇', # 2087 SUBSCRIPT SEVEN 18 | 8 => '₈', # 2088 SUBSCRIPT EIGHT 19 | 9 => '₉', # 2089 SUBSCRIPT NINE 20 | }; 21 | 22 | my @input = <>; 23 | 24 | for my $int(keys(%{ $map })) { 25 | map { s/$int/$map->{$int}/g; $_ } @input; 26 | } 27 | print @input; 28 | -------------------------------------------------------------------------------- /sync_music: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ -d "/mnt/mp3/MUSIC" ]]; then 4 | rm -vr /mnt/mp3/MUSIC/* && 5 | mv -v /mnt/Leftover/TransferMusic/* /mnt/mp3/MUSIC/ 6 | else 7 | printf "Not mounted!\n" 8 | fi 9 | -------------------------------------------------------------------------------- /thinkpad-brighter: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo 19393 > /sys/class/backlight/intel_backlight/brightness 3 | -------------------------------------------------------------------------------- /title: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use feature 'say'; 4 | use Audio::MPD; 5 | use utf8; 6 | use open qw(:utf8); 7 | use WWW::Mechanize; 8 | 9 | map { $_ = "http://" . $_ unless $_ =~ /http:/ } @ARGV; 10 | 11 | my $mpd = Audio::MPD->new( 12 | host => '192.168.1.128', 13 | port => 6600, 14 | ); 15 | 16 | my $agent = do { 17 | $mpd->current ? $mpd->current->title : 'Laleh'; 18 | }; 19 | 20 | $agent =~ s{[åä]+}{a}g; 21 | $agent =~ s{[ö]}{o}g; 22 | 23 | my $m = WWW::Mechanize->new( 24 | agent => $agent, 25 | ); 26 | 27 | say $m->get($_)->title for @ARGV; 28 | -------------------------------------------------------------------------------- /tohtml: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #tohtml 3 | for f in $@; do 4 | wim "$f" -c TOhtml -c :w -c :q! -c :q! 5 | done 6 | -------------------------------------------------------------------------------- /tomp3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for f in *.flac; do 4 | ffmpeg -i "$f" "$f.mp3" 5 | prename 's/[.]flac([.]mp3)$/$1/' *.mp3 6 | done 7 | -------------------------------------------------------------------------------- /top25: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # setopt no_hist_save_no_dups 3 | use strict; 4 | 5 | $0 =~ s;^.*/(\w+)$;$1;; 6 | 7 | my $history = shift // "$ENV{XDG_DATA_HOME}/zsh/history"; 8 | my $count = shift // 25; 9 | 10 | open(my $fh, '<', $history) or print STDERR "$!" and exit(1); 11 | chomp(my @records = <$fh>); 12 | close($fh); 13 | 14 | my %commands = (); 15 | 16 | for(@records) { 17 | s/^:\s+[0-9]+:[0-9]+;//; 18 | next if $_ eq $0; 19 | $commands{$_}++; 20 | } 21 | 22 | for(sort { $commands{$b} <=> $commands{$a} } keys(%commands)) { 23 | if($count == 0) { 24 | exit(0); 25 | } 26 | printf("% 5d => %s\n", $commands{$_}, $_); 27 | $count--; 28 | } 29 | -------------------------------------------------------------------------------- /topsi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: a bunch of tops in one go 4 | 5 | tmux -f $HOME/etc/tmux.conf new-session -d 'iotop -o -d2 -k' \; \ 6 | split-window -d 'htop' \; \ 7 | split-window -h -p 20 -d 'atop' \; \ 8 | attach 9 | -------------------------------------------------------------------------------- /torrent: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: create torrents 4 | 5 | 6 | if [ $# -lt 2 ]; then 7 | echo "Usage: $0 announce-url directory/" 8 | exit 9 | fi 10 | 11 | url=$1 12 | dir=$2 13 | 14 | mktorrent -a $url -n $dir -p $dir 15 | -------------------------------------------------------------------------------- /tpb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | wget -nv -nc -c -E \ 4 | $( lynx -dump "$@" | awk '/http.+[.]torrent$/ { print $2 }' ) 5 | -------------------------------------------------------------------------------- /traffic: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: visualize httpd traffic 4 | 5 | LOGFILE="$HOME/pi/var/log/access.log" 6 | 7 | tail -fq $LOGFILE \ 8 | | logstalgia -1080x1920 -x --paddle-mode vhost - 9 | -------------------------------------------------------------------------------- /traffic_cpan: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ssh -p 19216 scp1@192.168.1.128 'tail -f /var/log/lighttpd/japh.se/access.log' |\logstalgia -1680x1050 - 3 | -------------------------------------------------------------------------------- /translate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: translate 4 | 5 | while true; do 6 | printf "translate: " 7 | read word 8 | /usr/bin/translate FROM swe $word 9 | done 10 | -------------------------------------------------------------------------------- /tv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | 4 | media_sort -t tv $1 5 | -------------------------------------------------------------------------------- /tweet_compress: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Sneaky way to get more information in your tweets 4 | 5 | use strict; 6 | use utf8; 7 | 8 | sub tweet_compress { 9 | my $tweet = shift; 10 | 11 | my @orig = ( qw/cc ms ns ps in ls fi fl ffl ffi iv ix vi oy ii xi nj/, '. ', ', ' ); 12 | 13 | my @new = qw/㏄ ㎳ ㎱ ㎰ ㏌ ʪ fi fl ffl ffi ⅳ ⅸ ⅵ ѹ ⅱ ⅺ nj . ,/; 14 | 15 | $tweet =~ s/\Q$orig[$_]\E/$new[$_]/g for 0 .. $#orig; 16 | 17 | return $tweet; 18 | } 19 | 20 | binmode STDOUT, ':utf8'; 21 | 22 | print tweet_compress( join '', @ARGV ), "\n"; 23 | -------------------------------------------------------------------------------- /twitter_grep: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | 4 | use Data::Dumper; 5 | 6 | { 7 | package Data::Dumper; 8 | no strict "vars"; 9 | 10 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; 11 | $Quotekeys = 0; 12 | } 13 | 14 | my $person = shift // 'scp1'; 15 | 16 | my $twat = '/mnt/irclogs/192/#twitter_wantarray.log'; 17 | 18 | open(my $fh, '<', $twat) or die("Cannot open $twat: $!\n"); 19 | 20 | my %all; 21 | while(<$fh>) { 22 | chomp; 23 | my($who, $msg) = $_ =~ m{ [0-9]{2}:[0-9]{2}\s@?\s+(\w+)\s+(.+) }x; 24 | push(@{$all{$who}}, $msg); 25 | } 26 | 27 | print Dumper $all{ $person }; 28 | -------------------------------------------------------------------------------- /u-arrows: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: unicode arrows 4 | use strict; 5 | use vars qw($VERSION); 6 | my $APP = ''; 7 | $VERSION = '0.001'; 8 | use utf8; 9 | use open qw(:utf8 :std); 10 | 11 | use charnames qw(:full); 12 | 13 | for my $ord( (0x2190 .. 0x21ff), (0x2900 .. 0x297f), (0x2b00 .. 0x2b59) ) { 14 | printf("%6d, %6x: %s %s\n", $ord, $ord, chr($ord), charnames::viacode($ord)); 15 | } 16 | -------------------------------------------------------------------------------- /u-blocks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: unicode blocks 4 | use strict; 5 | use vars qw($VERSION); 6 | my $APP = ''; 7 | $VERSION = '0.001'; 8 | use utf8; 9 | use open qw(:utf8 :std); 10 | 11 | use charnames qw(:full); 12 | 13 | for my $ord(0x2580 .. 0x259f) { 14 | printf("%6d, %6x: %s %s\n", $ord, $ord, chr($ord), charnames::viacode($ord)); 15 | } 16 | -------------------------------------------------------------------------------- /u-boxdrawing: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: unicode boxes 4 | use strict; 5 | use vars qw($VERSION); 6 | use utf8; 7 | use open qw(:utf8 :std); 8 | 9 | use charnames qw(:full); 10 | 11 | for my $ord(0x2500.. 0x257f) { 12 | printf("%6d, %6x: %s %s\n", $ord, $ord, chr($ord), charnames::viacode($ord)); 13 | } 14 | -------------------------------------------------------------------------------- /u-brackets: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: unicode brackets 4 | use strict; 5 | use utf8; 6 | use open qw(:utf8 :std); 7 | 8 | use charnames qw(:full); 9 | 10 | for my $ord(0x27e6 .. 0x27eb, 0x2983 .. 0x2998, 0x3008 .. 0x301b) { 11 | printf("%6d, %6x: %s %s\n", $ord, $ord, chr($ord), charnames::viacode($ord)); 12 | } 13 | -------------------------------------------------------------------------------- /u-music: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: unicode music 4 | use vars qw($VERSION); 5 | use strict; 6 | use charnames qw(:full); 7 | 8 | use open qw(:std :utf8); 9 | 10 | for my $ord(0x1d100 .. 0x1d1ff,0x1b61 .. 0x1b7c,0xd0000 .. 0x1d0ff,0x266e,0x266f) { 11 | printf("%6d, %6x: %s %s\n", $ord, $ord, chr($ord), charnames::viacode($ord)); 12 | } 13 | -------------------------------------------------------------------------------- /uc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -p 2 | # vim: ft=perl smc&: 3 | $_ = uc; 4 | -------------------------------------------------------------------------------- /ucfirst: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim: ft=perl smc&: 3 | # abstract: uppercase first 4 | 5 | use strict; 6 | 7 | my $line = shift; 8 | chomp($line = <>) unless defined $line; 9 | 10 | my @words = ($line =~ m/(\S+)/g); 11 | 12 | printf "%s\n", $_ for map { ucfirst(lc($_)) } @words; 13 | 14 | -------------------------------------------------------------------------------- /umount-remote: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | fusermount -u $HOME/http 4 | fusermount -u /mnt/httpd 5 | fusermount -u /mnt/floff 6 | fusermount -u /mnt/irclogs 7 | fusermount -u /mnt/Books 8 | fusermount -u /mnt/Movies_1 9 | fusermount -u /mnt/Movies_2 10 | fusermount -u /mnt/Movies_3 11 | fusermount -u /mnt/Movies_4 12 | fusermount -u /mnt/Music_1 13 | fusermount -u /mnt/Music_2 14 | fusermount -u /mnt/Music_3 15 | fusermount -u /mnt/Music_4 16 | fusermount -u /mnt/Music_5 17 | fusermount -u /mnt/Music_6 18 | fusermount -u /mnt/Music_6 19 | fusermount -u /mnt/Mvids 20 | fusermount -u /mnt/TV_1 21 | fusermount -u /mnt/TV_2 22 | fusermount -u /mnt/TV_3 23 | fusermount -u /mnt/TV_4 24 | -------------------------------------------------------------------------------- /uncolor-ruby: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | def uncolor(str) 4 | str.gsub(/\e\[(?:[0-9];?)+m/, '') 5 | end 6 | 7 | ARGF.each_line do |l| 8 | puts uncolor(l) 9 | end 10 | -------------------------------------------------------------------------------- /underline: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: underline input 3 | 4 | use strict; 5 | use Term::ExtendedColor qw(:attributes); 6 | 7 | if(!(@ARGV)) { 8 | while(<>) { 9 | chomp; 10 | printf "%s\n", underline($_); 11 | } 12 | } 13 | else { 14 | printf "%s\n", underline("@ARGV"); 15 | } 16 | -------------------------------------------------------------------------------- /ungzip: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # uncompress gzipped bitches with regex 3 | s;^([^']+\.(?:gz|Z))\z;zcat "$1"|;xs for @ARGV; print while <>; 4 | -------------------------------------------------------------------------------- /uninames: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trapd00r/utils/501525cb0dce2f29908d528172c16b22f9fea442/uninames -------------------------------------------------------------------------------- /uniuni: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # vim: ft=sh: 3 | print -OaiC8 $( 4 | uninames "${@:-bracket}" \ 5 | | =grep -vP '[x#=*]' \ 6 | | awk '{print $1}' \ 7 | ) | perl -pe 's/^/ /' 8 | -------------------------------------------------------------------------------- /unlove: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | # abstract: unlove the currently playing song in mpd 4 | 5 | yes \ 6 | | ~/dev/beets/beet modify loved=0 "${XDG_MUSIC_DIR}$(mpc current --format %file% | head -1)" 7 | -------------------------------------------------------------------------------- /unpack: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # unpack script 3 | chmod +t,o+w $(pwd) 4 | find . -iname '*.rar' -execdir rar x {} $(pwd | perl -pe 's/^((?:\/[^\/]+){2}\/).*/$1/').temp/ \; 5 | mplayer -msgcolor -slave -input file=/home/scp1/.mplayer/fifo $(pwd | perl -pe 's/^((?:\/[^\/]+){2}\/).*/$1/').temp/* && rm $(pwd | perl -pe 's/^((?:\/[^\/]+){2}\/).*/$1/').temp/* 6 | # keep track of what I've seen 7 | echo $(basename $(pwd)) >> /mnt/Movies_1/.seen 8 | -------------------------------------------------------------------------------- /unpack_all: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | back=$(pwd) 3 | 4 | for x in $(find . -type f -iname '*.rar' -printf "%h\n" \ 5 | | perl -pe 's{^[.]/}{}' \ 6 | | sort -u); do 7 | $x=$(absname $x); 8 | cd $x && (unrar x *.rar && rm *.r*) 9 | done 10 | 11 | cd $back 12 | -------------------------------------------------------------------------------- /update_email: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | 4 | perl -pi -w -e 's/magnus\@trapd00r.se|trapd00r\@trapd00r.se/m\@japh.se/g;' * lib/**/*.pm 5 | -------------------------------------------------------------------------------- /updatesite: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | scp -P 19216 -r $HOME/dev/trapd00r.se/_genSite scp1@192.168.1.128:http/ 3 | -------------------------------------------------------------------------------- /upsidedown: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Text::UpsideDown; 4 | 5 | if(@ARGV) { 6 | print upside_down(@ARGV), "\n"; 7 | exit; 8 | } 9 | 10 | print upside_down($_), "\n" while <>; 11 | -------------------------------------------------------------------------------- /upstream: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Keep upstream up to date 3 | use Cwd qw(cwd); 4 | 5 | my $upstream = "$ENV{HOME}/bin/upstream"; 6 | 7 | my @projects = grep{ -d $_ } glob("$upstream/*"); 8 | 9 | chdir($upstream); 10 | 11 | for my $p(@projects) { 12 | if(-d "$p/.git") { 13 | chdir( $p ) and print "chdir $p\n"; 14 | system('git', qw(pull)); 15 | } 16 | elsif(-d "$p/.svn") { 17 | chdir( $p ) and print "chdir $p\n"; 18 | system('svn', qw(update)); 19 | } 20 | else { 21 | warn($p); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /uri: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use File::Find::Rule; 7 | use Regexp::Common qw(URI); 8 | 9 | my $dir = shift // '.'; 10 | 11 | my @f = grep{!/(?:blib|[.]git|cover_db)/} File::Find::Rule->file() 12 | ->in($dir); 13 | for my $file(@f) { 14 | my $seen = 0; 15 | open(my $fh, '<', $file) or die($!); 16 | while(<$fh>) { 17 | if($_ =~ m/($RE{URI}{HTTP})/) { 18 | $seen++; 19 | printf(" \e[3m%s\e[m\n", $file) unless($seen >= 2); 20 | printf("\e[38;5;85m% 4d\e[m: %s\n", $., $1); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /url_find: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: extracts URLs from data 4 | use strict; 5 | 6 | use Regexp::Common qw(URI); 7 | 8 | 9 | my $filter = shift; 10 | $filter = qr{$filter}; 11 | 12 | while(<>) { 13 | chomp $_; 14 | if($_ =~ m/($RE{URI})/) { 15 | my $uri = $1; 16 | if($filter) { 17 | if($uri =~ m/$filter/) { 18 | print "$uri\n"; 19 | } 20 | } 21 | else { 22 | print "$uri\n"; 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /v: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 1. Search for text in files using Ripgrep 4 | # 2. Interactively narrow down the list using fzf 5 | # 3. Open the file in Vim 6 | IFS=: read -ra selected < <( 7 | rg --color=always --line-number --no-heading --smart-case "${*:-}" | 8 | fzf --ansi \ 9 | --color "hl:-1:underline,hl+:-1:underline:reverse" \ 10 | --delimiter : \ 11 | --preview 'bat --color=always {1} --highlight-line {2}' \ 12 | --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' 13 | ) 14 | [ -n "${selected[0]}" ] && vim "${selected[0]}" "+${selected[1]}" 15 | -------------------------------------------------------------------------------- /vid2gif: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | convert -delay 1 "$1" "$1".gif 4 | -------------------------------------------------------------------------------- /vidir-open-untracked-git-files: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git status --untracked-files=normal --short | awk '{$1="";print}' | vidir - 4 | 5 | -------------------------------------------------------------------------------- /vidir_by_dirsize: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | # sort subdirectories in . by size, and open in vidir 4 | 5 | du -h --max-depth=1 "$@" \ 6 | | sort -k 1,1hr -k 2,2f \ 7 | | awk -F '\t' '{print $2}' \ 8 | | vidir - 9 | -------------------------------------------------------------------------------- /vim-bindings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use Data::Dumper; 5 | 6 | { 7 | package Data::Dumper; 8 | no strict 'vars'; 9 | $Terse = $Indent = $Useqq = $Deparse = $Sortkeys = 1; 10 | $Quotekeys = 0; 11 | } 12 | 13 | 14 | my $map = "$ENV{XDG_CONFIG_HOME}/vim/_mappings.vim"; 15 | 16 | open(my $fh, '<', $map) or die($!); 17 | 18 | my $m; 19 | while(<$fh>) { 20 | chomp; 21 | 22 | if($_ =~ m/^([cnv]no(?:remap))\s+(.+)/) { 23 | push(@{ $m->{$1} }, $2); 24 | } 25 | elsif($_ =~ m/^(map!?)\s+(.+)/) { 26 | push(@{ $m->{$1} }, $2); 27 | } 28 | } 29 | 30 | for my $k(sort(keys(%{ $m }))) { 31 | print "\n\n\e[34m>\e[m $k\n\n"; 32 | print join("\n ", @{ $m->{$k} }); 33 | } 34 | -------------------------------------------------------------------------------- /vim-time-fix-db: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: remove various non-file records from the vim-times db 4 | use strict; 5 | use Storable; 6 | 7 | 8 | my %h = %{ retrieve("$ENV{HOME}/.local/share/time_spent_in_vim.db") }; 9 | 10 | for my $k(keys(%h)) { 11 | if($k =~ m/^:?[sl]et/) { 12 | delete($h{$k}); 13 | } 14 | if($k =~ m/^-/) { 15 | delete($h{$k}); 16 | } 17 | if($k =~ m/^: ?/) { 18 | delete($h{$k}); 19 | } 20 | if($k =~ m/^http/) { 21 | delete($h{$k}); 22 | } 23 | if($k =~ m/bufdo/) { 24 | delete($h{$k}); 25 | } 26 | if($k =~ m/^\s+$/) { 27 | delete($h{$k}); 28 | } 29 | if($k eq '' or !$k or !defined($k)) { 30 | delete($h{$k}); 31 | } 32 | 33 | print "$k: $h{$k}\n"; 34 | } 35 | 36 | store(\%h, './time_spent_in_vim.db'); 37 | -------------------------------------------------------------------------------- /vim-writes-a-day: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # abstract: how many times a day do I type :w in vim? 3 | use strict; 4 | 5 | use POSIX qw(strftime); 6 | use Data::Dumper; 7 | 8 | my $writes_db = "$ENV{HOME}/vim_writes"; 9 | my $today = strftime "%Y-%m-%d", localtime; 10 | 11 | my %writes; 12 | 13 | open(my $fh, '<', $writes_db) or die $!; 14 | 15 | while(<$fh>) { 16 | chomp; 17 | $writes{$_}++; 18 | } 19 | 20 | printf "I have smashed \033[38;5;196;1;3m:w\033[m \033[38;5;32;1m%d\033[m times today in vim.\n", $writes{$today}; 21 | -------------------------------------------------------------------------------- /viml: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: open the most recently edited file in vim 3 | 4 | vim -c "normal '0" 5 | -------------------------------------------------------------------------------- /vimsyntax: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl: 3 | # abstract: generate html from vim syntax hl 4 | 5 | 6 | use strict; 7 | use Text::VimColor; 8 | use Getopt::Long; 9 | 10 | our ($optXML,$optColor, $optVimrc); 11 | $optColor = 'molokai'; 12 | $optVimrc = "$ENV{HOME}/.vimrc"; 13 | GetOptions(xml => \$optXML, 14 | colorscheme => \$optColor, 15 | vimrc => \$optVimrc, 16 | ); 17 | 18 | my $file = shift or die "Need file"; 19 | my $output = 'html'; 20 | if($optXML) { 21 | $output = 'xml'; 22 | } 23 | 24 | 25 | my @options = qw(-RXZ -i NONE -u NONE -N); 26 | my $vim = Text::VimColor->new( 27 | file => $file, 28 | html_full_page => 1, 29 | vim_options => \@options, 30 | ); 31 | 32 | 33 | 34 | 35 | 36 | print $vim->html; 37 | -------------------------------------------------------------------------------- /vol_down: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ossmix vmix0.pcm8 -- -2 4 | -------------------------------------------------------------------------------- /vol_up: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ossmix vmix0.pcm8 -- +2 4 | -------------------------------------------------------------------------------- /vr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | lynx -dump "$@" --nolist | /usr/bin/vim -R - 3 | -------------------------------------------------------------------------------- /vt52: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\e[?2t" 3 | -------------------------------------------------------------------------------- /vw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: format text properly and send it to vim 4 | 5 | /bin/cat "$@" \ 6 | | perl -MText::Autoformat -ne 'print autoformat($_, { left => 0, right => 72 })' \ 7 | | /usr/bin/vim -R -c ':set ft=_txt.txt' - 8 | -------------------------------------------------------------------------------- /warn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | warn "@ARGV\n"; 3 | -------------------------------------------------------------------------------- /we: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | vim ="$@" 3 | -------------------------------------------------------------------------------- /wf: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | file ="$@" 3 | -------------------------------------------------------------------------------- /wgetdarknet: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=zsh: 3 | # abstract: rip directory listing on darknet 4 | 5 | torsocks wget -r --no-parent "$@" 6 | -------------------------------------------------------------------------------- /whatfont: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh: 3 | # abstract: query the terminal for the current fonts in use. 4 | # it will only work in xterm compatible terminals. 5 | # urxvt note: you *must* have enabled frills *and* you must set the insecure 6 | # resource. xterm is 'insecure' by default. 7 | 8 | printf "\033]710;?\007"; xxd 9 | printf "\033]711;?\007"; xxd 10 | printf "\033]712;?\007"; xxd 11 | printf "\033]713;?\007"; xxd # urxvt boldItalic 12 | 13 | printf "\033]50;?\007"; xxd 14 | -------------------------------------------------------------------------------- /whatsmyip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # jackit++ 3 | 4 | curl http://jackit.se/ip.php 5 | -------------------------------------------------------------------------------- /whatthedev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Cwd qw(abs_path); 4 | 5 | my $mounted = { }; 6 | 7 | open(my $popen, '-|', 'mount') or die($!); 8 | 9 | while(<$popen>) { 10 | my($dev, $mp) = m{^(.+) on ([\w+/]+)}; 11 | 12 | $mounted->{ $mp } = $dev; 13 | } 14 | 15 | my $file = shift or die("File?\n"); 16 | 17 | for my $m(keys(%{ $mounted })) { 18 | if( abs_path($file) =~ m{($m)} and $m ne '/') { # FIXME 19 | print "$file is on $m ( $mounted->{$m} )\n"; 20 | last; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wifi-enable: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #killall NetworkManager 3 | #dhcpcd; ip link set wlo1 up; NetworkManager 4 | 5 | wpa_supplicant -i wlo1 -c /etc/wpa_supplicant/wpa_supplicant.conf 6 | NetworkManager 7 | -------------------------------------------------------------------------------- /wikipedia_over_dns: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Net::DNS; 4 | 5 | my $res = Net::DNS::Resolver->new; 6 | 7 | print wikipedia( @ARGV ? @ARGV : 'laleh' ), "\n"; 8 | 9 | sub wikipedia { 10 | my($name) = @_; 11 | my $q = $res->query("$name.wp.dg.cx", "TXT"); 12 | if($q) { 13 | for my $rr($q->answer) { 14 | next unless $rr->type eq "TXT"; 15 | return join "", $rr->char_str_list; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /winrarthemefetcher: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | r='http://rarlab.com' 4 | 5 | mkdir -p winrar;cd winrar 6 | wget $( \ 7 | for x in '' {2..4}; \ 8 | do curl -s $r/themes$x.htm | \ 9 | grep -Po '\/(.+theme\.rar)'| \ 10 | perl -pe "s;^;$r;"; \ 11 | done \ 12 | ) 13 | -------------------------------------------------------------------------------- /workdays: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use POSIX 'mktime'; 3 | 4 | my ( $mon, $year ) = (localtime)[4,5]; 5 | my $total = 0; 6 | 7 | for( my $day = 1; ; $day++ ) { 8 | my @t = localtime(mktime(0,0,0, $day, $mon, $year)); 9 | last if $t[4] > $mon; 10 | $total++ if $t[6] >= 1 and $t[6] <= 6; 11 | } 12 | print "Total of $total working days this month\n" 13 | 14 | -------------------------------------------------------------------------------- /wp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # wp 3 | use strict; 4 | use warnings; 5 | 6 | my %users = (); 7 | 8 | for(`who`) { 9 | s/\s.*\n//; 10 | $users{$_}++; 11 | } 12 | 13 | print " Logged in users:\n"; 14 | for(sort(keys(%users))) { 15 | if($_."\n" eq `whoami`) { 16 | $_ = "\033[1m$_\033[0m"; 17 | } 18 | print "$_\n"; 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /wrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Text::Autoformat; 4 | 5 | while(<>) { 6 | print autoformat($_, { left => 2, right => 80, justify => 'left' }); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /wtc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # wtc - get random retarded commit msgs 3 | use strict; 4 | use LWP::Simple; 5 | 6 | for(get('http://whatthecommit.com/')) { 7 | if(m;

(.+)\n

;) { 8 | print $1,"\n"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /wup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ifconfig wlan0 up 3 | wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf 4 | sleep 10 5 | dhcpcd wlan0 6 | 7 | -------------------------------------------------------------------------------- /x11-remote: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | use X11::GUITest qw( 5 | StartApp 6 | WaitWindowViewable 7 | SendKeys 8 | QuoteStringForSendKeys 9 | ); 10 | 11 | StartApp('xterm -T foobar'); 12 | if(! WaitWindowViewable('foobar') ) { 13 | die("Couldn't find window\n"); 14 | } 15 | 16 | SendKeys("perl $0\n"); 17 | -------------------------------------------------------------------------------- /xbox2ps4: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:ft=sh:et: 3 | 4 | # 'You must run the following command to allow ds4drv access to 5 | # uinput:\nudevadm control --reload-rules; rmmod uinput; modprobe 6 | # uinput\nAlso, on some systems it may be necessary for you to force the 7 | # uinput module to load at boot, as follows:\necho \"uinput\" > /etc/modules- 8 | # load.d/uinput.conf' 9 | 10 | udevadm control --reload-rules; rmmod uinput; modprobe uinput 11 | ds4drv --hidraw --emulate-xpad 12 | -------------------------------------------------------------------------------- /xdgdirs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # vim:ft=perl:et: 3 | # abstract: check that XDG_* dirs are defined 4 | use strict; 5 | 6 | # show defined XDG dirs 7 | 8 | 9 | my @xdg = qw( 10 | XDG_CACHE_HOME 11 | XDG_DESKTOP_DIR 12 | XDG_MUSIC_DIR 13 | XDG_RUNTIME_DIR 14 | XDG_TEMPLATES_DIR 15 | XDG_CONFIG_HOME 16 | XDG_DOCUMENTS_DIR 17 | XDG_PICTURES_DIR 18 | XDG_VIDEOS_DIR 19 | XDG_DATA_HOME 20 | XDG_DOWNLOAD_DIR 21 | XDG_PUBLICSHARE_DIR 22 | ); 23 | 24 | my $missing; 25 | for my $x(sort(@xdg)) { 26 | $missing = (-d $ENV{$x} ? '' : "\033[48;5;196;38;5;187mENOEXIST\033[m"); 27 | printf "%20s: %s %s\n", $x, $ENV{$x}, $missing; 28 | } 29 | -------------------------------------------------------------------------------- /xmodshit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $(ps aux | grep -c zsh) -lt 5 ]; then 4 | setsid urxvt -name URxvt.$HOSTNAME -e zsh -c \ 5 | "xmodmap -e 'clear Lock' \ 6 | -e 'keycode 0x42 = Escape' \ 7 | -e 'keycode 0x30 = apostrophe' \ 8 | -e 'keycode 0x2f = asterisk'; \ 9 | -e 'keycode 0xe5 = slash; \ 10 | exec zsh" 11 | else 12 | xmodmap -verbose -e 'clear Lock' 13 | xmodmap -verbose -e 'keycode 0x42 = Escape' 14 | xmodmap -verbose -e 'keycode 0x30 = apostrophe' 15 | xmodmap -verbose -e 'keycode 0x2f = asterisk' 16 | xmodmap -verbose -e 'keycode 0x22 = slash' 17 | fi 18 | -------------------------------------------------------------------------------- /xonotic-map-downloader.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | 5 | use utf8; 6 | use open qw(:std :utf8); 7 | 8 | use DDP; 9 | use v5.30; 10 | 11 | use Mojo::DOM; 12 | use Mojo::UserAgent; 13 | 14 | my $base_url = 'http://dl.xonotic.fps.gratis/'; 15 | my $map_dir = "$ENV{HOME}/Xonotic_old/data"; 16 | 17 | my $ua = Mojo::UserAgent->new; 18 | 19 | my $dom = Mojo::DOM->new($ua->get($base_url)->result->body); 20 | 21 | my %pk3 = map { $_ => "${base_url}$_" } $dom->find('a')->map(attr => 'href')->each; 22 | 23 | for my $pk3 (keys %pk3) { 24 | my $file = "$map_dir/$pk3"; 25 | next if -e $file; 26 | say "Downloading $pk3"; 27 | $ua->get($pk3{$pk3})->result->save_to($file); 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /xresources_dump: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Term::ExtendedColor::Xresources qw(get_xterm_color); 4 | 5 | my $c = get_xterm_color({ 6 | index => [0 .. 255], 7 | type => 'hex', 8 | }); 9 | 10 | my $prefix = shift // 'URxvt.shiva'; 11 | 12 | for my $index(0 .. 255) { 13 | printf("%s.color%s: #%s\n", $prefix, $index, $c->{$index}->{rgb}); 14 | } 15 | -------------------------------------------------------------------------------- /xterm-blinkenlights: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This requires an xterm compatible terminal (like... xterm) 3 | 4 | while true; do 5 | xset led 6 | printf "\e[1;q" 7 | perl -e 'select(undef, undef, undef, rand(1))' 8 | done 9 | -------------------------------------------------------------------------------- /xterm-cycle_colormap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | 5 | # move color definition to index -1 6 | # works in urxvt and xterm compatible terminals 7 | 8 | use Term::ExtendedColor::Xresources qw(get_xterm_color set_xterm_color); 9 | 10 | my $existing = get_xterm_color( 11 | { 12 | index => [0 .. 255], 13 | type => 'hex', 14 | }, 15 | ); 16 | 17 | 18 | for my $index(keys(%{ $existing })) { 19 | my $previous = $index -1; 20 | $previous = 255 if $previous == -1; 21 | 22 | set_xterm_color( 23 | { 24 | $previous => $existing->{$index}->{rgb}, 25 | }, 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /xterm-paste.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings FATAL => 'all'; 4 | 5 | # OSC 52 . Only works in xterm so far... 6 | printf "\e]52;?\e\\"; 7 | -------------------------------------------------------------------------------- /youtube: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ssh -X scp1@rambo 'clive --exec "mplayer -vo x11 -fs %f" "$@"' 3 | -------------------------------------------------------------------------------- /youtube-dl-channel: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # created for mirroring Rosa Mannen 3 | 4 | youtube-dl --download-archive downloaded.txt -i -o "%(uploader)s/%(upload_date)s - %(title)s - (%(duration)ss) [%(resolution)s].%(ext)s" -f bestvideo[ext=mp4]+bestaudio "$@" 5 | 6 | -------------------------------------------------------------------------------- /youtube-extract: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | grake "$@" 4 | -------------------------------------------------------------------------------- /youtube-getfavs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | umph -m 50 -t f "$@" 4 | -------------------------------------------------------------------------------- /youtube-getplaylist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cclive -qbc --agent 'Mozilla/5.0' --max-retries 2 $(umph -a "$@") 4 | -------------------------------------------------------------------------------- /youtube-getuservideos: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | umph -m 50 -t u "$@" 4 | -------------------------------------------------------------------------------- /youtube2mp3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # abstract: rip audio from youtube 3 | 4 | youtube-dl -i --extract-audio --audio-format mp3 "$1" 5 | -------------------------------------------------------------------------------- /youtube_sanitize: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | s/&.*// and print while <>; 4 | -------------------------------------------------------------------------------- /yt-dlp2mp3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yt-dlp \ 3 | --ignore-errors \ 4 | --format bestaudio \ 5 | --extract-audio \ 6 | --audio-format mp3 \ 7 | --audio-quality 192K \ 8 | --output "%(title)s.%(ext)s" \ 9 | --add-metadata \ 10 | --yes-playlist "$@" 11 | 12 | 13 | -------------------------------------------------------------------------------- /öl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | printf "\033]710;%s\007" "xft:fixed:pixelsize:0" 3 | curl -s https://gist.githubusercontent.com/trapd00r/2a405a890605c49a8e65dbd9604dd59f/raw/43180288f24ac44d058b1309be8eb60adbe1283a/mariestad.txt | cat 4 | --------------------------------------------------------------------------------