Skip to content

Instantly share code, notes, and snippets.

View lestrrat's full-sized avatar

lestrrat lestrrat

View GitHub Profile
shoebill% perl -MXML::LibXML -E 'say XML::LibXML->new()->parse_string("<foo>bar</foo>")->findvalue("baz")'
shoebill% perl -MXML::LibXML -E 'say XML::LibXML->new()->parse_string("<foo>bar</foo>")->findvalue("foo")'
bar
package main
import (
"log"
"math/rand"
"time"
)
type Promise struct {
done bool
@lestrrat
lestrrat / gist:281b5ecc69d3b3b9f12b
Created March 4, 2015 01:35
とうとう脳内デバッグだけ追えるgoroutineの並列度を突破したのでトレース用のPrintfをあちこちに仕込むことにした
package peco
import (
"log"
"os"
)
type traceLogger interface {
Printf(string, ...interface{})
}
@lestrrat
lestrrat / architecture.md
Created March 4, 2015 00:29
Ideas on new peco architecture

NEW peco architecture

Pipeline

  1. InputReader - Reads from os.Stdin or file
  2. RawListBuffer - Buffers output from InputReader
  3. QueryFilter - Receive stream of Line objects, and filters according to user query
  4. FilteredLineBuffer - Buffers output from QueryFilter
  5. PagedLineBuffer - Type of FilteredLineBuffer, but creates a "paged" view of the filtered buffer, so it can be displayed to the terminal
wg := &sync.WaitGroup{}
ch := make(chan struct{})
for i := 0; i < 100; i++ {
wg.Add(1)
go func(ch chan struct{}) {
defer wg.Done()
for _ = range ch {
r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name})
if err != nil {
log.Fatalf("could not greet: %v", err)
#!perl
use strict;
print <<EOM;
Hello, World!
EOM
exit 0;
print "Hello, $ARGV[0]\n"
@lestrrat
lestrrat / gist:5180bebeeafb1fd6394d
Created December 15, 2014 02:58
Convert .conf style config to .pl
perl -MData::Dumper -MConfig::General -E ‘$Data::Dumper::Indent = $Data::Dumper::Terse = $Data::Dumper::Sortkeys = 1; say Dumper(Config::General->new(“filename”)->config)
# At this point I'm just inching towards sending a request to the upstream.
# So first goal is to make http1client_connect() to succeed...
# Instead I get this.
# I wonder why chunked.on_setup_ostream is being called twice, thus (I believe
# is causing the assert to fail)
# Note: upstream server is NOT running, so I'm expecting a failure to connect.
shoebill% ./h2o
Creating filter of size 40
inserted new filter at 1
ADDR=$(docker inspect $CONTAINER_NAME | perl -ne '/"IPAddress": "([^"]+)"/ && print "$1\n"')
echo "host-record=$CONTAINER_NAME,$ADDR" > /etc/dnsmasq.d/docker-$CONTAINER_NAME
service dnsmasq restart