Skip to content

Instantly share code, notes, and snippets.

@Altreus
Altreus / template.pl
Created October 5, 2015 10:51
Pipe to this to do a quick template (with {{ }} delimiters)
#!/usr/bin/env perl
use strict;
use warnings;
use Text::Template 'fill_in_file';
use 5.010;
my $template = shift;
my @content = <>;
say fill_in_file($template,
@Altreus
Altreus / gist:0bee9624daf3a76f1044
Last active December 2, 2015 14:06
Unzip with splurge protection
function sunzip() {
unzip -l "$1" | \
head -n -2 | \
tail -n +4 | \
perl -lnE'$dirs{((split " ")[3] =~ m!([^/]*)!)[0]}++ } { exit 1 if keys %dirs > 1'
if [[ "$?" -eq "0" ]]; then
unzip "$1"
else
EXDIR="${1/%.zip/}"
perl -Ilib -MTest::WWW::Mechanize::Roles -MTest::WWW::Mechanize::Roles::JSON -E'package J; use Moose; extends "Test::WWW::Mechanize::Roles"; with "Test::WWW::Mechanize::Roles::JSON"; package main; my $j = J->new; $j->json_ok'
[alias]
lg = log --graph --decorate --branches --oneline --remotes --tags --all
st = status
co = checkout
ci = commit
cdiff = diff --cached
yoink = cherry-pick
[status]
submodulesummary = true
#!/usr/bin/env perl
use strict;
use warnings;
use 5.014;
use Getopt::Long qw(:config gnu_getopt);
use App::Multigit qw(mg_each);
use Path::Class;
use Future;
<StreamWriter(gpgi-output(gpg --status-fd=2 --passphrase-fd=0 --no-use-agent --enable-progress-filter --batch --verbose --with-colons --utft
<StreamWriter(gpgi-output(gpg --status-fd=2 --passphrase-fd=0 --no-use-agent --enable-progress-filter --batch --verbose --with-colons --utft
Traceback (most recent call last):
File "/Mailpile/mailpile/crypto/gpgi.py", line 442, in writeout
fd.write(line)
IOError: [Errno 32] Broken pipe
Traceback (most recent call last):
File "/Mailpile/mailpile/crypto/gpgi.py", line 442, in writeout
fd.write(line)
IOError: [Errno 32] Broken pipe
#!/bin/bash
OUT=`basename "$PWD"`.avi
BITRATE=10000000
RATIO=1920:1080
# x264 main profile, veryfast cpu, lossless, level is kinda like version
# -preset veryfast -qp 0
# 60fps, keyframe every 2s
ffmpeg -i "$3" -i "$4" \
-map 0:v -map 1:a \
:: @ECHO OFF
for %%i in ("%cd%") do SET OUT="%%~nxi"
SET BITRATE="10000000"
SET RATIO="1920:1080"
:: x264 main profile, veryfast cpu, lossless, level is kinda like version
:: -preset veryfast -qp 0
:: 60fps, keyframe every 2s
ffmpeg -loglevel panic -i %3 -i %4 -map 0:v -map 1:a -vb %BITRATE% -minrate %BITRATE% -maxrate %BITRATE% -bufsize %BITRATE% -aspect %RATIO% -s %RATIO% -c:v libx264 -profile:v main -level 3.1 -r 60 -g 120 -keyint_min 120 -x264opts "keyint=120:min-keyint=120:no-scenecut" -c:a aac -ab 48000 -ac 2 -f avi -ss %1 -to %2 %OUT%.avi

Keybase proof

I hereby claim:

  • I am altreus on github.
  • I am altreus (https://keybase.io/altreus) on keybase.
  • I have a public key whose fingerprint is 07B0 0E86 E59F B24B F807 C5C8 49F3 45C1 1751 8986

To claim this, I am signing this object:

@Altreus
Altreus / gist:e693f739227806f8cf02bf898724cb95
Created April 18, 2018 15:30
Update Perl modules so package line matches path
find lib -name '*.pm' | xargs perl -pi -E'(s{^package \K.*;$}{join("::", split "/", ($ARGV =~ s!lib/|\.pm!!gr)) . ";"}e and $seen{$ARGV}++) unless $seen{$ARGV}'