Skip to content

Instantly share code, notes, and snippets.

@niczero
niczero / git-migrate.sh
Created November 11, 2015 14:28
Extract a subtree of git repo to make a new repo
# Want to remove all reference to lib/* except lib/Minion/Backend/*
git filter-branch --tag-name-filter cat \
--index-filter 'git rm --cached -qr -- lib && git reset -q $GIT_COMMIT -- lib/Minion/Backend t' \
--prune-empty \
-- --all
@niczero
niczero / build_percona.md
Last active November 19, 2015 13:25
How to build and patch Percona's MySQL on Debian

Download

wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0-1.debian.tar.gz
wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0-1.dsc
wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0-1_source.changes
wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0.orig.tar.gz
apt-get --only-source build-dep percona-server-5.6
dpkg-source -x percona-server-5.6_5.6.27-75.0-1.dsc
cd percona-server-5.6-5.6.27-75.0
@niczero
niczero / word-parse.pl
Created November 23, 2015 10:17 — forked from ingydotnet/word-parse.pl
Parse words from a string of smushed together words with a single regexp
#!/usr/bin/env perl
use strict;
# Get all the letters from stdin:
my $input = do {local $/; <>};
$input =~ s/[^a-zA-Z]//g;
# All 3+ letter English words, longest to shortest:
my @long = grep {length > 2}
sort {length $b <=> length $a}
@niczero
niczero / testing_templates.sh
Created November 25, 2015 10:55
Testing Mojo::Template
MOJO_TEMPLATE_DEBUG=1 perl -Mojo -E'my $c = app->build_controller; $c->render_to_string(inline => "")'
@niczero
niczero / tcpdump.md
Created December 2, 2015 12:33
Sniffing with tcpdump

Capturing tcp connections into the telnet port

tcpdump -i eth0 -nnvvSX -s1514 tcp and dst port 23 -w/tmp/x/tcp
@niczero
niczero / Tail.pm
Last active December 3, 2015 14:00
Tail a log via WebSocket or EventSource
package Mojo::IOLoop::Tail;
use Mojo::EventEmitter -base;
our $VERSION = 0.001;
use IO::File;
use Mojo::IOLoop;
has ioloop => sub { Mojo::IOLoop->singleton };
has name => 'log';
@niczero
niczero / index.html
Created December 8, 2015 09:37 — forked from anonymous/index.html
Bootstrap 3 responsive columns of same height Bootstrap 3 responsive columns of same height // source http://jsbin.com/xokerexola
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bootstrap 3 responsive columns of same height</title>
<meta name="description" content="Bootstrap 3 responsive columns of same height">
<!-- include bootstrap -->
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<style id="jsbin-css">
/* USAGE
@niczero
niczero / build-hplip.md
Created January 14, 2016 15:03
Backporting for debian via uupdate

You start with the debian source package from your current release and merge that with the new upstream tarball (or one downloaded from sid). This relies upon a degree of luck -- whether the new tarball will build if dropped into the older packaging scripts -- so don't trust the resulting deb files inappropriately.

apt-get install devscripts
cd /usr/src
apt-get build-dep hplip
apt-get source hplip
cd hplip-3.14.6
uupdate /tmp/hplip-3.15.11.tar.gz
@niczero
niczero / linktester.pl
Created June 10, 2016 13:20
Check for dead links recursively on a page
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::UserAgent;
my $base = shift or die "Usage: $0 http://example.com/foo/bar\n";
my @queue = ([$base = Mojo::URL->new($base)]);
my $ua = Mojo::UserAgent->new;
my %info;
@niczero
niczero / rebus-minion.sh
Created June 10, 2016 13:21 — forked from mrenvoize/rebus-minion.sh
init.d script for starting multiple minion workers (Mojolicious)
#!/bin/bash
### BEGIN INIT INFO
# Provides: rebus-minion
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Provides Minion Workers for rebus:list jobs
# Description: This script with start/stop minion worker