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
@cfedde
cfedde / gist:6859336
Last active December 24, 2015 20:39
mysql explain is pretty useless.
mysql> explain select count(1) as count, device_sn, sum(moslq) from vqm_archive group by device_sn\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: vqm_archive
type: index
possible_keys: NULL
key: vqm_archive_device_sn_idx
key_len: 23
ref: NULL
@cfedde
cfedde / cute
Created September 30, 2013 20:20
mauke: slow
$ 23:37:43 cfedde@small:~
echo $'GET /exe/nph-lock HTTP/1.0\n' | nc mauke.hopto.org 80
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 648
<html>
<head>
<title>ݙ妌ࢽ䪟瞩⚱Ꮠ໕橂ጞsߥ㻾⣰掫䅚Ეᑵࣿȵແ赀㈒出鿎⚹ഗ꒏ࡘ◣⡯㴦ー䯠ֈᓚčĥ驝ሎ䣶཯େ∲حቔ奴ᕬ悾杚ඔ泞ଞ⪟争翝ඦ舋㣦࣪ႳԲመ㤃鰼✑἞䣝沗媴ஂ⨬╌퀧水⊰Ῐ뵁⅓⁩ᤫ쥙翫㬜ప⁻䊃ᷔ槵ᶅ慛ᢍ潥㔵฻㑰ם常ࣘෙ</title>
</head>
@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,
);
@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: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 / 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: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: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: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: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;