Skip to content

Instantly share code, notes, and snippets.

View Ovid's full-sized avatar

Ovid Ovid

View GitHub Profile
@Ovid
Ovid / find_duplicate_code.pl
Created December 7, 2012 08:47
Find Duplicate Code in Perl (a hack)
#!/usr/bin/env perl
use 5.12.0;
use autodie;
use Carp;
use utf8::all;
use File::Spec::Functions qw(catfile catdir);
use File::Find::Rule;
use Getopt::Long;
use Capture::Tiny qw(capture);
@Ovid
Ovid / gist:4232050
Created December 7, 2012 09:18
Sample "dupe code detection" in DBIx::Class
#Possible match (lib/DBIx/Class/ResultSet.pm near line 936) (lib/DBIx/Class/Relationship/Base.pm near line 512)
#Begining at:
} | }
sub search_related { | sub search_related {
return shift(@_)->related_resultset(shift @_)->search(@_); | return shift(@_)->related_resultset(shift @_)->search(@_);
} | }
sub search_related_rs { | sub search_related_rs {
return shift(@_)->related_resultset(shift @_)->search_rs(@_); | return shift(@_)->related_resultset(shift @_)->search_rs(@_);
} | }
@Ovid
Ovid / provediff.pl
Created December 26, 2012 09:56
A simple way of seeing if one .prove file has different test results from another (used with "prove --state=save")
#!/usr/bin/env perl
use Modern::Perl;
use App::Prove::State;
my ( $prove1, $prove2 ) = @ARGV;
unless ( -f $prove1 and -f $prove2 ) {
die "Pass .prove files, please";
}
@Ovid
Ovid / gist:4971571
Last active December 13, 2015 20:38
Red-black binary tree insertion in Perl 6
enum RedBlack <R B>;
multi balance(B,[R,[R,$a,$x,$b],$y,$c],$z,$d) {
[R,[B,$a,$x,$b],$y,[B,$c,$z,$d]]
}
multi balance(B,[R,$a,$x,[R,$b,$y,$c]],$z,$d) {
[R,[B,$a,$x,$b],$y,[B,$c,$z,$d]]
}
multi balance(B,$a,$x,[R,[R,$b,$y,$c],$z,$d]) {
[R,[B,$a,$x,$b],$y,[B,$c,$z,$d]]
@Ovid
Ovid / gist:4971599
Created February 17, 2013 13:59
Reformatted for for red-black tree in Perl 6
enum RedBlack <R B>;
sub MAIN {
my $tree = Any;
for (1..10).pick(*) -> $node {
$tree = insert($node, $tree);
printf "%2d: %s\n", $node, $tree.perl;
}
}
@Ovid
Ovid / gist:4971602
Created February 17, 2013 14:00
Red-black tree output
8: [RedBlack::B, Any, 8, Any]
6: [RedBlack::B, [RedBlack::R, Any, 6, Any], 8, Any]
4: [RedBlack::B, [RedBlack::B, Any, 4, Any], 6, [RedBlack::B, Any, 8, Any]]
7: [RedBlack::B, [RedBlack::B, Any, 4, Any], 6, [RedBlack::B, [RedBlack::R, Any, 7, Any], 8, Any]]
9: [RedBlack::B, [RedBlack::B, Any, 4, Any], 6, [RedBlack::B, [RedBlack::R, Any, 7, Any], 8, [RedBlack::R, Any, 9, Any]]]
3: [RedBlack::B, [RedBlack::B, [RedBlack::R, Any, 3, Any], 4, Any], 6, [RedBlack::B, [RedBlack::R, Any, 7, Any], 8, [RedBlack::R, Any, 9, Any]]]
2: [RedBlack::B, [RedBlack::R, [RedBlack::B, Any, 2, Any], 3, [RedBlack::B, Any, 4, Any]], 6, [RedBlack::B, [RedBlack::R, Any, 7, Any], 8, [RedBlack::R, Any, 9, Any]]]
1: [RedBlack::B, [RedBlack::R, [RedBlack::B, [RedBlack::R, Any, 1, Any], 2, Any], 3, [RedBlack::B, Any, 4, Any]], 6, [RedBlack::B, [RedBlack::R, Any, 7, Any], 8, [RedBlack::R, Any, 9, Any]]]
5: [RedBlack::B, [RedBlack::R, [RedBlack::B, [RedBlack::R, Any, 1, Any], 2, Any], 3, [RedBlack::B, Any, 4, [RedBlack::R, Any, 5, An
@Ovid
Ovid / gist:11038984
Last active August 29, 2015 14:00
Fetching Email Threads in Veure
SELECT thread.*
FROM email thread
JOIN email selected ON selected.email_thread_id = thread.email_thread_id
JOIN character recipient ON recipient.character_id = thread.recipient_id
JOIN station_area sa ON sa.station_area_id = recipient.station_area_id
JOIN station st ON st.station_id = sa.station_id
JOIN star origin ON origin.star_id = thread.sender_star_id
JOIN star destination ON destination.star_id = st.star_id
LEFT JOIN route
ON ( route.from_id = origin.star_id AND route.to_id = destination.star_id )
@Ovid
Ovid / vawa.vim
Created May 16, 2014 15:30
Perl Vim Variable highlighting
" Drop this into .vim/plugin.vawa.vim
" if you already have vawa.vim, rename appropriately
" automatically highlights variables under cursor, allowing you to easily see the data flow.
" Vawa Plugin for VIM > 7.3 version 1.00
" Maintainer: Sandeep.c.r<[email protected]>
" Hacked for Perl by Curtis "Ovid" Poe <[email protected]>
function! s:vawa()
call clearmatches()
@Ovid
Ovid / gist:0674ef8fe906f10cc8f2
Created July 5, 2014 18:43
Procedural quest generation
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
use Getopt::Long;
use Data::Dumper;
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: