Skip to content

Instantly share code, notes, and snippets.

@vividsnow
vividsnow / soundcloud-term
Created Nov 30, 2021
terminal app to soundcloud personal stream (play, pause, forward, like, unlike, open in browser..). uses mpv
View soundcloud-term
#!/usr/bin/env perl
use utf8; use strict; use warnings;
use Getopt::Std 'getopt';
use HTTP::Tiny; use JSON::PP;
use IO::Uncompress::Gunzip 'gunzip';
use Socket qw'AF_UNIX SOCK_STREAM PF_UNSPEC';
use List::Util qw'min max';
use Encode::Locale;
use POSIX 'setsid';
View share-via-nginx
#!/usr/bin/env perl
use strict; use utf8; use warnings; use autodie ':all';
use File::Temp qw'tempfile tempdir';
use Getopt::Std 'getopts';
use Cwd 'cwd';
use File::Spec::Functions qw'catfile rel2abs';
my %o = (qw'l 0:4321 -d', cwd);
getopts 'l:d:u:p:h', \%o;
View gist:1380125
Use of uninitialized value in substitution (s///) at /home/f2r/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/PocketIO/Message.pm line 55.
Use of uninitialized value in string eq at /home/f2r/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/PocketIO/Message.pm line 66.
Use of uninitialized value in string eq at /home/f2r/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/PocketIO/Message.pm line 66.
Use of uninitialized value in hash element at /home/f2r/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/PocketIO/Message.pm line 87.
Use of uninitialized value in string eq at /home/f2r/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/PocketIO/Message.pm line 90.
Use of uninitialized value in string eq at /home/f2r/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/PocketIO/Message.pm line 93.
Use of uninitialized value in string eq at /home/f2r/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/PocketIO/Message.pm line 93.
Use of uninitialized value in string eq at /home/f2r/perl5/
@vividsnow
vividsnow / debootstrap.md
Created Jun 26, 2018 — forked from tr3buchet/debootstrap.md
debian usb debootstrap
View debootstrap.md

make sure any needed utilities are installed

sudo aptitude install debootstrap coreutils util-linux e2fsprogs

get usb device

df -h
@vividsnow
vividsnow / desktop-load-theme.el
Created May 27, 2015
emacs load-theme desktop-mode
View desktop-load-theme.el
(desktop-save-mode)
(add-to-list 'desktop-globals-to-save 'custom-enabled-themes)
(defun desktop-load-theme () "load custom theme" (interactive)
(dolist (th custom-enabled-themes) (load-theme th)))
(add-hook 'desktop-after-read-hook 'desktop-load-theme)
@vividsnow
vividsnow / torium.pl
Last active Oct 9, 2017
multiple tor runner
View torium.pl
use strict; use warnings;
use File::Temp qw'tempfile tempdir'; use File::Spec::Functions 'catfile';
use Symbol 'geniosym'; use Socket; use Net::EmptyPort 'empty_port'; use Getopt::Std;
my %in = (qw'h 127.0.0.1 p 5498 n 4'); getopts('p:n:', \%in);
print "torium[$$] listens $in{p}\n";
my @children;
@vividsnow
vividsnow / rounded.pl
Created Jul 27, 2017
imager rounded corner mask with transparency
View rounded.pl
sub rounded_mask {
my ($img, $rad) = @_;
state $ss = 4; # subsample smooth
my $srad = int $rad*$ss;
my $corner = Imager->new(xsize => $srad, ysize => $srad, channels => 1)
->arc(qw'x 0 y 0 d1 0 d2 90', r => $srad - $ss/2)
->scale(scalefactor => 1/$ss);
my ($w, $h) = ($img->getwidth, $img->getheight);
my $mask = Imager->new(xsize => $w, ysize => $h, channels => 1);
$mask->box(box => [$rad, 0, $w - 1 - $rad, $h - 1], filled => 1);
@vividsnow
vividsnow / pdfshot.pl
Last active Dec 24, 2015
perl html to pdf printer using gtk3 bindings
View pdfshot.pl
# example usage: xvfb-run -a -s '-screen 0, 34x34x24' perl pdfshot.pl OUTFILE URL [ WAIT]
use v5.16;
use Gtk3 -init;
use Gtk3::WebKit;
(my $view = Gtk3::WebKit::WebView->new)->set_transparent(Glib::FALSE);
(my $window = Gtk3::OffscreenWindow->new)->add($view);
$view->signal_connect('notify::load-status' => sub { if ($view->get_uri && $view->get_load_status eq 'finished') {
Glib::Timeout->add( $ARGV[2] // 5, sub {
$view->get_main_frame->print_full((map {
@vividsnow
vividsnow / scratch.pl
Created May 17, 2013
random stuff from live coding session using https://github.com/vividsnow/perl-live
View scratch.pl
# some handy modules to print things
use Data::Dump 'dd';
use DDP colored => 1, filters => { -external => [ 'PDL' ] };
dd my $h = bless { a => 1 }, 'test';
p $h
# ok - lets test scoping
say my $v = 0;
@vividsnow
vividsnow / sctweets.pl
Created May 15, 2012
recent supercollider tweets
View sctweets.pl
#!/bin/env perl
use v5.12;
use HTTP::Tiny();
use JSON::XS();
use Try::Tiny;
use HTML::Entities 'decode_entities';
my @search_words = ('#supercollider', '#sc140', '#sc', qw(
Ndef Tdef Pbind SinOsc PMOsc LFSaw LFPulse Splay Pan2 LFNoise0 LFNoise1 LFNoise2 LFCub LFPar
LFTri Drand Ringz Dshuf Decay2 DelayN DelayL DelayC CombC GVerb FreeVerb VarSaw DynKlank DynKlang