Skip to content

Instantly share code, notes, and snippets.

View cfedde's full-sized avatar

Chris Fedde cfedde

  • Loud Noise System Services
View GitHub Profile
#!/usr/bin/env perl
use Modern::Perl;
use autodie;
my $x;
open my $f, "<", $ARGV[0];
seek $f, $ARGV[1], 0;
@cfedde
cfedde / gist:5086715
Created March 4, 2013 23:47
for thumbs on #apache
/usr/sbin/apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server crf.example.com (/etc/httpd/conf.d/vhostcrf.conf:1)
port 80 namevhost crf.example.com (/etc/httpd/conf.d/vhostcrf.conf:1)
Syntax OK
@cfedde
cfedde / gist:5091772
Created March 5, 2013 16:51
an example
package BCV::LDAP::User;
use Moose;
use namespace::autoclean;
has entry => (
is => 'ro',
isa => 'Net::LDAP::Entry',
);
our $AUTOLOAD;
@cfedde
cfedde / gist:5392341
Created April 16, 2013 00:11
perltidy does not know about //=
#!/bin/perl
# Before perltidy
helper ndb => sub { state $db //= BCV::DB->new('SwitchCLLI') };
helper cdb => sub { state $db //= BCV::DB->new('STARS') };
# After perltidy
helper ndb => sub { state $db // = BCV::DB->new('SwitchCLLI') };
helper cdb => sub { state $db // = BCV::DB->new('STARS') };
@cfedde
cfedde / gist:6184945
Created August 8, 2013 14:15
What is going on here?
sudo ubic start nice_js
Starting nice_js... Can't open '/var/lib/ubic/tmp/1375914532.15896.993049.52270268.new' for writing: Permission denied at /usr/lib/perl5/site_perl/5.8.8/Ubic/AtomicFile.pm line 24.
temp file /var/lib/ubic/tmp/1375914532.15896.993049.52270268 not found after fork at /usr/lib/perl5/site_perl/5.8.8/Ubic.pm line 488.
cat /etc/ubic/service/nice_js.ini
module = Ubic::Service::SimpleDaemon
[options]
bin = node /opt/node/nICE/nice.js 24.40.52.128
user = bcv
@cfedde
cfedde / gist:6500228
Created September 9, 2013 19:21
snowman
#!/usr/bin/perl
use Modern::Perl;
use Math::Complex;
my $ul = cplx(-2.1, 1.2);
my $lr = cplx( 0.6,-1.2);
my $sx = (Re($lr) - Re($ul))/79;
my $sy = (Im($lr) - Im($ul))/26;
@cfedde
cfedde / gist:6715698
Created September 26, 2013 15:21
Is there a better way to call Exp here? It seems like I'm using i more often than I should.
package main
import (
"fmt"
"math/big"
)
func main() {
i := big.NewInt(6)
fmt.Println(i.Exp(i, i.Exp(i, i, nil), nil))
@cfedde
cfedde / gist:6717131
Last active December 24, 2015 00:29
How do I get the value of the 'type=' attribute out of the 'command' tag in this XML frag?
DB<12> p $r->at('command')->to_xml
<command type="Error" xmlns="" xmlns:c="C" xsi:type="c:ErrorResponse"><summary>[Error 4007] Invalid login ID: cfedde001c_as01</summary><summaryEnglish>[Error 4007] Invalid login ID: cfedde001c_as01</summaryEnglish></command>
DB<13> x $r->at('command')->attr
empty array
@cfedde
cfedde / command_type=Error
Last active December 24, 2015 00:40
Test case for how I suspect I'll be able to get at the "type=" attribute of this xml frag.
#!/usr/bin/env perl
use Modern::Perl;
use Mojo::DOM;
use Test::More;
my $xml = q|<?xml version="1.0" encoding="ISO-8859-1"?>
<command type="Error" xmlns="" xmlns:c="C" xsi:type="c:ErrorResponse"><summary>[Error 4007] Invalid login ID: cfedde001c_as01</summary><summaryEnglish>[Error 4007] Invalid login ID: cfedde001c_as01</summaryEnglish></command>
|;
my $r = Mojo::DOM->new()->xml(1)->parse($xml);
@cfedde
cfedde / gist:6734955
Last active December 24, 2015 03:08
What is special about the "name" attribute in this moose module?
use Modern::Perl;
package A;
use Moose;
use YAML::XS;
has size => (
is => 'ro',
default => 4,
);