Skip to content

Instantly share code, notes, and snippets.

View creaktive's full-sized avatar
👽
🛸

Stanislaw Pusep creaktive

👽
🛸
View GitHub Profile
@creaktive
creaktive / j.pl
Created May 19, 2011 17:37
"j" impresso com "X"
#!/usr/bin/perl
use common::sense;
sub circ {
my ($a, $b, $r, $h, $w) = @_;
for my $y (0 .. $h) {
for my $x (0 .. $w) {
my $z = (($x - $a)**2 + ($y - $b)**2) / ($r**2);
print(($z >= 0.9 && $z <= 1.1) ? 'X' : ' ');
}
# http://en.wikipedia.org/wiki/Sign_function
sub sgn {
return sprintf('%.0f', $_[0] / sqrt($_[0] ** 2 + 0.00001));
}
@creaktive
creaktive / update-local-lib.sh
Created May 24, 2011 01:07
local::lib update
#!/bin/sh
perl -MExtUtils::Installed -E 'chdir $ENV{PERL_LOCAL_LIB_ROOT}; my $i = new ExtUtils::Installed; say for $i->modules' | cpanm
@creaktive
creaktive / gist:1005393
Created June 2, 2011 21:42
Perl Command Line
perl -MO=Concise x.pl
perl -MO=Deparse x.pl
perl -Mcommon::sense -MDevel::REPL -e 'Devel::REPL->new->run'
@creaktive
creaktive / gist:1006663
Created June 3, 2011 16:46
My Devel::REPL repl.rc
#!/usr/bin/perl
use common::sense;
use lib 'lib';
use open ':locale';
use lexicals;
use Data::Dumper;
use Data::Printer;
use Digest::MD5 qw(md5_hex md5_base64);
@creaktive
creaktive / named-list.pl
Created June 5, 2011 22:23
list named A & CNAME records
perl -MFile::Basename '-F/\t/' -ane 'if ($F[3] =~ /^(A|CNAME)$/) { my $d = $F[0] . "." . (fileparse($ARGV, ".db"))[0]; $d =~ s/^.*\.\.//; print "$d\t$F[4]" unless $F[4] =~ /\b127\.0\.0\.1\b/ }' /var/named/*.db
@creaktive
creaktive / .bashrc
Created June 17, 2011 19:08
readline vi
set -o vi
# ^p check for partial match in history
bind -m vi-insert "\C-p":dynamic-complete-history
# ^n cycle through the list of partial matches
bind -m vi-insert "\C-n":menu-complete
# ^l clear screen
bind -m vi-insert "\C-l":clear-screen
@creaktive
creaktive / teste.pl
Created July 1, 2011 20:25
WWW::Mechanize::Firefox + Flash
#!/usr/bin/perl
use common::sense;
use Benchmark;
use WWW::Mechanize::Firefox;
my $mech = new WWW::Mechanize::Firefox;
$mech->allow(
javascript => 1,
metaredirects => 1,
@creaktive
creaktive / delta.sh
Created July 25, 2011 13:43
MacPorts + Lion fixes
#!/bin/sh
port list active | cut -c-31 | sort -u > ports.now
grep -v -F -f ports.now ports.old | grep -v '^p5' | tr -d ' '
MULTILINESTRING(
(A,B,C,D,E),
(F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U),
(F,G,H,I,J,K,L,M,N,V,W,X,Y,Z),
(U,T,S,R,Q,P,O,N,V,W,X,Y,Z)
)