Skip to content

Instantly share code, notes, and snippets.

View petdance's full-sized avatar

Andy Lester petdance

View GitHub Profile
#!/usr/bin/perl
use warnings;
use strict;
use Cwd;
use File::Spec;
my @viminfo_candidates = glob( '~/.viminfo' );
--- Syntax items ---
podCmdText xxx match /.*$/ contained contains=podFormat,@NoSpell
match /.*$/ contained contains=podFormat,podBold,podBoldAlternativeDelim,podItalic,podItalicAlternativeDelim,@NoSpell
links to String
podCommand xxx match /^=encoding/ contained contains=@NoSpell nextgroup=podCmdText
match /^=head[1234]/ contained contains=@NoSpell nextgroup=podCmdText
match /^=item/ contained contains=@NoSpell nextgroup=podCmdText
match /^=over/ contained contains=@NoSpell nextgroup=podOverIndent skipwhite
@petdance
petdance / gist:3c500d913d059ee16437c11a07d6fb6d
Last active March 14, 2017 16:29
SQL breaks Perl highlighting
#!/var/perl/bin/perl
my $sql =<<'SQL';
insert into foo values (
-- Add any letter to any of the four words below and the Perl highlighting breaks.
create,
update,
select,
insert,
)
$ cat ~/.vim/after/syntax/perl.vim
" ~/.vim/after/syntax/perl.vim
let s:bcs = b:current_syntax
unlet b:current_syntax
syntax include @SQL syntax/sql.vim
let b:current_syntax = s:bcs
syntax region perlHereDocSQL start=+<<['"]SQL['"].*;\s*$+ end=+^SQL$+ contains=@SQL
syntax region perlHereDocSQL start=+<<['"]SQL_TEXT['"].*;\s*$+ end=+^SQL_TEXT$+ contains=@SQL
syntax region perlHereDocSQL start=+<<['"]__SQL__['"].*;\s*$+ end=+^__SQL__$+ contains=@SQL
# How to make things unhappy.
#
# 1. Go to the end of the file. Open the editor so that your cursor is on the last line of the file.
#
# 2. Scroll up until the "Scroll up so that..." is the top line. Everything is OK.
#
# 3. Scroll up two lines. Everything goes white.
#
# 4. Scroll up three more lines. Everything is now confused by the single quote in the POD.
#
@petdance
petdance / keybase.md
Created March 28, 2017 05:40
keybase.md

Keybase proof

I hereby claim:

  • I am petdance on github.
  • I am petdance (https://keybase.io/petdance) on keybase.
  • I have a public key ASBIbfOjRA_8NyVM6mryZoyn8NfMraD1Jlb6GfYNjQdOago

To claim this, I am signing this object:

Site-admin/browse.t
676: ok( $fschool->is_following($user), 'User follows its own school' );
677: ok( $fschool->is_tchecking($user), 'User tchecks its own school' );
681: ok( !$another_school->is_following($user), 'User not following another school' );
682: ok( !$another_school->is_tchecking($user), 'User not tchecking another school' );
705: ok( !$fschool->is_following($user), 'User stopped following its own school' );
706: ok( !$fschool->is_tchecking($user), 'User stopped tchecking its own school' );
709: ok( $another_school->is_following($user), 'User now following another school' );
710: ok( $another_school->is_tchecking($user), 'User now tchecking another school' );
736: ok( $fschool->is_following($user), 'User now following school' );
@petdance
petdance / gist:dc0f1bf9c14c4aa4995ebdf7fa8cd2a7
Last active April 19, 2017 02:17
What do we call the clumping?
$ ./ack-standalone some t/text --clump
t/text/boy-named-sue.txt
11:Some gal would giggle and I'd turn red
12:And some guy'd laugh and I'd bust his head,
t/text/science-of-myth.txt
10:Somehow no matter what the world keeps turning
11:Somehow we get by without ever learning
21:'cause some things are better left without a doubt
@petdance
petdance / gist:7c44793015b58c110a75c7b75f4d49b6
Created April 20, 2017 14:28
dirty, a shell script for showing modified files whether under Git or Subversion.
#!/usr/bin/perl
use warnings;
use strict;
# Try Git.
my @lines = qx{git diff --name-only 2> /dev/null};
if ( $? == 0 ) {
print for @lines;
exit 0;
defmodule Euler003 do
# http://projecteuler.net/index.php?section=problems&id=3
# The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?
def largest_prime_factor( n ) do
factors = prime_factors( n )
[largest|_] = factors
IO.write 'Prime factors are '